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

Lua Destroy item out of the bag 'n' onmove

luccagomes

New Member
Joined
Jul 30, 2015
Messages
153
Reaction score
1
How to fix this script?

To destroy item out of the bag
For exemple, i click and it on ground, and delete, no only in BP


And delete item on move? It's possible?

I use 0.4
Code:
<action itemid="2596" event="script" value="deleteparcelonopenrook.lua"/>

Code:
function onUse(cid, item, frompos, item2, topos)
   if getPlayerVocation(cid) == 0 then
     doPlayerRemoveItem(cid, 2596, 1)
     return 1
   end
end
 
Last edited:
Well.. you could simply make it impossible for players on rookgaard to not be able to open the parcel?
They could then just open it when they get to main.

actions.xml

Code:
<action itemid="2596" event="script" value="useParcelRookgaard.lua"/>
actions/scripts/useParcelRookgaard.lua
Code:
function onUse(cid, item, frompos, item2, topos)
  if getPlayerVocation(cid) == 0 then
     doCreatureSay(cid, "You cannot use parcels while in rookgaard.", TALKTYPE_ORANGE_1)
   else
     return false
   end
  return true
end
------------------------
And for the move problem you can do this
creaturescripts.xml

Code:
<event type="throw" name="moveParcelRookgaard" event="script" value="moveParcelRookgaard.lua"/>
creaturescripts/scripts/moveParcelRookgaard.lua
Code:
function onThrow(cid, item, fromPosition, toPosition)
  if getPlayerVocation(cid) == 0 then
     if item.itemid == 2596 then
       return doCreatureSay(cid, "You cannot move parcels while in rookgaard.", TALKTYPE_ORANGE_1) and false
     end
   end
  return true
end
creaturescripts/scripts/login.lua [somewhere at the bottom with the other registered events]
Code:
registerCreatureEvent(cid, "moveParcelRookgaard")
 
Last edited:
Well.. you could simply make it impossible for players on rookgaard to not be able to open the parcel?
They could then just open it when they get to main.

actions.xml

Code:
<action itemid="2596" event="script" value="useParcelRookgaard.lua"/>
actions/scripts/useParcelRookgaard.lua
Code:
function onUse(cid, item, frompos, item2, topos)
  if getPlayerVocation(cid) == 0 then
     doCreatureSay(cid, "You cannot use parcels while in rookgaard.", TALKTYPE_ORANGE_1)
   else
     return false
   end
  return true
end
------------------------
And for the move problem you can do this
creaturescripts.xml

Code:
<event type="throw" name="moveParcelRookgaard" event="script" value="moveParcelRookgaard.lua"/>
creaturescripts/scripts/moveParcelRookgaard.lua
Code:
function onThrow(cid, item, fromPosition, toPosition)
  if getPlayerVocation(cid) == 0 then
     if item.itemid == 2596 then
       return doCreatureSay(cid, "You cannot move parcels while in rookgaard.", TALKTYPE_ORANGE_1) and false
     end
   end
  return true
end
creaturescripts/scripts/login.lua [somewhere at the bottom with the other registered events]
Code:
registerCreatureEvent(cid, "moveParcelRookgaard")

