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

Lua help with quest rewards

wishy85

GOD Smokey
Joined
May 10, 2010
Messages
150
Reaction score
3
Location
Australia
Ok im back again lol umm here is my script i got ive just made a new quest and at the end is 6 new weapon items BUT i only want a person to get 1 reward not the whole 6 ok so here is my script i done it work but the player can get all 6 rewards and not 1 so here it is

data\actions\scripts\quests

Lua:
-- hells weapons -- Made By Wishy

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

   	if item.uid == 2211 then
   		queststatus = getPlayerStorageValue(cid,2211)
   		if queststatus == -1 then
   			doPlayerSendTextMessage(cid,22,"You have found a hells rod.")
   			doPlayerAddItem(cid,7735,1)
   			setPlayerStorageValue(cid,2211,1)
   		else
   			doPlayerSendTextMessage(cid,22,"It is empty.")   		
   		end
		end
   	if item.uid == 2222 then
   		queststatus = getPlayerStorageValue(cid,2222)
   		if queststatus == -1 then
   			doPlayerSendTextMessage(cid,22,"You have found a hells wand.")
   			doPlayerAddItem(cid,7735,1)
   			setPlayerStorageValue(cid,2222,1)
   		else
   			doPlayerSendTextMessage(cid,22,"It is empty.")   		
   		end
		end
   	if item.uid == 2233 then
   		queststatus = getPlayerStorageValue(cid,2233)
   		if queststatus == -1 then
   			doPlayerSendTextMessage(cid,22,"You have found a hells club.")
   			doPlayerAddItem(cid,7735,1)
   			setPlayerStorageValue(cid,2233,1)
   		else
   			doPlayerSendTextMessage(cid,22,"It is empty.")   		
   		end
		end
   	if item.uid == 2244 then
   		queststatus = getPlayerStorageValue(cid,2244)
   		if queststatus == -1 then
   			doPlayerSendTextMessage(cid,22,"You have found a hells axe.")
   			doPlayerAddItem(cid,7735,1)
   			setPlayerStorageValue(cid,2244,1)
   		else
   			doPlayerSendTextMessage(cid,22,"It is empty.")   		
   		end
		end
   	if item.uid == 2255 then
   		queststatus = getPlayerStorageValue(cid,2255)
   		if queststatus == -1 then
   			doPlayerSendTextMessage(cid,22,"You have found a hells sword.")
   			doPlayerAddItem(cid,7735,1)
   			setPlayerStorageValue(cid,2255,1)
   		else
   			doPlayerSendTextMessage(cid,22,"It is empty.")   		
   		end
		end
   	if item.uid == 2266 then
   		queststatus = getPlayerStorageValue(cid,2266)
   		if queststatus == -1 then
   			doPlayerSendTextMessage(cid,22,"You have found a hells slingshot.")
   			doPlayerAddItem(cid,7735,1)
   			setPlayerStorageValue(cid,2266,1)
   		else
   			doPlayerSendTextMessage(cid,22,"It is empty.")   		
   		end
	else
		return 0
   	end

   	return 1
end


and in data\actions
actions.xml
Lua:
      	<action uniqueid="2211" event="script" value="quests/hells weapons.lua"/>
      	<action uniqueid="2222" event="script" value="quests/hells weapons.lua"/>
      	<action uniqueid="2233" event="script" value="quests/hells weapons.lua"/>
      	<action uniqueid="2244" event="script" value="quests/hells weapons.lua"/>
      	<action uniqueid="2255" event="script" value="quests/hells weapons.lua"/>
      	<action uniqueid="2266" event="script" value="quests/hells weapons.lua"/>

can any1 help me please ????? or wat have i done wrong?
oh with my quest if it helps lol i got a gate of expertise of lvl 250 uid == 1250 if that helps at all hehe.
Im not getting any errors at all i just want the players to get 1 reward per character ...
 
Last edited by a moderator:
can any1 help me on this one i really need it oh its also giving me the same item out of all quest chests (6 chests) plz i rlly need this hmmm unless it might be easier to make a anni script but make it so 1 player can do it
 
Last edited:
Lua:
function onUse(cid, item, frompos, item2, topos)

if item.uid == 2266 then
	if getPlayerStorageValue(cid,20018) <= 0 then
		rew = doPlayerAddItem(cid,7735,1)
		setPlayerStorageValue(cid,20018,1)
		doPlayerSendTextMessage(cid, 25, 'You have found a')
	else
		doPlayerSendTextMessage(cid, 25, 'The chest is empty.')
	end
