• 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 resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Feature Creaturescript: onMoveItem(moveItem, frompos, position, cid)

For some reason the 0.3.6pl1 dev I had didn't contain these functions, lol, can find it now but I get errors, lol.
 
Yo guys
I made my own function onMoveItem, but now I saw that Mock already did, but I have a question going to this topic.
If I move a item towards a container or into equipment the toPos variable is like x=65536, y=slotid, z=slot or smth -> Is there a way to get the unique id of the backpack or container it is moved to out of this function:
bool Game::playerMoveItem(uint32_t playerId, const Position& fromPos, uint16_t spriteId, int16_t fromStackpos, const Position& toPos, uint8_t count)??


@Mock
You should add the 'count' to your function since item.type will return the full count and not the moved count of the item.
 
Last edited:
It only works for items, but for creatures you can use 'onPush(cid, target)'.

Bump my question xD
 
when using it any item cant be moved:
Code:
[01/03/2011 16:00:29] [Error - CreatureScript Interface] 
[01/03/2011 16:00:29] data/creaturescripts/scripts/moverpieza.lua:onMoveItem
[01/03/2011 16:00:29] Description: 
[01/03/2011 16:00:29] data/creaturescripts/scripts/moverpieza.lua:2: attempt to index global 'moveitem' (a nil value)
[01/03/2011 16:00:29] stack traceback:
[01/03/2011 16:00:29] 	data/creaturescripts/scripts/moverpieza.lua:2: in function <data/creaturescripts/scripts/moverpieza.lua:1>

with the script on example:
Lua:
function onMoveItem(moveItem, frompos, position, cid)
     if moveitem.itemid == 6500 then
          doPlayerSendTextMessage(cid,25,'This item is blocked! you cannot move it!')
          return false   
     end
end

edit:
>.< solved... problem of capital leters xD moveItem.itemid instead of moveitem.itemid
 
Last edited:
can some one help me ?

ERROR COMPILING

Code:
  creatureevent.cpp
..\creatureevent.cpp(118): error C2839: invalid return type 'CreatureEvent **' for overloaded 'operator ->'
..\creatureevent.cpp(118): error C2039: 'second' : is not a member of 'std::_Vector_iterator<_Myvec>'
          with
          [
              _Myvec=std::_Vector_val<CreatureEvent *,std::allocator<CreatureEvent *>>
          ]
..\creatureevent.cpp(118): error C2227: left of '->getEventType' must point to class/struct/union/generic type
..\creatureevent.cpp(118): error C2065: 'CREATURE_EVENT_MOVEITEM' : undeclared identifier
..\creatureevent.cpp(119): error C2839: invalid return type 'CreatureEvent **' for overloaded 'operator ->'
..\creatureevent.cpp(119): error C2039: 'second' : is not a member of 'std::_Vector_iterator<_Myvec>'
          with
          [
              _Myvec=std::_Vector_val<CreatureEvent *,std::allocator<CreatureEvent *>>
          ]
..\creatureevent.cpp(119): error C2227: left of '->executeMoveItem' must point to class/struct/union/generic type
..\creatureevent.cpp(215): error C2065: 'CREATURE_EVENT_MOVEITEM' : undeclared identifier
..\creatureevent.cpp(282): error C2065: 'CREATURE_EVENT_MOVEITEM' : undeclared identifier
..\creatureevent.cpp(282): error C2051: case expression not constant
..\creatureevent.cpp(338): error C2065: 'CREATURE_EVENT_MOVEITEM' : undeclared identifier
..\creatureevent.cpp(338): error C2051: case expression not constant
..\creatureevent.cpp(468): error C2653: 'LuaScriptInterface' : is not a class or namespace name
..\creatureevent.cpp(468): error C3861: 'pushThing': identifier not found
..\creatureevent.cpp(469): error C2653: 'LuaScriptInterface' : is not a class or namespace name
..\creatureevent.cpp(469): error C3861: 'pushPosition': identifier not found
..\creatureevent.cpp(470): error C2653: 'LuaScriptInterface' : is not a class or namespace name
..\creatureevent.cpp(470): error C3861: 'pushPosition': identifier not found

Build FAILED.

0.4 REV 4556
 
I managed to made the whole code works with latest 0.4, but mock said that I shouldn't use 0.4 since it can crash my server =/
 
Mock you've done a lot of mistakes. Some of the things is part of the other places. But...
The application of this is useless.
I want to do script like this:
Lua:
local ItemID = {2222, 2651, 2653, 2220, 2655}

function onMoveItem(moveItem, frompos, position, cid)
if(isInArray(ItemID, moveItem.itemid)) then
	doPlayerSendCancel(cid, "You cannot drop this item!")
	return false
end
end
This script of course didn't work properly, why?
Because, I can take this item into the backpack, but when i want to throw him to the ground show me the words: "You cannot drop this item!", and i can't move this object. I guess it doesn't work properly...
 
Your code makes onKill function stops working, and when I does not declare a function onMove in .xml file then the server stops working.
 
Your code makes onKill function stops working, and when I does not declare a function onMove in .xml file then the server stops working.
i'ts because you are using in tfs 0.4, this code is for 0.3.6 ONLY!
but if you are using 0.3.6 you have did a great mess with the instalation.
 
Yep, I use TFS 0.3.6pl1
I did everything according to your instructions, but onkill function does not work. When I delete your function server works correctly, without errors and crashes.
 
how to check is position is an equiped backpack? if its stackpos is 0 and tile too?
 
Back
Top