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

RevScripts command

alcapone

Member
Joined
Jan 13, 2021
Messages
247
Reaction score
19
If the player has any item equipped
helmet,armor,items like shield etc and backpack
you cannot use the command


Lua:
local test= TalkAction("!test")
function test.onSay(player, words, param)


for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
        local slotItem = player:getSlotItem(slot)
           if slotItem  then
        
 player:sendCancelMessage("have item")
            return true
           end
    end
    
    
    return false
end


test:register()
 
Last edited:
bump
You need to loop to check if there is any equipment in the character's slots.
I recommend studying a little about loop in lua.
Post automatically merged:

A little tip:
i = CONST_SLOT_FIRST, CONST_SLOT_LAST
I'm trying to do it. He can only execute this command if I'm without the set. From what I noticed, what I posted worked, but do you think it's bad?
 
code seems to be okay, just player will send message "!test" cause of return true (this is how talkaction's in lua work, false = msg will not appear, true, msg will show), i dont see any error in your code tbh, if something not work make sure that CONST_SLOT_HEAD its declared as "first" and CONST_SLOT_AMMO as last
 
I don't understand what you want, but let's try it this way:
Lua:
local test = TalkAction("!test")

function Player.usingEquipment(self)
    self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are using equipment.")

    return true
end

function Player.notUsingEquipment(self)
    self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are not using equipment.")

    return true
end

function test.onSay(player, words, param)
    for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
        local slotItem = player:getSlotItem(slot)
        if slotItem then
            player:usingEquipment()
        else
            player:notUsingEquipment()
        end
    end

    return false
end

test:register()
 
Back
Top