Ty bro, but i dont want to block, it i know
I want delete parcel, i dont want parcels on rook..
I do know how to delete item without the bag :(

doPlayerRemoveItem(cid, 2596, 1)
/\ it work only if item is inside bp

To delete items on move, you can do it the same way as here.
https://otland.net/threads/problem-quests-lua.235466/#post-2272237
If the itemid should be the moveitem instead if the tileitem just remove tileitem="1" in the XML line.

I try it, but dont work

Code:
<movevent type="AddItem" tileitem="1" itemid="2596" event="script" value="delete_parcel_rook_move.lua"/>

Code:
function onAddItem(moveitem, tileitem, position, cid)
   if getPlayerVocation(cid) == 0 then
     doPlayerRemoveItem(cid, 2596, 1)
     return 1
   end
end
 
Last edited:
Code:
doRemoveItem(moveitem.uid)
Instead of doPlayerRemoveItem, and remove tileitem="1" since that is only if the itemid should be the item you throw the item on.
Also for the action script (function onUse), use doRemoveItem instead of doPlayerRemoveItem. With doPlayerRemoveItem it indeed only works if the player has the item.
Code:
doRemoveItem(item.uid)
 
Ty bro, but i dont want to block, it i know
I want delete parcel, i dont want parcels on rook..
I do know how to delete item without the bag :(

doPlayerRemoveItem(cid, 2596, 1)
/\ it work only if item is inside bp



I try it, but dont work

Code:
function onAddItem(moveitem, tileitem, position, cid)
   if getPlayerVocation(cid) == 0 then
     doPlayerRemoveItem(cid, 2596, 1)
     return 1
   end
end
That's the beautiful part though. As long as they cannot buy parcels, (which would be useless as all the parcels would simply be stuck in their backpack, or on the ground).. and only have them mailed to them from someone in main.. they won't be able to move or look inside the parcel, until they get a vocation.
After a week or so, everyone will realize parcels are useless to send to rook, and you'll never see a parcel again.
Once in awhile a player might try to send some stuff to rookgaard, but again, they'll just have the parcel stuck in the mailbox, unable to be opened, or moved.
On the other side, if you destroy the parcel your literally deleting the parcel itself, AND anything inside.
What if someone sent a giant sword to the player? You'll delete 15k. Boh? 30k. MPA? 130k.
It's not fair to the player if you delete their items.

But if your still determined to delete the items.. use this.
Code:
function onUse(cid, item, frompos, item2, topos)
   if getPlayerVocation(cid) == 0 then
     doRemoveItem(item.uid, 1)
   end
   return true
end
 
Well.. you could simply make it impossible for players on rookgaard to not
Code:
<event type="throw" name="moveParcelRookgaard" event="script" value="moveParcelRookgaard.lua"/>
creaturescripts/scripts/moveParcelRookgaard.lua
Code:
function onThrow(cid, item, fromPosition, toPosition)
  if getPlayerVocation(cid) == 0 then
     if item.itemid == 2596 then
       return doCreatureSay(cid, "You cannot move parcels while in rookgaard.", TALKTYPE_ORANGE_1) and false
     end
   end
  return true
end
creaturescripts/scripts/login.lua [somewhere at the bottom with the other registered events]
Code:
registerCreatureEvent(cid, "moveParcelRookgaard")

In my sources don't have function throw...
I search and found function OnMOve
Code:
//Função add por luanluciano93uint32_tCreatureEvent::executeMoveItem(Player* player,Item* item,uint8_t count,constPosition& fromPos,constPosition& toPos,Item* toContainer,Item* fromContainer,int16_t fstack){//onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos)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));
scriptstream <<"local count = "<< count << std::endl;
env->streamThing(scriptstream,"toContainer", toContainer, env->addThing(toContainer));
env->streamThing(scriptstream,"fromContainer", fromContainer, env->addThing(fromContainer));
env->streamPosition(scriptstream,"fromPos", fromPos, fstack);
env->streamPosition(scriptstream,"toPos", toPos,0);


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));
lua_pushnumber(L, count);LuaInterface::pushThing(L, toContainer, env->addThing(toContainer));LuaInterface::pushThing(L, fromContainer, env->addThing(fromContainer));LuaInterface::pushPosition(L, fromPos, fstack);LuaInterface::pushPosition(L, toPos,0);

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

I try it:
Dont give me erros, but dont remove the item.. Why?
Code:
<event type="moveitem" name="moveParcelRookgaard" event="script" value="moveParcelRookgaard.lua"/>

Code:
function onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos)
   if getPlayerVocation(cid) == 0 then
     if item.itemid == 2596 then
       doRemoveItem(item.uid, 1)
       return true
     end
   end
end
 
Back
Top