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

Feature [creatureEvent] onMove very advanced

Ok error on compile hour:
errorcompilehour.png

With luaInterface and
Code:
			if(m_scriptData)
				scriptstream << *m_scriptData;
 
			bool result = true;
and maybe
Code:
			LuaInterface::pushPosition(L, fromPosition);
			LuaInterface::pushPosition(L, toPosition);
Can any help me? it's for 0.3.6,Thanks !
 
PHP:
uint32_t CreatureEvent::executeOnMove(Player* player, Item* item, const Position& fromPosition, const Position& toPosition, 
	Item* fromItem, Item* toItem, Item* fromGround, Item* toGround, std::map<std::string,int> status)
{
	//onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, equip, hold, depot, slot)
	if(m_interface->reserveEnv())
	{
		ScriptScriptEnviroment* env = m_interface->getEnv();
		if(m_scripted == EVENT_SCRIPT_BUFFER)
		{
			env->setRealPos(player->getPosition());
			std::stringstream scriptstream;
			scriptstream << "local cid = " << env->addThing(player) << std::endl;
 
			env->streamThing(scriptstream, "item" ,item, env->addThing(item));
			env->streamPosition(scriptstream, "fromPosition", fromPosition);
			env->streamPosition(scriptstream, "toPosition", toPosition);
 
 
			env->streamThing(scriptstream, "fromItem",fromItem, env->addThing(fromItem));	
			env->streamThing(scriptstream, "toItem",toItem, env->addThing(toItem));
			env->streamThing(scriptstream, "fromGround",fromGround, env->addThing(fromGround));
			env->streamThing(scriptstream, "toGround",toGround, env->addThing(toGround));
 
 
 
			scriptstream << "equip = " << (int32_t)status["equip"] << std::endl;
			scriptstream << "hold = " << (int32_t)status["hold"] << std::endl;
			scriptstream << "depot = " << (int32_t)status["depot"] << std::endl;
			scriptstream << "slot = " << (int32_t)status["slot"] << 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__
			char desc[30];
			sprintf(desc, "%s", player->getName().c_str());
			env->setEvent(desc);
			#endif
 
			env->setScriptId(m_scriptId, m_interface);
			env->setRealPos(player->getPosition());
 
			lua_State* L = m_interface->getState();
			m_interface->pushFunction(m_scriptId);
 
			lua_pushnumber(L, env->addThing(player));
 
			LuaInterface::pushThing(L, item, env->addThing(item));
			LuaInterface::pushPosition(L, fromPosition);
			LuaInterface::pushPosition(L, toPosition);
 
			LuaInterface::pushThing(L, fromItem, env->addThing(fromItem));
			LuaInterface::pushThing(L, toItem, env->addThing(toItem));
			LuaInterface::pushThing(L, fromGround, env->addThing(fromGround));
			LuaInterface::pushThing(L, toGround, env->addThing(toGround));
 
			lua_pushnumber(L, status["equip"]);
			lua_pushnumber(L, status["hold"]);
			lua_pushnumber(L, status["depot"]);
			lua_pushnumber(L, status["slot"]);

 
			bool result = m_interface->callFunction(12);
			m_interface->releaseEnv();
			return result;
		}
	}
	else
	{
		std::clog << "[Error - CreatureEvent::executeMove] Call stack overflow." << std::endl;
		return 0;
	}
}

Try this
 
