Hello in this function is bug. I don't know where...
...just kills you.
I very need this functions to change max hp and mana at weapon equip.
luascript.cpp
luascript.h
creature.cpp
creature.h
When using this script, as I said, it kills you and when you relog, you login with 0 HP so you die again and when you login the second time you don't die.
And in movements I make function:
and
And don't works. Any help ?
...just kills you.
I very need this functions to change max hp and mana at weapon equip.
luascript.cpp
Code:
//doCreatureChangeMaxHealth(cid, newHealth)
lua_register(m_luaState, "doCreatureChangeMaxHealth", LuaScriptInterface::luaDoCreatureChangeMaxHealth);
Code:
int32_t LuaScriptInterface::luaDoCreatureChangeMaxHealth(lua_State* L)
{
//doCreatureChangeMaxHealth(uid,newHealth)
int32_t healthChange = (int32_t)popNumber(L);
uint32_t cid = popNumber(L);
ScriptEnviroment* env = getScriptEnv();
Creature* creature = env->getCreatureByUID(cid);
if(creature)
{
creature->changeMaxHealth(healthChange);
lua_pushnumber(L, LUA_NO_ERROR);
}
else
{
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushnumber(L, LUA_ERROR);
}
return 1;
}
luascript.h
Code:
static int32_t luaDoCreatureChangeMaxHealth(lua_State* L);
creature.cpp
Code:
void Creature::changeMaxHealth(int32_t healthChange)
{
healthMax = (int32_t)healthChange;
g_game.addCreatureHealth(this);
}
creature.h
Code:
virtual void changeMaxHealth(int32_t healthChange);
When using this script, as I said, it kills you and when you relog, you login with 0 HP so you die again and when you login the second time you don't die.
And in movements I make function:
Code:
function onEquip(cid, item)
doCreatureChangeMaxHealth(cid, (getMaxHealth+50))
return TRUE
end
Code:
function onDeEquip(cid, item)
doCreatureChangeMaxHealth(cid, (getMaxHealth-50))
return TRUE
end