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

Solved Trying to do quest where you choose 1/x items

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
922
Location
Chile
Hello guys, i have been trying to do a quest that you can choose between 5 chest, you can only choose one, you know, this type of quest, but i cant get it to work!!
this is what i have so far

plz guys help me here, i use otx 2.52

Code:
<action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />




Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,20970)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Sword.")
doPlayerAddItem(cid,20970,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,20902)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Axe.")
doPlayerAddItem(cid,20902,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,20915)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Hammer.")
doPlayerAddItem(cid,20915,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,21035)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Spear.")
doPlayerAddItem(cid,21035,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,21160)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Magic Staff.")
doPlayerAddItem(cid,21160,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end

end
return 1
end


CONSOLE
Code:
[19/11/2016 20:32:56] [Warning - Actions::registerEvent] Duplicate registered item uid: 23450
[19/11/2016 20:32:56] [Warning - Actions::registerEvent] Duplicate registered item uid: 23450
[19/11/2016 20:32:56] [Warning - Actions::registerEvent] Duplicate registered item uid: 23450
[19/11/2016 20:32:56] [Warning - Actions::registerEvent] Duplicate registered item uid: 23450
 
you cant have all the same unique id
use an action id

you're trying to use 5 of the same id for 5 different items
Code:
local t = {
    [23450] = {string = 'Sword', item = 20970},
    [23451] = {string = 'Axe', item = 20902},
    [23452] = {string = 'Hammer', item = 20915},
    [23453] = {string = 'Spear', item = 21035},
    [23454] = {string = 'Staff', item = 21160}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = t[item.actionid]
    local queststatus = getPlayerStorageValue(cid, 20970)
    if tmp then
        if queststatus == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a Rare Prestige ' .. tmp.string)
            doPlayerAddItem(cid, tmp.item, 1)
            doPlayerSetStorageValue(cid, 20970, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
        end
    end
    return true
end

Code:
<action fromaid="23450" toaid="23454" event="script" value="xxx.lua"/>

http://lua-users.org/wiki/TablesTutorial
https://www.lua.org/pil/3.4.html
 
you cant have all the same unique id
use an action id

you're trying to use 5 of the same id for 5 different items
Code:
local t = {
    [23450] = {string = 'Sword', item = 20970},
    [23451] = {string = 'Axe', item = 20902},
    [23452] = {string = 'Hammer', item = 20915},
    [23453] = {string = 'Spear', item = 21035},
    [23454] = {string = 'Staff', item = 21160}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = t[item.actionid]
    local queststatus = getPlayerStorageValue(cid, 20970)
    if tmp then
        if queststatus == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a Rare Prestige ' .. tmp.string)
            doPlayerAddItem(cid, tmp.item, 1)
            doPlayerSetStorageValue(cid, 20970, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
        end
    end
    return true
end

Code:
<action fromaid="23450" toaid="23454" event="script" value="xxx.lua"/>

http://lua-users.org/wiki/TablesTutorial
https://www.lua.org/pil/3.4.html



oooh man thanks, but it didnt work :( now i can open all chest, it shows whats inside (empty) and i dont get any items :(

chest should look like this right?
CUtZxGo.png
 
Last edited:
i dont know too much but you can check paradox quest scripts i think it's works similar as whats are you looking for.... use rme to check chests also check actions folders change uniqueid etc
sorry my inglish
 
i dont know too much but you can check paradox quest scripts i think it's works similar as whats are you looking for.... use rme to check chests also check actions folders change uniqueid etc
sorry my inglish
that is exactly how i found the script at the beginning and didnt work for me :(
 
you cant have all the same unique id
use an action id

you're trying to use 5 of the same id for 5 different items
Code:
local t = {
    [23450] = {string = 'Sword', item = 20970},
    [23451] = {string = 'Axe', item = 20902},
    [23452] = {string = 'Hammer', item = 20915},
    [23453] = {string = 'Spear', item = 21035},
    [23454] = {string = 'Staff', item = 21160}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = t[item.actionid]
    local queststatus = getPlayerStorageValue(cid, 20970)
    if tmp then
        if queststatus == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a Rare Prestige ' .. tmp.string)
            doPlayerAddItem(cid, tmp.item, 1)
            doPlayerSetStorageValue(cid, 20970, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
        end
    end
    return true
end

Code:
<action fromaid="23450" toaid="23454" event="script" value="xxx.lua"/>

http://lua-users.org/wiki/TablesTutorial
https://www.lua.org/pil/3.4.html

t[item.actionid] is not a temporary variable :cool:
string should be replaced with item :cool:
item should be replaced with itemId :cool:

OR EQUIVALENT sir :D


im not serious
 
Last edited:
Hello guys, i have been trying to do a quest that you can choose between 5 chest, you can only choose one, you know, this type of quest, but i cant get it to work!!
this is what i have so far

plz guys help me here, i use otx 2.52

Code:
<action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="23450" script="Quests/rareprestigeweapons.lua" />




Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,20970)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Sword.")
doPlayerAddItem(cid,20970,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,20902)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Axe.")
doPlayerAddItem(cid,20902,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,20915)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Hammer.")
doPlayerAddItem(cid,20915,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,21035)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Spear.")
doPlayerAddItem(cid,21035,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 23450 then
queststatus = getPlayerStorageValue(cid,21160)
if queststatus == -1 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Magic Staff.")
doPlayerAddItem(cid,21160,1)
setPlayerStorageValue(cid,6076,1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end

end
return 1
end


CONSOLE
Code:
[19/11/2016 20:32:56] [Warning - Actions::registerEvent] Duplicate registered item uid: 23450
[19/11/2016 20:32:56] [Warning - Actions::registerEvent] Duplicate registered item uid: 23450
[19/11/2016 20:32:56] [Warning - Actions::registerEvent] Duplicate registered item uid: 23450
[19/11/2016 20:32:56] [Warning - Actions::registerEvent] Duplicate registered item uid: 23450

Not sure if you got it working, if not just copy Annihilator and create new edited action/unique IDs. It's the same exact thing.
 
god damnn still doesnt work, and i copied the same annihi quest, with this all chests work, i can get all this items
ooh and my anni works perfectly >.<

Code:
<action uniqueid="20970" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="20915" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="20902" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="21160" script="Quests/rareprestigeweapons.lua" />
        <action uniqueid="21035" script="Quests/rareprestigeweapons.lua" />


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

       if item.uid == 20970 then
        queststatus = getPlayerStorageValue(cid,20970)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Sword.")
               doPlayerAddItem(cid,20970,1)
               setPlayerStorageValue(cid,20970,1)
           else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
           end
       elseif item.uid == 20915 then
        queststatus = getPlayerStorageValue(cid,20915)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a  Rare Prestige Hammer.")
               doPlayerAddItem(cid,20915,1)
               setPlayerStorageValue(cid,20915,1)
           else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
           end
       elseif item.uid == 20902 then
        queststatus = getPlayerStorageValue(cid,20902)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a rare Prestige Axe.")
               doPlayerAddItem(cid,20902,1)
               setPlayerStorageValue(cid,20902,1)
           else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
        end
       elseif item.uid == 21160 then
        queststatus = getPlayerStorageValue(cid,21160)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Magic Staff.")
            local bag = doPlayerAddItem(cid,21160,1)
            doAddContainerItem(bag,21160,1)
               setPlayerStorageValue(cid,21160,1)
           else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
           end
              elseif item.uid == 21035 then
        queststatus = getPlayerStorageValue(cid,21035)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found a Rare Prestige Spear.")
               doPlayerAddItem(cid,21035,1)
               setPlayerStorageValue(cid,21035,1)
           else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
        end
    end
       return 1
end


hpB2z_F.png
 
Last edited:
I would make the code more like this...

Code:
local items = {
[20970] = {itemid = 20970, msg = "You have found a rare prestige sword."},
[20915] = {itemid = 20915, msg = "You have found a rare prestige hammer."},
[20902] = {itemid = 20902, msg = "You have found a rare prestige axe."},
[21160] = {itemid = 21160, msg = "You have found a rare prestige magic staff."},
[21035] = {itemid = 21035, msg = "You have found a rare prestige magic spear."}
}

function onUse(cid, item, frompos, item2, topos)
    ITEM = items[getItemAttribute(item.uid, 'uid')]
        if not ITEM then return false end
      
        if getPlayerStorageValue(cid, ITEM.itemid) == 1 then
            return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
        end
      
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ITEM.msg)
    doPlayerAddItem(cid, ITEM.itemid, 1)
    setPlayerStorageValue(cid, ITEM.itemid, 1)
return true
end
 
I would make the code more like this...

Code:
local items = {
[20970] = {itemid = 20970, msg = "You have found a rare prestige sword."},
[20915] = {itemid = 20915, msg = "You have found a rare prestige hammer."},
[20902] = {itemid = 20902, msg = "You have found a rare prestige axe."},
[21160] = {itemid = 21160, msg = "You have found a rare prestige magic staff."},
[21035] = {itemid = 21035, msg = "You have found a rare prestige magic spear."}
}

function onUse(cid, item, frompos, item2, topos)
    ITEM = items[getItemAttribute(item.uid, 'uid')]
        if not ITEM then return false end
     
        if getPlayerStorageValue(cid, ITEM.itemid) == 1 then
            return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
        end
     
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ITEM.msg)
    doPlayerAddItem(cid, ITEM.itemid, 1)
    setPlayerStorageValue(cid, ITEM.itemid, 1)
return true
end

just tried that, it gives me all the items, doesnt block the others when one is chosen :(
 
Deleted previous post cause it wouldn't let me edit. Realized your otx version is ancient
Code:
local queststatus = getPlayerStorageValue(cid,21000)
function onUse(cid, item, frompos, item2, topos)
    if queststatus > 0 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
        return false
    end
    doPlayerAddItem(cid,item.uid,1)
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemInfo(item.uid).article .. " " .. getItemInfo(item.uid).name)
    setPlayerStorageValue(cid,21000, 1)
   return 1
end
give this a try
 
Deleted previous post cause it wouldn't let me edit. Realized your otx version is ancient
Code:
local queststatus = getPlayerStorageValue(cid,21000)
function onUse(cid, item, frompos, item2, topos)
    if queststatus > 0 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
        return false
    end
    doPlayerAddItem(cid,item.uid,1)
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemInfo(item.uid).article .. " " .. getItemInfo(item.uid).name)
    setPlayerStorageValue(cid,21000, 1)
   return 1
end
give this a try



like this??
Code:
local queststatus = getPlayerStorageValue(cid,21000)
function onUse(cid, item, frompos, item2, topos)
    if queststatus > 0 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
        return false
    end
    doPlayerAddItem(cid,item.uid,1)
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemInfo(item.uid).article .. " " .. getItemInfo(item.uid).name)
    setPlayerStorageValue(cid,21000, 1)
   return 1
end


because that gives me several errors
Code:
[20/11/2016 17:28:4] [Error - Test Interface]
[20/11/2016 17:28:4] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:4] Description:
[20/11/2016 17:28:4] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:4] [Error - Action Interface]
[20/11/2016 17:28:4] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:5] Description:
[20/11/2016 17:28:5] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:5] [Error - Test Interface]
[20/11/2016 17:28:5] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:5] Description:
[20/11/2016 17:28:5] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:5] [Error - Action Interface]
[20/11/2016 17:28:5] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:5] Description:
[20/11/2016 17:28:5] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:5] [Error - Test Interface]
[20/11/2016 17:28:5] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:5] Description:
[20/11/2016 17:28:5] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:5] [Error - Action Interface]
[20/11/2016 17:28:5] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:5] Description:
[20/11/2016 17:28:5] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:5] [Error - Test Interface]
[20/11/2016 17:28:5] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:5] Description:
[20/11/2016 17:28:5] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:6] [Error - Action Interface]
[20/11/2016 17:28:6] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:6] Description:
[20/11/2016 17:28:6] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:6] [Error - Test Interface]
[20/11/2016 17:28:6] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:6] Description:
[20/11/2016 17:28:6] (LuaInterface::luaGetCreatureStorage) Creature not found

