Lua:
function isItemEquipped(cid, slot, itemid)
-- Function by Colandus
if(isPlayer(cid) == FALSE) then
return LUA_ERROR
end
return (getPlayerSlotItem(cid, slot).itemid == itemid) and TRUE or FALSE
end
Take that function and use it as such:
Lua:
if(isItemEquipped(cid, CONST_SLOT_HEAD, 1939) == TRUE) then
-- code if item is in head!
end
Now, I just typed a random number for itemid, I don't know what that item is
Also you could need this function as well:
Lua:
function hasPlayerWeapon(cid, itemid)
-- Function by Colandus
return (isItemEquipped(cid, CONST_SLOT_RIGHT, itemid) == TRUE or isItemEquipped(cid, CONST_SLOT_LEFT, itemid) == TRUE) and TRUE or FALSE
end
Or a bit more readable:
Lua:
function hasPlayerWeapon(cid, itemid)
-- Function by Colandus
local ret = isItemEquipped(cid, CONST_SLOT_RIGHT, itemid)
return bit.bor(ret, isItemEquipped(cid, CONST_SLOT_LEFT, itemid))
end
That would check if he's got a certain item in his hands, you could check for weapons, shields or any item you want...
Last edited: