I'm trying to make an onKill event script just for learning:
It's very simple, and I don't know why it's not working... no errors in console neither other infos...
This is the creaturescripts.xml line I've added:
And yea my file name is tasks.lua and it's inside data\creaturescripts\scripts xd
This is the creatureevent.cpp:
I'm just trying to kill rats and nothing happens, this should bring a msg after killing the rat
This is OTHire 0.0.3
Code:
function onKill(cid, target, lastHit)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "On script")
return true
end
It's very simple, and I don't know why it's not working... no errors in console neither other infos...
This is the creaturescripts.xml line I've added:
Code:
<event name="tasks" type="kill" script="tasks.lua"/>
And yea my file name is tasks.lua and it's inside data\creaturescripts\scripts xd
This is the creatureevent.cpp:
Code:
bool CreatureEvent::executeOnKill(Creature* creature, Creature* target, bool lastHit)
{
//onKill(cid, target, lasthit)
if(m_scriptInterface->reserveScriptEnv()){
ScriptEnviroment* env = m_scriptInterface->getScriptEnv();
#ifdef __DEBUG_LUASCRIPTS__
std::stringstream desc;
desc << creature->getName();
env->setEventDesc(desc.str());
#endif
env->setScriptId(m_scriptId, m_scriptInterface);
env->setRealPos(creature->getPosition());
uint32_t cid = env->addThing(creature);
uint32_t targetId = env->addThing(target);
lua_State* L = m_scriptInterface->getLuaState();
m_scriptInterface->pushFunction(m_scriptId);
lua_pushnumber(L, cid);
lua_pushnumber(L, targetId);
lua_pushboolean(L, (lastHit ? true : false) );
bool result = m_scriptInterface->callFunction(3);
m_scriptInterface->releaseScriptEnv();
return result;
}
else{
std::cout << "[Error] __ENABLE_SERVER_DIAGNOSTIC__Call stack overflow. CreatureEvent::executeOnKill" << std::endl;
return 0;
}
}
I'm just trying to kill rats and nothing happens, this should bring a msg after killing the rat
This is OTHire 0.0.3