PHP:
uint32_t CreatureEvent::executeOnMove(Player* player, Item* item, const Position& fromPosition, const Position& toPosition, 
    Item* fromItem, Item* toItem, Item* fromGround, Item* toGround, std::map<std::string,int> status)
{
    //onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, equip, hold, depot, slot)
    if(m_interface->reserveEnv())
    {
        ScriptEnviroment* env = m_interface->getEnv();
        if(m_scripted == EVENT_SCRIPT_BUFFER)
        {
            env->setRealPos(player->getPosition());
            std::stringstream scriptstream;
            scriptstream << "local cid = " << env->addThing(player) << std::endl;
 
            env->streamThing(scriptstream, "item" ,item, env->addThing(item));
            env->streamPosition(scriptstream, "fromPosition", fromPosition);
            env->streamPosition(scriptstream, "toPosition", toPosition);
 
 
            env->streamThing(scriptstream, "fromItem",fromItem, env->addThing(fromItem));    
            env->streamThing(scriptstream, "toItem",toItem, env->addThing(toItem));
            env->streamThing(scriptstream, "fromGround",fromGround, env->addThing(fromGround));
            env->streamThing(scriptstream, "toGround",toGround, env->addThing(toGround));
 
 
 
            scriptstream << "equip = " << (int32_t)status["equip"] << std::endl;
            scriptstream << "hold = " << (int32_t)status["hold"] << std::endl;
            scriptstream << "depot = " << (int32_t)status["depot"] << std::endl;
            scriptstream << "slot = " << (int32_t)status["slot"] << 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__
            char desc[30];
            sprintf(desc, "%s", player->getName().c_str());
            env->setEvent(desc);
            #endif
 
            env->setScriptId(m_scriptId, m_interface);
            env->setRealPos(player->getPosition());
 
            lua_State* L = m_interface->getState();
            m_interface->pushFunction(m_scriptId);
 
            lua_pushnumber(L, env->addThing(player));
 
            LuaScriptInterface::pushThing(L, item, env->addThing(item));
            LuaScriptInterface::pushPosition(L, fromPosition);
            LuaScriptInterface::pushPosition(L, toPosition);
 
            LuaScriptInterface::pushThing(L, fromItem, env->addThing(fromItem));
            LuaScriptInterface::pushThing(L, toItem, env->addThing(toItem));
            LuaScriptInterface::pushThing(L, fromGround, env->addThing(fromGround));
            LuaScriptInterface::pushThing(L, toGround, env->addThing(toGround));
 
            lua_pushnumber(L, status["equip"]);
            lua_pushnumber(L, status["hold"]);
            lua_pushnumber(L, status["depot"]);
            lua_pushnumber(L, status["slot"]);

 
            bool result = m_interface->callFunction(12);
            m_interface->releaseEnv();
            return result;
        }
    }
    else
    {
        std::clog << "[Error - CreatureEvent::executeMove] Call stack overflow." << std::endl;
        return 0;
    }
}
 
man very thanks for all u help.. creatureevent.cpp done.
but i have only an error in game.cpp
PIC:
xd11n.png


Can u help me in this?
thanks!
 
Aff Bro, i have an error !! check this
32898110.png

no more error, only this
solve it please!
 
omg man nice codes, u re very nice man
very thanks ;X;X;X
works 100% perfectly
THANKS!
 
Doggynub, i have a serious error x.x!
when the players put the unique item (example of any itemID), to his depot, and the players put a moveable bag (example 1987) in his depot, move the unique item to his bag, and later can move the 1987 with container UniqueItem and it's possible move >.<
Undestood?
Unique item -> In Bag -> Move Bag to Floor (Player can Move Unique Items >.<)

Can u give me a good script of this system¿?
very thanks >.>
 
what about stacking items (for example 5gp) -- checking how much items in stack...
 
you can use item.type to get the item in stack, if this is what u are asking for
 
Could you add that examined the object for which it was thrown into another player's item in your backpack?
For example, a player has in a backpack another backpack, and I want to throwing some object on the backpack was going to check this bag itemId.
 
"Nubaza@

Doggynub, i have a serious error x.x!
when the players put the unique item (example of any itemID), to his depot, and the players put a moveable bag (example 1987) in his depot, move the unique item to his bag, and later can move the 1987 with container UniqueItem and it's possible move >.<
Undestood?
Unique item -> In Bag -> Move Bag to Floor (Player can Move Unique Items >.<)

Can u give me a good script of this system¿?
very thanks >.>"


I have the same problem, how to solve?

I'm not good in scripts = /
 
Code:
function onMove(params, go hear)
  maxuid = 5000 -- change with max uid of items (can't be infinite, uids are in use for players, creatures, items, npcs, etc)
  if(item.uid > 0 and item.uid < maxuid) then
     return true
  end
  return false
end
 
Hi Doggy I try use this script but this c++ code dont work

look to my script

PHP:
function onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
	if item.actionid == 20000 then
	doPlayerSendCancel(cid, "You cannot move this object.")
	return false
	end
end

i set in itens this actionid but on move this itens your script dont work
please explain to me how to use this fucntion ?
 
Back
Top