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

chest weapon item problem

carre

Advanced OT User
Joined
Apr 23, 2013
Messages
881
Solutions
1
Reaction score
157
Location
Sweden
Hi
When I try get a weapon from chest as a starter knight I get unlimited
I only want 1x then the chest is empty
Screenshot_4.png
my weapons.lua
Code:
function onUse(cid, item, frompos, item2, topos)

    if item.uid == 61904 then
        if getPlayerStorageValue(cid,61904) == -1 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Jagged Sword.")
            doPlayerAddItem(cid,8602,1)
            setPlayerStorageValue(cid,61904,1)
        else
            doPlayerSendTextMessage(cid,25,"The chest is empty.")
        end
    elseif item.uid == 61905 then
        if getPlayerStorageValue(cid,61904) == -1 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Daramanian Mace.")
            doPlayerAddItem(cid,2439,1)
            setPlayerStorageValue(cid,61904,1)
        else
            doPlayerSendTextMessage(cid,25,"The chest is empty.")
        end
     elseif item.uid == 61906 then
        if getPlayerStorageValue(cid,61904) == -1 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Steel Axe.")
            doPlayerAddItem(cid,8601,1)
            setPlayerStorageValue(cid,61905,1)
        else
            doPlayerSendTextMessage(cid,25,"The chest is empty.")
        end
    end
    return true
end
 
Lua:
function onUse(cid, item, frompos, item2, topos)

    if item.uid == 61904 then
        if getPlayerStorageValue(cid,61904) == 1 then
            doPlayerSendTextMessage(cid,25,"The chest is empty.")
        else
            doPlayerSendTextMessage(cid,25,"You have chosen an Jagged Sword.")
            doPlayerAddItem(cid,8602,1)
            setPlayerStorageValue(cid,61904,1)
        end
    elseif item.uid == 61905 then
        if getPlayerStorageValue(cid,61904) == 1 then
            doPlayerSendTextMessage(cid,25,"The chest is empty.")
        else
            doPlayerSendTextMessage(cid,25,"You have chosen an Daramanian Mace.")
            doPlayerAddItem(cid,2439,1)
            setPlayerStorageValue(cid,61904,1)
        end
     elseif item.uid == 61906 then
        if getPlayerStorageValue(cid,61904) == 1 then
            doPlayerSendTextMessage(cid,25,"The chest is empty.")
        else
            doPlayerSendTextMessage(cid,25,"You have chosen an Steel Axe.")
            doPlayerAddItem(cid,8601,1)
            setPlayerStorageValue(cid,61905,1)
        end
    end
    return true
end
:rolleyes:
 
More clean and use only one storage value.
Lua:
local storage = 60000 --use a unused storage value

function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid,storage) ~= 1 then
        if item.uid == 61904 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Jagged Sword.")
            doPlayerAddItem(cid,8602,1)
        elseif item.uid == 61905 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Daramanian Mace.")
            doPlayerAddItem(cid,2439,1)
         elseif item.uid == 61906 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Steel Axe.")
            doPlayerAddItem(cid,8601,1)
        end
        setPlayerStorageValue(cid, storage, 1)
    else
        doPlayerSendTextMessage(cid,25,"The chest is empty.")
    end
    return true
end
 
More clean and use only one storage value.
Lua:
local storage = 60000 --use a unused storage value

function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid,storage) ~= 1 then
        if item.uid == 61904 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Jagged Sword.")
            doPlayerAddItem(cid,8602,1)
        elseif item.uid == 61905 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Daramanian Mace.")
            doPlayerAddItem(cid,2439,1)
         elseif item.uid == 61906 then
            doPlayerSendTextMessage(cid,25,"You have chosen an Steel Axe.")
            doPlayerAddItem(cid,8601,1)
        end
        setPlayerStorageValue(cid, storage, 1)
    else
        doPlayerSendTextMessage(cid,25,"The chest is empty.")
    end
    return true
end
it work.
thank you again @zxmatzx
 
Got bored and checked some old threads, wanna try and improve this script for practice and stuffs :D

Lua:
local storage = 60000
local Chests = {
[61904] = {itemweapon = 8602, text = "You have chosen a Jagged Sword."},
[61905] = {itemweapon = 2439, text = "You have chosen a Daramanian Mace."},
[61906] = {itemweapon = 8601, text = "You have chosen a Steel Axe."}
    }
function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid,storage) ~= 1 then
        doPlayerAddItem(cid,Chests[item.uid].itemweapon, 1)
        doPlayerSendTextMessage(cid,25,Chests[item.uid].text)
        setPlayerStorageValue(cid, storage, 1)
    else
        doPlayerSendTextMessage(cid,25,"The chest is empty.")
    end
    return true
end

yeet
 
Last edited:
Got bored and checked some old threads, wanna try and improve this script for practice and stuffs :D
and im bored at work

Lua:
local storage = 60000
local Chests = {
[61904] = {itemweapon = 8602, text = "You have chosen a Jagged Sword."},
[61905] = {itemweapon = 2439, text = "You have chosen a Daramanian Mace."},
[61906] = {itemweapon = 8601, text = "You have chosen a Steel Axe."}
    }
function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid,storage) ~= 1 then
        doPlayerAddItem(cid,Chests[item.uid].itemweapon, 1)
        doPlayerSendTextMessage(cid,25,Chests[item.uid].text)
        setPlayerStorageValue(cid, storage, 1)
    else
        doPlayerSendTextMessage(cid,25,"The chest is empty.")
    end
    return true
end

yeet
Figured I'd chip in.

Lua:
local storage = 60000
local chests = {
    [61904] = 8602, -- [uniqueid] = itemid
    [61905] = 2439,
    [61906] = 8601
}

function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid, storage) < 1 then
        local reward = chests[item.uid]
        doPlayerAddItem(cid, reward, 1)
        doPlayerSendTextMessage(cid, 25, "You have chosen " .. getItemInfo(reward).article .. " " .. getItemInfo(reward).name .. ".")
        setPlayerStorageValue(cid, storage, 1)
        return true
    end
    doPlayerSendTextMessage(cid, 25, "The chest is empty.")
    return true
end
 
Last edited:
Figured I'd chip in.

Lua:
local storage = 60000
local chests = {
    [61904] = 8602, -- [uniqueid] = itemid
    [61905] = 2439,
    [61906] = 8601
}

function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid, storage) < 1 then
        doPlayerAddItem(cid, chests[item.uid], 1)
        doPlayerSendTextMessage(cid, 25, "You have chosen " .. getItemInfo.article .. " " .. getItemInfo.name .. ".")
        setPlayerStorageValue(cid, storage, 1)
        return true
    end
    doPlayerSendTextMessage(cid, 25, "The chest is empty.")
    return true
end
Don't you mean getItemInfo(item2.uid)?
 
Back
Top