• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Help! Skills reset system

seto sazo

Member
Joined
Apr 27, 2009
Messages
162
Reaction score
21
Yo. This script works. It just lags my server hardcore when someone dies. Anyway to make it so it doesn't lag when people logout?
LUA:
function onLogout(cid)
			   if isKnight(cid) then
   		if getPlayerMagLevel(cid) < 6 then
			doPlayerAddMagLevel(cid, 6-getPlayerMagLevel(cid))
		end
		if getPlayerSkill(cid, SKILL_SWORD) < 80 then
			doPlayerAddSkill(cid, SKILL_SWORD, 80-getPlayerSkill(cid,SKILL_SWORD))
		end
				if getPlayerSkill(cid, SKILL_CLUB) < 80 then
			doPlayerAddSkill(cid, SKILL_CLUB, 80-getPlayerSkill(cid,SKILL_CLUB))
		end
				if getPlayerSkill(cid, SKILL_SHIELD) < 80 then
			doPlayerAddSkill(cid, SKILL_SHIELD, 80-getPlayerSkill(cid,SKILL_SHIELD))
		end
				if getPlayerSkill(cid, SKILL_AXE) < 80 then
			doPlayerAddSkill(cid, SKILL_AXE, 80-getPlayerSkill(cid,SKILL_AXE))
		end
	elseif isDruid(cid) or isSorcerer(cid) then
		if getPlayerMagLevel(cid) < 63 then
			doPlayerAddMagLevel(cid, 63-getPlayerMagLevel(cid))
		end
						if getPlayerSkill(cid, SKILL_SHIELD) < 20 then
			doPlayerAddSkill(cid, SKILL_SHIELD, 20-getPlayerSkill(cid,SKILL_SHIELD))
		end
	elseif isPaladin(cid) then
		if getPlayerSkill(cid, SKILL_DISTANCE) < 80 then
			doPlayerAddSkill(cid, SKILL_DISTANCE, 80-getPlayerSkill(cid,SKILL_DISTANCE))
		end
						if getPlayerSkill(cid, SKILL_SHIELD) < 60 then
			doPlayerAddSkill(cid, SKILL_SHIELD, 60-getPlayerSkill(cid,SKILL_SHIELD))
		end
		   		if getPlayerMagLevel(cid) < 19 then
			doPlayerAddMagLevel(cid, 19-getPlayerMagLevel(cid))
		end
end
return true
end
 
Last edited:
You can't remove stuff from this script. Its all core stuff. My guess is that its from all the ifs and ends Lol. I just dont know how to group things differently. Bit of an amateur here. Thats why I'm posting. Because I need help.
 
I suggested that because your script shouldn't normally cause any freezes, and you're not getting any errors are you?
 
Nope =/. Its a war server. Script is made so it sets you skills back to default. say Axe 80. Unlike levels, skills dont downgrade. I tried. So I had to put deathlosspercent = 100 in my config. So that when you die, you skills will definitely go below "80". The skills are the problem area. I can login and logout and it doesnt lag. But when I die and loose skills or magic level. It lags. I've tried dbquery's but they dont work because my save = 1 I think. I cant go save = 0 because I have a ton of other scripts for donations, rewards, addons, etc that depend on save = 1
 
Last edited:
player.cpp, remove this from Player::onDeath()
[cpp] //Skill loss
uint64_t lostSkillTries, sumSkillTries;
for(int16_t i = 0; i < 7; ++i) //for each skill
{
lostSkillTries = sumSkillTries = 0;
for(uint32_t c = 11; c <= skills[SKILL_LEVEL]; ++c) //sum up all required tries for all skill levels
sumSkillTries += vocation->getReqSkillTries(i, c);

sumSkillTries += skills[SKILL_TRIES];
lostSkillTries = (uint64_t)std::ceil(sumSkillTries * ((double)(percent * lossPercent[LOSS_SKILLS]) / 100.));
while(lostSkillTries > skills[SKILL_TRIES])
{
lostSkillTries -= skills[SKILL_TRIES];
skills[SKILL_TRIES] = vocation->getReqSkillTries(i, skills[SKILL_LEVEL]);
if(skills[SKILL_LEVEL] < 11)
{
skills[SKILL_LEVEL] = 10;
skills[SKILL_TRIES] = lostSkillTries = 0;
break;
}
else
skills[SKILL_LEVEL]--;
}

skills[SKILL_TRIES] = std::max((int32_t)0, (int32_t)(skills[SKILL_TRIES] - lostSkillTries));
}[/cpp]
 
Hmmm. What happens when people get 100 frags. (Skills and Ml are gained with Frags). Have ml 90. or if there a knight 100/100 etc. And they dont die. They go into PZ and logout. Theyll login with the same stuff. There isn't are shortened Lua code? Or a different script I can use?
 
make them not save. iologindata.cpp, remove:
[cpp] // skills
for(int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)
{
query.str("");
query << "UPDATE `player_skills` SET `value` = " << player->skills[SKILL_LEVEL] << ", `count` = " << player->skills[SKILL_TRIES] << " WHERE `player_id` = " << player->getGUID() << " AND `skillid` = " << i << db->getUpdateLimiter();
if(!db->query(query.str()))
return false;
}[/cpp]
 
[cpp] query << "`maglevel` = " << player->magLevel << ", ";[/cpp]&[cpp] query << "`manaspent` = " << player->manaSpent << ", ";[/cpp]
 
Back
Top