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

Help with quest chests

Ozo

New Member
Joined
Jun 30, 2008
Messages
58
Reaction score
0
Hello, i've tried for hours to get this to work..

I have 4 chests, and i only want you to be able to get rewards from 1 of them.

I've tried reconfiguring the annihilator chests etc.. no luck
Has anyone got a working script for this matter? - for the latest TFS release

I would greatly appreciate it!
 
Code:
function onUse(cid, item)
    config = { storage = 1, ch1 = 2, ch2 = 3, ch3 = 4, ch4 = 5 }
    
    if isInArray({config.ch1,config.ch2,config.ch3,config.ch4}, item.actionid) == TRUE and getPlayerStorageValue(cid, config.storage) ~= 1 then
        doPlayerSendTextMessage(cid, 17, "The chest is empty.")
        return FALSE
    end
    if item.actionid == config.ch1 then
        doPlayerAddItem(cid, item, count)
        doPlayerSendTextMessage(cid, 17, "You have found item.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch2 then
        doPlayerAddItem(cid, item, count)
        doPlayerSendTextMessage(cid, 17, "You have found item.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch3 then
        doPlayerAddItem(cid, item, count)
        doPlayerSendTextMessage(cid, 17, "You have found item.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch4 then
        doPlayerAddItem(cid, item, count)
        doPlayerSendTextMessage(cid, 17, "You have found item.")
        setPlayerStorageValue(cid, config.storage, 1)
    end
end
 
Thank you for your reply Marcinek, the problem is that i do not understand what is what... i do understand where to put the item ID's but the rest is scribble to me :)
 
So, shall i leave the player storage at 1, or change it to maybe.. 4242?
And the chest, do i write anything in unique id inside the editor? since the normal chests reacts when you type a unique ID.

Thank you!
 
This is what the script looks like now, and it doesn't work:
Code:
function onUse(cid, item)
    config = { storage = 4224, ch1 = 4050, ch2 = 4051, ch3 = 4052, ch4 = 4053 }
    
    if isInArray({config.ch1,config.ch2,config.ch3,config.ch4}, item.actionid) == TRUE and getPlayerStorageValue(cid, config.storage) ~= 1 then
        doPlayerSendTextMessage(cid, 17, "The chest is empty.")
		return FALSE
    end
    if item.actionid == config.ch1 then
        doPlayerAddItem(cid, 8912, 1)
        doPlayerSendTextMessage(cid, 17, "You have found a Springsprout Rod.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch2 then
        doPlayerAddItem(cid, 8853, 1)
        doPlayerSendTextMessage(cid, 17, "You have found the Ironworker.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch3 then
        doPlayerAddItem(cid, 8920, 1)
        doPlayerSendTextMessage(cid, 17, "You have found a Wand of Starstorm.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch4 then
        doPlayerAddItem(cid, 2539, 1)
        doPlayerSendTextMessage(cid, 17, "You have found a Phoenix Shield.")
        setPlayerStorageValue(cid, config.storage, 1)
    end
end
compare.jpg
 
Code:
    if isInArray({config.ch1,config.ch2,config.ch3,config.ch4}, item.actionid) == TRUE and getPlayerStorageValue(cid, config.storage) ~= 1 then

should be

Code:
    if isInArray({config.ch1,config.ch2,config.ch3,config.ch4}, item.actionid) == TRUE and getPlayerStorageValue(cid, config.storage) ~= 4224 then
 
Ah, ok :) thank you BigB!
Will try it, and change the storagevalue!

<3
Edit:
What should the actions.xml look like? This is what it looks like now
<action uniqueid="4050" script="quests/towerquest.lua"/>
<action uniqueid="4051" script="quests/towerquest.lua"/>
<action uniqueid="4052" script="quests/towerquest.lua"/>
<action uniqueid="4053" script="quests/towerquest.lua"/>
 
Code:
<action actionid="4050" script="quests/towerquest.lua"/>
<action actionid="4051" script="quests/towerquest.lua"/>
<action actionid="4052" script="quests/towerquest.lua"/>
<action actionid="4053" script="quests/towerquest.lua"/>

you have it set so they need to be unique ids, not action ids xD
 
Ok, this is what i have now:

towerquest.lua
Code:
function onUse(cid, item)
    config = { storage = 42222, ch1 = 4050, ch2 = 4051, ch3 = 4052, ch4 = 4053 }
    
    if isInArray({config.ch1,config.ch2,config.ch3,config.ch4}, item.actionid) == TRUE and getPlayerStorageValue(cid, config.storage) ~= 42222 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The chest is empty.")
		return FALSE
    end
    if item.actionid == config.ch1 then
        doPlayerAddItem(cid, 8912, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Springsprout Rod.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch2 then
        doPlayerAddItem(cid, 8853, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found the Ironworker.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch3 then
        doPlayerAddItem(cid, 8920, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Wand of Starstorm.")
        setPlayerStorageValue(cid, config.storage, 1)
    elseif item.actionid == config.ch4 then
        doPlayerAddItem(cid, 2539, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Phoenix Shield.")
        setPlayerStorageValue(cid, config.storage, 1)
    end
end
Actions.xml
Code:
<action actionid="4050" script="quests/towerquest.lua"/>
<action actionid="4051" script="quests/towerquest.lua"/>
<action actionid="4052" script="quests/towerquest.lua"/>
<action actionid="4053" script="quests/towerquest.lua"/>
compare.jpg


This is what happends:
The quest is empty, and the chest is opened.

Any ideas?
 
If its still not working try this.
Excuse me if the script is a tad sloppy im not very awake
[I kept your item ids ect in there for you aswell]
Actions.xml
PHP:
<action actionid="4050" script="quests/towerquest.lua"/>
<action actionid="4051" script="quests/towerquest.lua"/>
<action actionid="4052" script="quests/towerquest.lua"/>
<action actionid="4053" script="quests/towerquest.lua"/>

towerquest.lua
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
queststatus = getPlayerStorageValue(cid,100)

    if item.actionid == 4050 then
	if queststatus == -1 then
        doPlayerAddItem(cid, 8912, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Springsprout Rod.")
        setPlayerStorageValue(cid, 100, 1)
	else
	doPlayerSendTextMessage(cid,24,"It is empty.")
	end

    elseif item.actionid == 4051 then
	if queststatus == -1 then
        doPlayerAddItem(cid, 8853, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found the Ironworker.")
        setPlayerStorageValue(cid, 100, 1)
	else
	doPlayerSendTextMessage(cid,24,"It is empty.")
	end

    elseif item.actionid == 4052 then
	if queststatus == -1 then
        doPlayerAddItem(cid, 8920, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Wand of Starstorm.")
        setPlayerStorageValue(cid, 100, 1)
	else
	doPlayerSendTextMessage(cid,24,"It is empty.")
	end
 
   elseif item.actionid == 4053 then
	if queststatus == -1 then
        doPlayerAddItem(cid, 2539, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Phoenix Shield.")
         setPlayerStorageValue(cid, 100, 1)
	else
	doPlayerSendTextMessage(cid,24,"It is empty.")
	end
    end
return TRUE
end


[EDIT]: Fixed the missing end i frogot. was sleepy =[
p.s add Unique ID's above 10,000 to the chest so they don't move if anyone uses this script.
 
Last edited:
Thank you Serp, works very well, altough you can walk on the chest.. this isn't the biggest issue but, if there is a fairly quick way to do this i'd like to :)
 
Lol just give the chests a Unique ID above 10,000. the quests.lua is set to work for
UIDs between 1k and 10k. so if you put one on the chest above 10k. it'll just
make it just un-moveable. Sorry i didn't think bout that :p like i said i'm half
asleep
 
haha kk :D

Thank you Serp and BigB for trying! you also forgot to write an END in the script, at the bottom :)
But that i could manage myself :p

Thanks again!
 
Back
Top Bottom