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

check actionid

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
454
Reaction score
15
hello guys how i can check items action id for items in backpack
if player have scroll with actionid 3214 and chance <-= 10 let him teleport

0.4
 
Solution
This will try to remove one of the random items in config, if they exist.

Lua:
local config = {
    destination = {x = 1000, y = 1000, z = 7},
    chance      = 10,
    actionId    = 3214,
    itemId      = 9020,
    item        = {{8300, 10}, {8301, 3}, {8302, 5}}
}

function onUse(cid, item, fromPos, itemEx, toPos)
    local teleportItem = getPlayerItemById(cid, true, config.itemId)
    if not teleportItem then
        doPlayerSendCancel(cid, "You don't have the required item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    if teleportItem.actionid ~= config.actionId then
        doPlayerSendCancel(cid, "Invalid item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end...

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,244
Solutions
71
Reaction score
556
Location
Hell
Since you haven't provided any code I am assuming you're asking for one, in that case this should be in Requests section.

------------------------------------------
Is this what you are asking for?
XML:
<action actionid="12123" event="script" value="custom/tplever.lua"/>

Lua:
local config = {
    destination = {x = 1000, y = 1000, z = 7},
    chance      = 10,
    actionId    = 3214,
    itemId      = 9020
}

function onUse(cid, item, fromPos, itemEx, toPos)

    local teleportItem = getPlayerItemById(cid, true, config.itemId)
    if not teleportItem then
        doPlayerSendCancel(cid, "You don't have the required item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    if teleportItem.actionid ~= config.actionId then
        doPlayerSendCancel(cid, "Invalid item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    local chance = math.random(1, 100)
    if chance > config.chance then
        doSendAnimatedText(fromPos, "FAIL", COLOR_YELLOW)
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    doTeleportThing(cid, config.destination)
    doSendMagicEffect(config.destination, CONST_ME_TELEPORT)
    doRemoveItem(teleportItem.uid, 1)
    return true
end
 
Last edited:
OP
OP
ConAn Edujawa

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
454
Reaction score
15
Since you haven't provided any code I am assuming you're asking for one, in that case this should be in Requests section.

------------------------------------------
Is this what you are asking for?
XML:
<action actionid="12123" event="script" value="custom/tplever.lua"/>

Lua:
local config = {
    destination = {x = 1000, y = 1000, z = 7},
    chance      = 10,
    actionId    = 3214,
    itemId      = 9020
}

function onUse(cid, item, fromPos, itemEx, toPos)

    local teleportItem = getPlayerItemById(cid, true, config.itemId)
    if not teleportItem then
        doPlayerSendCancel(cid, "You don't have the required item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    if teleportItem.actionid ~= config.actionId then
        doPlayerSendCancel(cid, "Invalid item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    local chance = math.random(1, 100)
    if chance > config.chance then
        doSendAnimatedText(fromPos, "FAIL", COLOR_YELLOW)
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    doTeleportThing(cid, config.destination)
    doSendMagicEffect(config.destination, CONST_ME_TELEPORT)
    doRemoveItem(teleportItem.uid, 1)
    return true
end
yes its what i want but need small edit in this scrip
add this linein config
Lua:
local config = {

    destination = {x = 1000, y = 1000, z = 7},

    chance      = 10,

    actionId    = 3214,

 item = {8300, 10, 8301, 3, 8302, 5},

    itemId      = 9020

}

if chance not work remove random items and random count from item
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,244
Solutions
71
Reaction score
556
Location
Hell
This will try to remove one of the random items in config, if they exist.

Lua:
local config = {
    destination = {x = 1000, y = 1000, z = 7},
    chance      = 10,
    actionId    = 3214,
    itemId      = 9020,
    item        = {{8300, 10}, {8301, 3}, {8302, 5}}
}

function onUse(cid, item, fromPos, itemEx, toPos)
    local teleportItem = getPlayerItemById(cid, true, config.itemId)
    if not teleportItem then
        doPlayerSendCancel(cid, "You don't have the required item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    if teleportItem.actionid ~= config.actionId then
        doPlayerSendCancel(cid, "Invalid item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    local chance = math.random(1, 100)
    if chance > config.chance then
        -- remove random item
        local itemToRemove = config.item[math.random(#config.item)]
        doPlayerRemoveItem(cid, itemToRemove[1], math.random(itemToRemove[2]))

        doSendAnimatedText(fromPos, "FAIL", COLOR_YELLOW)
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    doTeleportThing(cid, config.destination)
    doSendMagicEffect(config.destination, CONST_ME_TELEPORT)
    doRemoveItem(teleportItem.uid, 1)
    return true
end
 
Solution
OP
OP
ConAn Edujawa

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
454
Reaction score
15
This will try to remove one of the random items in config, if they exist.

Lua:
local config = {
    destination = {x = 1000, y = 1000, z = 7},
    chance      = 10,
    actionId    = 3214,
    itemId      = 9020,
    item        = {{8300, 10}, {8301, 3}, {8302, 5}}
}

function onUse(cid, item, fromPos, itemEx, toPos)
    local teleportItem = getPlayerItemById(cid, true, config.itemId)
    if not teleportItem then
        doPlayerSendCancel(cid, "You don't have the required item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    if teleportItem.actionid ~= config.actionId then
        doPlayerSendCancel(cid, "Invalid item.")
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    local chance = math.random(1, 100)
    if chance > config.chance then
        -- remove random item
        local itemToRemove = config.item[math.random(#config.item)]
        doPlayerRemoveItem(cid, itemToRemove[1], math.random(itemToRemove[2]))

        doSendAnimatedText(fromPos, "FAIL", COLOR_YELLOW)
        doSendMagicEffect(fromPos, CONST_ME_POFF)
        return true
    end

    doTeleportThing(cid, config.destination)
    doSendMagicEffect(config.destination, CONST_ME_TELEPORT)
    doRemoveItem(teleportItem.uid, 1)
    return true
end
thx man
 
Top