View Full Version : [SOLVED] not allowing a player to equip gear

04-12-2015, 04:34 AM
Is it possible to make it so a player can't equip gear in eluna? I know it's possible in C++ but, is it in eluna?

For example

function PlayerEquip(event, player, item, bag, slot)
if (player:GetItemEntry() == xxx) then
player:SendBroadcastMessage('You can't equip this item')
-- either stop them from equiping the item or unequip it.

RegisterPlayerEvent(PlayerEquip, 29)

Sorry to bother everyone, just been working on it for a while and if I can't get it in eluna i'll have to learn C++ or something :P.

Thank you,

04-12-2015, 05:42 AM
Look at Rochet2's answer below this post for the proper way to do what you're asking. Few things you should note on your above code (I'm pointing this out so your code doesn't cause confusion for searchers):

RegisterPlayerEvent(PlayerEquip, 29)

This isn't correct. Arguments goes as follows: ( event, function ), [( event, function, shots]], not "function, event, ...".


RegisterPlayerEvent(29, PlayerEquip) (http://eluna.emudevs.com/Global/RegisterPlayerEvent.html)

The OnEquip hook has 'item' parameter which instead of trying to get the itemId by a non-existent player related method, you can do:

if (item:GetEntry() == 1234) then

Also, "player:GetItemEntry()" does not exist and SendBroadcastMessage argument should have " " around the message.

04-12-2015, 09:25 AM
The "proper" way to do this is:

local function CanEquipCheck(event, player, itemEntry)
if (itemEntry == 1234) then
player:SendNotification("You can't equip this item")
return 83

RegisterPlayerEvent(31, CanEquipCheck)

Or then instead of 83 make it return some other valid InventoryResult

04-12-2015, 07:34 PM
Sorry, I was doing it in a rush and wasn't paying attention. Thanks Rochet, helped out a lot :D