• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Arena

Status
Not open for further replies.

Demonkil

Beginner Mapper
Joined
Dec 21, 2007
Messages
468
Reaction score
13
Well i have got the arena working fine but i have one problem, when you goto the reward room you can take the items as many times as you want. any1 know the problem
 
Your script fails to either read or write a storage value on the character, thus the character is never marked as "have recieved reward" and can thus take as many items as he or she pleases.
 
Here is my reward script

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.actionid >= 42361 and item.actionid <= 42365 and getPlayerStorageValue(cid, 42361) ~= 1 then
		local reward = 0
		if item.actionid == 42361 then
			reward = doCreateItemEx(1990,1)
			doAddContainerItem(reward, 7372, 1)
			doAddContainerItem(reward, 6569, 10)
			doAddContainerItem(reward, 6574, 1)
			doAddContainerItem(reward, 2114, 1)
		elseif item.actionid == 42362 then
			reward = doCreateItemEx(7406,1)
		elseif item.actionid == 42363 then
			reward = doCreateItemEx(7380,1)
		elseif item.actionid == 42364 then
			reward = doCreateItemEx(7392,1)
		elseif item.actionid == 42365 then
			reward = doCreateItemEx(7342,1)
			doAddContainerItem(reward, 7365, 100)
			doAddContainerItem(reward, 7364, 100)
		end
		local additem = doPlayerAddItemEx(cid, reward, 0)
		if additem == RETURNVALUE_NOERROR then
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'You have chosen a ' .. getItemName(getThing(reward).itemid) .. '.')
			setPlayerStorageValue(cid, 42361, 1)
		else
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Not enough capacity.')
		end
		
			elseif item.actionid >= 42361 and item.actionid <= 42365 and getPlayerStorageValue(cid, 42361) == 1 then
							doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'You have already claimed your reward.')
			elseif item.actionid >= 42371 and item.actionid <= 42375 and getPlayerStorageValue(cid, 42371) == 1 then
							doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'You have already claimed your reward.')
			elseif item.actionid >= 42381 and item.actionid <= 42385 and getPlayerStorageValue(cid, 42381) == 1 then
							doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'You have already claimed your reward.')
	elseif item.actionid >= 42371 and item.actionid <= 42375 and getPlayerStorageValue(cid, 42371) ~= 1 then
		local reward = 0
		if item.actionid == 42371 then
			reward = doCreateItemEx(1990,1)
			doAddContainerItem(reward, 7372, 1)
			doAddContainerItem(reward, 6569, 10)
			doAddContainerItem(reward, 6574, 1)
			doAddContainerItem(reward, 7183, 1)
		elseif item.actionid == 42372 then
			reward = doCreateItemEx(7384,1)
		elseif item.actionid == 42373 then
			reward = doCreateItemEx(7389,1)
		elseif item.actionid == 42374 then
			reward = doCreateItemEx(7415,1)
		elseif item.actionid == 42375 then
			reward = doCreateItemEx(7342,1)
			doAddContainerItem(reward, 7365, 100)
			doAddContainerItem(reward, 2547, 100)
			doAddContainerItem(reward, 2547, 100)
			doAddContainerItem(reward, 2311, 50)
			doAddContainerItem(reward, 2304, 50)
					end
					
		local additem = doPlayerAddItemEx(cid, reward, 0)
		if additem == RETURNVALUE_NOERROR then
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'You have found a ' .. getItemName(getThing(reward).itemid) .. '.')
			setPlayerStorageValue(cid, 42371, 1)
		else
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Not enough capacity.')
		end
	elseif item.actionid >= 42381 and item.actionid <= 42385 and getPlayerStorageValue(cid, 42381) ~= 1 then
		local reward = 0
		if item.actionid == 42381 then
			reward = doCreateItemEx(1990,1)
			doAddContainerItem(reward, 7372, 1)
			doAddContainerItem(reward, 6569, 10)
			doAddContainerItem(reward, 6574, 1)
			doAddContainerItem(reward, 6568, 1)
		elseif item.actionid == 42382 then
			reward = doCreateItemEx(7429,1)
		elseif item.actionid == 42383 then
			reward = doCreateItemEx(7434,1)
		elseif item.actionid == 42384 then
			reward = doCreateItemEx(7390,1)
		elseif item.actionid == 42385 then
			reward = doCreateItemEx(7342,1)
			doAddContainerItem(reward, 2273, 50)
			doAddContainerItem(reward, 2268, 50)
			doAddContainerItem(reward, 7443, 1)
			doAddContainerItem(reward, 7440, 1)
			doAddContainerItem(reward, 6529, 100)
		end
		local additem = doPlayerAddItemEx(cid, reward, 0)
		if additem == RETURNVALUE_NOERROR then
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'You have found a ' .. getItemName(getThing(reward).itemid) .. '.')
			setPlayerStorageValue(cid, 42381, 1)
		else
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'Not enough capacity.')
		end
	end
	return TRUE