end
if item.uid == 2255 then
	if getPlayerStorageValue(cid,20018) <= 0 then
		rew = doPlayerAddItem(cid,7735,1)
		setPlayerStorageValue(cid,20018,1)
		doPlayerSendTextMessage(cid, 25, 'You have found a')
	else
		doPlayerSendTextMessage(cid, 25, 'The chest is empty.')
	end
end
if item.uid == 2244 then
	if getPlayerStorageValue(cid,20018) <= 0 then
		rew = doPlayerAddItem(cid,7735,1)
		setPlayerStorageValue(cid,20018,1)
		doPlayerSendTextMessage(cid, 25, 'You have found a')
	else
		doPlayerSendTextMessage(cid, 25, 'The chest is empty.')
	end
end
if item.uid == 2233 then
	if getPlayerStorageValue(cid,20018) <= 0 then
		rew = doPlayerAddItem(cid,7735,1)
		setPlayerStorageValue(cid,20018,1)
		doPlayerSendTextMessage(cid, 25, 'You have found a')
	else
		doPlayerSendTextMessage(cid, 25, 'The chest is empty.')
	end
end
if item.uid == 2222 then
	if getPlayerStorageValue(cid,20018) <= 0 then
		rew = doPlayerAddItem(cid,7735,1)
		setPlayerStorageValue(cid,20018,1)
		doPlayerSendTextMessage(cid, 25, 'You have found a')
	else
		doPlayerSendTextMessage(cid, 25, 'The chest is empty.')
	end
end
if item.uid == 2211 then
	if getPlayerStorageValue(cid,20018) <= 0 then
		rew = doPlayerAddItem(cid,7735,1)
		setPlayerStorageValue(cid,20018,1)
		doPlayerSendTextMessage(cid, 25, 'You have found a')
	else
		doPlayerSendTextMessage(cid, 25, 'The chest is empty.')
	end
end
end

Try this, idk if it will work i didn't test it, i did it in 5 minutes so test it and if it works your welcome and REP me ++ please. If not then sorry, i tried.
And just edit the doPlayerSendTextMessage to say whatever you want it to say.
 
