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

How can I add a check to this action, so as not to throw the item on the ground when using it.

demonrage

New Member
Joined
Oct 28, 2014
Messages
22
Reaction score
2
I'm using otx2 8.60


Code:
Lua:
function onUse(cid, item, frompos, item2, topos)

local dolls = {
    [12179] = {pet = "[Pet] Demon"},   
}
    
local go = dolls[item.itemid]
local summon = getCreatureSummons(cid)
local slotForUse = CONST_SLOT_AMMO
local item = getPlayerSlotItem(cid, slotForUse)
    ---------------------------------------------------
        local ammo = getPlayerSlotItem(cid, slotForUse)
    if ammo.uid ~= item.uid then
        return doPlayerSendCancel(cid, "The weapon must be located in your slot ammunition.")
    end
    
    if #summon >= 1 then
        for _, pid in ipairs(summon) do
            doRemoveCreature(pid)
            doCreatureSay(cid, ""..go.pet..", Recuar!", TALKTYPE_ORANGE_1)
        end
    return true
    end
    
    if (getPlayerItemCount(cid, item.itemid) <= 0) then
        doPlayerSendTextMessage(cid, 19, "Voce precisa do item em sua backpack ou slot toten.")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
        return true
    end

    if (getTilePzInfo(getCreaturePosition(cid))) then
        doPlayerSendTextMessage(cid, 19, "Voce nao pode sumonar seu PET em Protect Zone!")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
        return true
    end
    
    if (getPlayerStorageValue(cid, 6641) == 1 or isPlayer(cid)) then
        doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
        doCreatureSay(cid, ""..go.pet..", GO!", TALKTYPE_ORANGE_1)
    else
        doPlayerSendTextMessage(cid, 19, "Voce precisa da quest para usar esse PET!")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
    end
return true
end
 
try.
Lua:
function onUse(cid, item, frompos, item2, topos)
    local dolls = {
        [12179] = {pet = "[Pet] Demon"},   
    }
    
    local go = dolls[item.itemid]
    local summon = getCreatureSummons(cid)
    local slotForUse = CONST_SLOT_AMMO
    local ammo = getPlayerSlotItem(cid, slotForUse)
    
    if ammo.uid ~= item.uid then
        return doPlayerSendCancel(cid, "A arma deve estar no seu slot de munição.")
    end
    
    if #summon >= 1 then
        for _, pid in ipairs(summon) do
            doRemoveCreature(pid)
            doCreatureSay(cid, ""..go.pet..", Recuar!", TALKTYPE_ORANGE_1)
        end
        return true
    end
    
    if getPlayerItemCount(cid, item.itemid) <= 0 then
        doPlayerSendTextMessage(cid, 19, "Você precisa do item em sua mochila ou slot de totem.")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
        return true
    end
    
    if getTilePzInfo(getCreaturePosition(cid)) then
        doPlayerSendTextMessage(cid, 19, "Você não pode summonar seu PET em uma Zona de Proteção!")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
        return true
    end
    
    if getPlayerStorageValue(cid, 6641) == 1 or isPlayer(cid) then
        local playerTile = getThingPos(cid)
        if not isWalkable(playerTile.x, playerTile.y, playerTile.z, false, false, false, true) then
            doPlayerSendTextMessage(cid, 19, "Você não pode summonar seu PET aqui.")
            doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
            return true
        end
        local newItem = doCreateItem(item.itemid, 1, getPlayerPosition(cid))
        doRemoveItem(item.uid, 1)
        doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
        doCreatureSay(cid, ""..go.pet..", Vai!", TALKTYPE_ORANGE_1)
    else
        doPlayerSendTextMessage(cid, 19, "Você precisa da missão para usar este PET!")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
    end
    return true
end
 
try.
Lua:
function onUse(cid, item, frompos, item2, topos)
    local dolls = {
        [12179] = {pet = "[Pet] Demon"},  
    }
   
    local go = dolls[item.itemid]
    local summon = getCreatureSummons(cid)
    local slotForUse = CONST_SLOT_AMMO
    local ammo = getPlayerSlotItem(cid, slotForUse)
   
    if ammo.uid ~= item.uid then
        return doPlayerSendCancel(cid, "A arma deve estar no seu slot de munição.")
    end
   
    if #summon >= 1 then
        for _, pid in ipairs(summon) do
            doRemoveCreature(pid)
            doCreatureSay(cid, ""..go.pet..", Recuar!", TALKTYPE_ORANGE_1)
        end
        return true
    end
   
    if getPlayerItemCount(cid, item.itemid) <= 0 then
        doPlayerSendTextMessage(cid, 19, "Você precisa do item em sua mochila ou slot de totem.")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
        return true
    end
   
    if getTilePzInfo(getCreaturePosition(cid)) then
        doPlayerSendTextMessage(cid, 19, "Você não pode summonar seu PET em uma Zona de Proteção!")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
        return true
    end
   
    if getPlayerStorageValue(cid, 6641) == 1 or isPlayer(cid) then
        local playerTile = getThingPos(cid)
        if not isWalkable(playerTile.x, playerTile.y, playerTile.z, false, false, false, true) then
            doPlayerSendTextMessage(cid, 19, "Você não pode summonar seu PET aqui.")
            doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
            return true
        end
        local newItem = doCreateItem(item.itemid, 1, getPlayerPosition(cid))
        doRemoveItem(item.uid, 1)
        doConvinceCreature(cid, doSummonCreature(go.pet, getCreaturePosition(cid)))
        doCreatureSay(cid, ""..go.pet..", Vai!", TALKTYPE_ORANGE_1)
    else
        doPlayerSendTextMessage(cid, 19, "Você precisa da missão para usar este PET!")
        doSendAnimatedText(getPlayerPosition(cid), "Failed!", 180)
    end
    return true
end
I already solved it, thank you very much!
 
Back
Top