• 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!

New function help

spodniarz

New Member
Joined
Dec 30, 2007
Messages
36
Reaction score
4
Hello.
Somebody can help me in new function? The new function must disappear monster when he stand on field.

Here is code.

Actions.Cpp

Code:
//doMonsterRemoverhealth(uid,health)
lua_register(luaState, "doMonsterRemoverhealth", ActionScript::luaActiondoMonsterRemoverhealth);

Code:
int ActionScript::luaActiondoMonsterRemoverhealth(lua_State *L)
{
//dodoMonsterRemoverhealth(uid,health)
int removerhealth = (int)internalGetNumber(L);
unsigned int cid = (unsigned int)internalGetNumber(L);

ActionScript *action = getActionScript(L);

const KnownThing* tmp = action->GetMonsterByUID(cid);
if(tmp){
Monster *monster = (Monster*)(tmp->thing);
int tmp = monster->health - removerhealth;
if(tmp <= 0){
monster->health = 1;
}
else if(tmp > monster->healthmax){
monster->health = monster->healthmax;
}
else{
monster->health = tmp;
}
monster->sendStats();

SpectatorVec list;
SpectatorVec::iterator it;

action->game->getSpectators(Range(monster->pos,true), list);
for(it = list.begin(); it != list.end(); ++it) {
monster* p = dynamic_cast<Monster*>(*it);
if(p)
p->removerMonsterHealth(monster);
}
}
else{
lua_pushnumber(L, -1);
std::cout << "luadoMonsterRemoverhealth: monster not found" << std::endl;
return 1;
}

lua_pushnumber(L, 0);
return 1;
}

And actions.h

Code:
static int luaActionDoMonsterRemoverhealth(lua_State *L);

The script must be look like this

Code:
function onStepIn(cid, item, frompos, item2, topos)
if item.uid == 11111 then
doMonsterRemoverHealth(cid,99999999)
else
return 0
end
return 1
end

Ye i have function onStepIn.
Thanks and sorry for my bad english ; P...
 
you don't need a new function for that, just use "doRemoveCreature(cid)" that function should work for the use.
 
Back
Top