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

Compiling Erro OnSpawn(cid)

eduardbean

Member
Joined
Nov 26, 2010
Messages
129
Solutions
2
Reaction score
16
I tying to compile my source 0.4 rev 3887 with this code:

http://otland.net/threads/creatureevent-onspawn-cid.134039

but, cant finish, cuze have this erro:

Code:
  In member function 'uint32_t CreatureEvent::executeOnSpawn(Creature*)':
line: 1937 >> \creatureevent.cpp could not convert '((CreatureEvent*)this)->CreatureEvent::<anonymous>.Event::m_scriptData' to 'bool'
line: 1938 >> \creatureevent.cpp no match for 'operator*' in '*((CreatureEvent*)this)->CreatureEvent::<anonymous>.Event::m_scriptData' 
line: 1938 >>\creatureevent.cpp *** [obj//creatureevent.o] Error 1

Code:
line: 1936
line: 1937            if(m_scriptData)
line: 1938                scriptstream << *m_scriptData;
anyone can solve it ?
 
Replace executeOnSpawn with this:
Code:
uint32_t CreatureEvent::executeOnSpawn(Creature* creature)
{
    //onSpawn(cid)
    if(m_interface->reserveEnv())
    {
        ScriptEnviroment* env = m_interface->getEnv();
        if(m_scripted == EVENT_SCRIPT_BUFFER)
        {
            env->setRealPos(creature->getPosition());
            std::stringstream scriptstream;
           
            scriptstream << "local cid = " << env->addThing(creature) << std::endl;
            scriptstream << m_scriptData;

            bool result = true;
            if(m_interface->loadBuffer(scriptstream.str()))
            {
                lua_State* L = m_interface->getState();
                result = m_interface->getGlobalBool(L, "_result", true);
            }
           
            m_interface->releaseEnv();
            return result;
        }
        else
        {
            #ifdef __DEBUG_LUASCRIPTS__
                std::stringstream desc;
                desc << creature->getName();
                env->setEvent(desc.str());
            #endif
   
   
            env->setScriptId(m_scriptId, m_interface);
            env->setRealPos(creature->getPosition());
               
            lua_State* L = m_interface->getState();
            m_interface->pushFunction(m_scriptId);
           
            lua_pushnumber(L, env->addThing(creature));
           
            bool result = m_interface->callFunction(1);
            m_interface->releaseEnv();
            return result;
        }
    }
    else
    {
        std::clog << "[Error - CreatureEvent::executeCast] Call stack overflow." << std::endl;
        return 0;
    }
}
 
i recompiled and gave no error, however my script dont work:

creature.xml

Code:
    <event type="spawn" name="monsterThink" event="script" value="onspawn.lua"/>

Script :

Code:
function onSpawn(cid)
    print("Spawned")
    return true
end
 
Not sure if it is called on startup.
Did you kill some monsters and what for respawn?
 
Back
Top