end
 
Well i get this error in my console when i use the chest

Code:
[05/12/2009 03:56:56] Lua Script Error: [Action Interface] 
[05/12/2009 03:56:56] data/actions/scripts/quests/arenareward.lua:onUse

[05/12/2009 03:56:56] luaGetItemDescriptions(). Item not found

[05/12/2009 03:56:56] Lua Script Error: [Action Interface] 
[05/12/2009 03:56:56] data/actions/scripts/quests/arenareward.lua:onUse

[05/12/2009 03:56:56] data/lib/function.lua:234: attempt to index a boolean value
[05/12/2009 03:56:56] stack traceback:
[05/12/2009 03:56:56] 	data/lib/function.lua:234: in function 'getItemName'
[05/12/2009 03:56:56] 	data/actions/scripts/quests/arenareward.lua:23: in function <data/actions/scripts/quests/arenareward.lua:1>

[05/12/2009 03:56:58] Lua Script Error: [Action Interface] 
[05/12/2009 03:56:58] data/actions/scripts/quests/arenareward.lua:onUse

[05/12/2009 03:56:58] luaGetItemDescriptions(). Item not found

[05/12/2009 03:56:58] Lua Script Error: [Action Interface] 
[05/12/2009 03:56:58] data/actions/scripts/quests/arenareward.lua:onUse

[05/12/2009 03:56:58] data/lib/function.lua:234: attempt to index a boolean value
[05/12/2009 03:56:58] stack traceback:
[05/12/2009 03:56:58] 	data/lib/function.lua:234: in function 'getItemName'
[05/12/2009 03:56:58] 	data/actions/scripts/quests/arenareward.lua:23: in function <data/actions/scripts/quests/arenareward.lua:1>

[05/12/2009 03:56:58] Lua Script Error: [Action Interface] 
[05/12/2009 03:56:58] data/actions/scripts/quests/arenareward.lua:onUse

[05/12/2009 03:56:58] luaGetItemDescriptions(). Item not found

[05/12/2009 03:56:58] Lua Script Error: [Action Interface] 
[05/12/2009 03:56:58] data/actions/scripts/quests/arenareward.lua:onUse

[05/12/2009 03:56:58] data/lib/function.lua:234: attempt to index a boolean value
[05/12/2009 03:56:58] stack traceback:
[05/12/2009 03:56:58] 	data/lib/function.lua:234: in function 'getItemName'
[05/12/2009 03:56:58] 	data/actions/scripts/quests/arenareward.lua:23: in function <data/actions/scripts/quests/arenareward.lua:1>
 
42361 - 42385

You put this in the actions.xml ?
Code:
<action uniqueid="42361-42385" event="script" value="pvparena.lua" />

Like that ? If yes, I think you should
do this
<action uniqueid="42361-42362" event="script" value="pvparena.lua" />

It's just a suggestion, I don't know it 100%.
 
Status
Not open for further replies.
Back
Top