• 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 Function doAbsorbCombatPercentage && getCombatPercentageAbsorbed

bump

got same problem as up

any ideas how to fix it?

Try replacing 'LuaScriptInterface' with 'LuaInterface'

Example:
Code:
//.cpp
//doAbsorbCombatPercentage(cid, combat, percent)
lua_register(m_luaState, "doAbsorbCombatPercentage", LuaInterface::luaDoAbsorbCombatPercentage);

//.h
static int32_t luaDoAbsorbCombatPercentage(lua_State* L);

and
Code:
int32_t LuaInterface::luaDoAbsorbCombatPercentage(lua_State *L)
{           	
    ScriptEnviroment* env = getEnv();
    int32_t percent = popNumber(L);
    CombatType_t combat = (CombatType_t)popNumber(L);
       if(!combat)
       {
			errorEx(getError(LUA_ERROR_COMBAT_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
       } 
 
       Player* player = env->getPlayerByUID(popNumber(L));
       if(player)
       {    
			player->setAbsorbedPercent(combat, percent);
            lua_pushnumber(L, true);
       }
       else
       {       
           errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
           lua_pushnumber(L, false);
       }       
    return 1;
}
 
int32_t LuaInterface::luaGetCombatPercentageAbsorbed(lua_State *L)
{             	
    ScriptEnviroment* env = getEnv();
    CombatType_t combat = (CombatType_t)popNumber(L); 
       if(!combat)
       {
			errorEx(getError(LUA_ERROR_COMBAT_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
       } 
       if(Player* player = env->getPlayerByUID(popNumber(L)))
       {    
            lua_pushnumber(L, player->getAbsorbedPercent(combat));
       }    
       else
       {       
           errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
           lua_pushnumber(L, false);
       }       
    return 1;
}
 
nvm i fixed it:

change
Code:
static int32_t luaDoCombatAbsorbPercentage(lua_State* L);

to

Code:
static int32_t luaDoAbsorbCombatPercentage(lua_State* L);

well, you cannot attack with this script, any ideas how to fix it?
 
Last edited:
Back
Top