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

Slot item check functions

Alindane

Banned User
Joined
Apr 25, 2009
Messages
82
Reaction score
1
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 :p

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:
Lua:
Or a [B]bit[/B] more readable:
[code]
function hasPlayerWeapon(cid, itemid)
    -- Function by Colandus
    local ret = isItemEquipped(cid, CONST_SLOT_RIGHT, itemid)
    return [B]bit[/B].bor(ret, isItemEquipped(cid, CONST_SLOT_LEFT, itemid))
end
hehe get it...a bit more readable, lol. jp.
 
Back
Top