[20/11/2016 17:28:6] [Error - Action Interface]
[20/11/2016 17:28:6] data/actions/scripts/Quests/rareprestigeweapons.lua
[20/11/2016 17:28:6] Description:
[20/11/2016 17:28:6] (LuaInterface::luaGetCreatureStorage) Creature not found
 
woopsie
Code:
function onUse(cid, item, frompos, item2, topos)
   local queststatus = getPlayerStorageValue(cid,21000)
   if queststatus > 0 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
        return false
    end
    doPlayerAddItem(cid,item.uid,1)
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemInfo(item.uid).article .. " " .. getItemInfo(item.uid).name)
    setPlayerStorageValue(cid,21000, 1)
   return 1
end
 
woopsie
Code:
function onUse(cid, item, frompos, item2, topos)
   local queststatus = getPlayerStorageValue(cid,21000)
   if queststatus > 0 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
        return false
    end
    doPlayerAddItem(cid,item.uid,1)
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemInfo(item.uid).article .. " " .. getItemInfo(item.uid).name)
    setPlayerStorageValue(cid,21000, 1)
   return 1
end

uff this is so weird, now i can choose only one, but from all the chests that are there, 10 in total, i only need this for the weapons (5) and also the chest is open showing its inside (empty)

Code:
local items = {
[20970] = {itemid = 20970, msg = "You have found a rare prestige sword."},
[20915] = {itemid = 20915, msg = "You have found a rare prestige hammer."},
[20902] = {itemid = 20902, msg = "You have found a rare prestige axe."},
[21160] = {itemid = 21160, msg = "You have found a rare prestige magic staff."},
[21035] = {itemid = 21035, msg = "You have found a rare prestige magic spear."}
}


function onUse(cid, item, frompos, item2, topos)
   local queststatus = getPlayerStorageValue(cid,21000)
   if queststatus > 0 then
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
        return false
    end
    doPlayerAddItem(cid,item.uid,1)
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have found " .. getItemInfo(item.uid).article .. " " .. getItemInfo(item.uid).name)
    setPlayerStorageValue(cid,21000, 1)
   return 1
end
 
Back
Top