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

MoveEvent Unequipable Items

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
Hello, Ive been inactive for a while and this might be a silly script (and/or be silly scripted) but I saw someone from an old post with this doubt of "how to prevent an equipped item from being dropped".

Even though he got a solution which was to make a new custom item removing the "moveable" property, here is another solution that I think is easier to apply, for anyone still having this doubt.

In movements.xml: (Im using item 2656, which is a blue robe, for the example)

PHP:
<movevent type="DeEquip" itemid="2656" slot="armor" event="script" value="Unequipable.lua"/>

In Unequipable.lua:
Lua:
function onDeEquip(cid, item, slot)
	doPlayerSendTextMessage(cid, 18, "Sorry, you cannot unequip this item.")
	doRemoveItem(item.uid)
	doPlayerAddItem(cid, item.itemid)
return 1
end

So as you can read from the script what it does is simply if you try to drop a certain equipped item (or move it to any other slot), it removes the item and adds it in the exact same slot (at least it works that way for me), so "to players" it looks simply like it was never moved.

So thats it, I use it on my private server and it works without problem, but if you have any problem dont hesitate to tell me about it Ill see if I can solve it.

Hope it helps, and sorry if it has been done already Im too tired to look right now.
-GF

PS: If you know how to make this for unequipped items AKA "items in containers (bag, bp, etc)" feel free to share, I dont think I can pull that one off with only scripting.
 
Last edited:
config.item -> item.itemid

@@@
did you test in all possible ways? drop to water, logout, drop to teleport, etc, etc?
 
config.item -> item.itemid

Yep sorry I updated some stuff and forgot to change that one, Im a bit tired :p

@@@
did you test in all possible ways? drop to water, logout, drop to teleport, etc, etc?

Yep, all worked for me. For example, if you try dropping to water you wont even see the "something fell on water" animation, the item is removed before anything happens, so it's just "remove-add".

On another *general* note, only thing I havent tested is for items equipped for example on the hands like left or right hand, which Im unsure if they will be added to the same slot. Most probably if someone would need this for items in hands, they would require to do it with 2 items on the 2 hands for it to work (I use it that way).

But I believe people who use "unequippable" items would use full unequippable sets anyway so in that case there is no margin for error since all slots are occupied and unequippable.
 
Last edited:
'return false' does not do the trick instead of removing and adding the item??
 
'return false' does not do the trick instead of removing and adding the item??

Nope *weirdly enough* it doesn't, I tried it before ending here (and also returning -1/LUA_ERROR and result is the same, nothing).

If you return any of those, what happens is you get the "Sorry no unequip" msg but the item gets unequipped/dropped anyway.
 
Well it is good but doing it in source is also easy and you really can't move it. Just set a certain action id for "unmoveable items".


//EDIT:
Just add:
Code:
	if(item->getActionId() == 65530)
    { 
    		player->sendCancel("You cannot deequip this item.");
    		return false;
      }

Before:
Code:
ReturnValue ret = internalMoveItem(player, fromCylinder, toCylinder, toIndex, item, count, NULL);

In function:
Code:
bool Game::playerMoveItem(uint32_t playerId, const Position& fromPos,
	uint16_t spriteId, int16_t fromStackpos, const Position& toPos, uint8_t count)
In game.cpp
Code:
if(item->getActionId() == 65530) { 
	player->sendCancel("You cannot deequip this item.");
	return false;
}

Now just give the item actionid 65530 and it won't be moveable
 
Last edited:
Code:
function onDeEquip(cid, item, slot)   
	doPlayerSendTextMessage(cid, 18, "Sorry, you cannot unequip this item.")
	return false
end
Code:
<movevent type="DeEquip" actionid="65530" slot="armor" event="script" value="Unequipable.lua"/>
this should work, I can't help you past this because I don't have a server
on Debian, also I'm not sure about the XML tag since I don't have a server.
 
@Guitar Freak
drop on the ground or add another item in same slot and it dont work.
better do it on sources.
 
Back
Top