• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[C++] - getPlayerSkillLevel(cid, skill)

Oskar1121

Excellent OT User
Joined
Jul 15, 2009
Messages
700
Reaction score
710
Location
Poland
Looking for someone to edit my getPlayerSkillLevel(cid, skill) in order to fetch the actual skill, not a base (that is, when we started giving the armor skill let's also check the same with spells decreasing / increasing skill)
 
@up
Wrong query.
PHP:
function getSkillLevel(cid, skill_id)
	return db.getResult("SELECT `value` FROM `player_skills` WHERE `player_id`= " .. getPlayerGUID(cid) .. " AND `skillid` = " .. skill_id):getDataInt("skill_id")
end
 
[cpp]int32_t LuaScriptInterface::luaGetPlayerSkillLevel(lua_State* L)
{
//getPlayerSkillLevel(cid, skill[, ignoreModifiers = true])
bool ignoreModifiers = true;
if(lua_gettop(L) > 2)
ignoreModifiers = popNumber(L);

uint32_t skill = popNumber(L);

ScriptEnviroment* env = getEnv();
if(const Player* player = env->getPlayerByUID(popNumber(L)))
{
if(skill <= SKILL_LAST)
lua_pushnumber(L, ignoreModifiers ? player->skills[skill][SKILL_LEVEL] :
player->skills[skill][SKILL_LEVEL] + player->getVarSkill((skills_t)skill));
else
lua_pushboolean(L, false);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}

return 1;
}[/cpp]
[cpp]//
//getPlayerSkillLevel(cid, skill[, ignoreModifiers = true])
lua_register(m_luaState, "getPlayerSkillLevel", LuaScriptInterface::luaGetPlayerSkillLevel);[/cpp]
I'm sure elf won't be happy, but I changed ignoreModifiers to default to true so it won't break the existing scripts, especially those who rely on skill tries.
You'll have to add , false manually in ethereal spear script though.
 
Last edited:
Back
Top