Lua:
local t = {
        [2266] = --hells slingshot ID here-- ,
        [2255] = --hells sword ID here-- ,
        [2244] = --hells axe ID here--  ,
        [2233] = -- hells club ID here-- ,
        [2222] = -- hells wand ID here-- ,
        [2211] = -- hells rod ID here-- ,
        s = 12312 
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[item.aid]
        if getPlayerStorageValue(cid, t.s) == -1 then
                doPlayerAddItem(cid, v, 1)
                doPlayerSendTextMessage(cid, 21, "You recieved"..getItemNameById(v).."!")
                setPlayerStorageValue(cid, t.s, 1)
        else
                doPlayerSendCancel(cid, "This chest is empty")
        end
return TRUE
end
 
@Bogart...
so for example [2266] = --hells slingshot ID here-- , it would be [2266] = --7735-- , (7735 is my slingshot id) like that or not cos i put the script as is how u posted it and it was just and empty chest sorry for being so noob just started gettn back into it and its change the littlest bit
 
can any1 help me its like annhi rewards but without the switch its just a room at end of normal quest (with door lvl 250) and wat i want is for the player to be able to get 1 reward only not the whole 6 rewards(quest chests)
 
@Bogart...
so for example [2266] = --hells slingshot ID here-- , it would be [2266] = --7735-- , (7735 is my slingshot id) like that or not cos i put the script as is how u posted it and it was just and empty chest sorry for being so noob just started gettn back into it and its change the littlest bit

No, just [2266] = 7735,
 
nope didnt work also wat is the s = 12312 for???? but yea i put ids in and its just a chest u click on it n it just opens :/

and got alot of errors :/ im working wif naxedot 8.6 if it helps
 
this is 1 of the errors

[09/12/2011 15:41:00] [Error - Action Interface]
[09/12/2011 15:41:00] data/actions/scripts/quests/hells weapons.lua:eek:nUse
[09/12/2011 15:41:00] Description:
[09/12/2011 15:41:00] data/lib/050-function.lua:222: attempt to index a boolean value
[09/12/2011 15:41:00] stack traceback:
[09/12/2011 15:41:00] data/lib/050-function.lua:222: in function 'getItemNameById'
[09/12/2011 15:41:00] data/actions/scripts/quests/hells weapons.lua:14: in function <data/actions/scripts/quests/hells weapons.lua:10>

its really anoyying me now :( umm if any1 can help i have a door thats infront of rewards room and its a lvl 250 door gate of expertise if there is a way we can put a action id for it so when u go through u can choose only 1 reward? maybe?
 
Lua:
local t = {
        [2266] = --hells slingshot ID here-- ,
        [2255] = --hells sword ID here-- ,
        [2244] = --hells axe ID here--  ,
        [2233] = -- hells club ID here-- ,
        [2222] = -- hells wand ID here-- ,
        [2211] = -- hells rod ID here-- ,
        s = 12312 
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[item.aid]
        if getPlayerStorageValue(cid, t.s) == -1 then
                doPlayerAddItem(cid, v, 1)
                doPlayerSendTextMessage(cid, 21, "You received your reward!")
                setPlayerStorageValue(cid, t.s, 1)
        else
                doPlayerSendCancel(cid, "This chest is empty")
        end
return TRUE
end
 
ok now i have this

[09/12/2011 15:59:13] [Error - Action Interface]
[09/12/2011 15:59:13] data/actions/scripts/quests/hells weapons.lua:eek:nUse
[09/12/2011 15:59:13] Description:
[09/12/2011 15:59:13] (luaDoPlayerAddItem) Item not found

only thing to work was this it showed up in red lolz
15:59 You received your reward!

and this is wat i have

local t = {
[2266] = 5907,
[2255] = 7959,
[2244] = 2443,
[2233] = 2444,
[2222] = 7735,
[2211] = 2184,
s = 12312
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[item.aid]
if getPlayerStorageValue(cid, t.s) == -1 then
doPlayerAddItem(cid, v, 1)
doPlayerSendTextMessage(cid, 21, "You received your reward!")
setPlayerStorageValue(cid, t.s, 1)
else
doPlayerSendCancel(cid, "This chest is empty")
end
return TRUE
end

ok so i tested wif a char and it all works properly how i want it to work but only thing its not giving me the item :/ it says i received my reward but i havent
and when i try click on other chests it says chest is empty which is how i wanted it :D jus need it to give the reward now
 
Last edited by a moderator:
yep all action ids now on quest chest through map editor and also in data\actions actions.xml

<action actionid="2211" event="script" value="quests/hells weapons.lua"/>
<action actionid="2222" event="script" value="quests/hells weapons.lua"/>
<action actionid="2233" event="script" value="quests/hells weapons.lua"/>
<action actionid="2244" event="script" value="quests/hells weapons.lua"/>
<action actionid="2255" event="script" value="quests/hells weapons.lua"/>
<action actionid="2266" event="script" value="quests/hells weapons.lua"/>
 
Lua:
local t = {
        [2266] = --hells slingshot ID here-- ,
        [2255] = --hells sword ID here-- ,
        [2244] = --hells axe ID here--  ,
        [2233] = -- hells club ID here-- ,
        [2222] = -- hells wand ID here-- ,
        [2211] = -- hells rod ID here-- ,
        s = 12312 
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[getItemAttribute(item, 'aid')]
        if getPlayerStorageValue(cid, t.s) == -1 then
                doPlayerAddItem(cid, v, 1)
                doPlayerSendTextMessage(cid, 21, "You received your reward!")
                setPlayerStorageValue(cid, t.s, 1)
        else
                doPlayerSendCancel(cid, "This chest is empty")
        end
return TRUE
end
 
still errors :/

[09/12/2011 16:25:02] [Error - LuaScriptInterface::loadFile] data/actions/scripts/quests/hells weapons.lua:19: 'end' expected (to close 'function' at line 10) near '<eof>'
[09/12/2011 16:25:02] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/quests/hells weapons.lua)
 
still errors :/

[09/12/2011 16:25:02] [Error - LuaScriptInterface::loadFile] data/actions/scripts/quests/hells weapons.lua:19: 'end' expected (to close 'function' at line 10) near '<eof>'
[09/12/2011 16:25:02] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/quests/hells weapons.lua)

You failed at copying it.
add an end or copy again.
 
[09/12/2011 16:38:46] [Error - Action Interface]
[09/12/2011 16:38:46] data/actions/scripts/quests/hells weapons.lua:eek:nUse
[09/12/2011 16:38:46] Description:
[09/12/2011 16:38:46] (luaGetItemAttribute) Item not found


thats with the end on the end of script
 
Back
Top