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

Surprisebag, what's wrong?

Exiled Pain

Fervid Learner
Joined
Jan 8, 2008
Messages
552
Reaction score
4
Sup everyone.
I'm trying to use surprise bags but I'm getting some errors.
I'm using TFS .3preAlpha latest REV but I'm getting this error:

[19/06/2008 11:08:44] data/actions/scripts/other/surprisebag.lua:18: attempt to index global 'randomPresent' (a nil value)
[19/06/2008 11:08:44] stack traceback:
[19/06/2008 11:08:44] data/actions/scripts/other/surprisebag.lua:18: in function <data/actions/scripts/other/surprisebag.lua:1>



In the surpricebag.lua I got:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local count = 1
	if item.itemid == 6570 then
		local randomPresent = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}
		local randomChance = math.random(1, 11)
		if randomChance == 1 then
			count = 10
		elseif randomChance == 2 then
			count = 3
		end
	elseif item.itemid == 6571 then
		local randomPresent = {2152, 2152, 2152, 2153, 5944, 2112, 6568, 6566, 2492, 2520, 2195, 2114, 2114, 2114, 6394, 6394, 6576, 6576, 6578, 6578, 6574, 6574}
		local randomChance = math.random(1, 22)
		if randomChance > 0 and randomChance < 4 then
			count = 10
		end
	end
	doPlayerAddItem(cid, randomPresent[randomChance], count)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid, 1)
	return TRUE
end

Thanks in advance
 
Last edited:
try this

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local count = 1
	if item.itemid == 6570 then
		local randomPresent = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}
		local randomChance = math.random(1, 11)
		if randomChance == 1 then
			count = 10
		elseif randomChance == 2 then
			count = 3
	elseif item.itemid == 6571 then
		local randomPresent = {2152, 2152, 2152, 2153, 5944, 2112, 6568, 6566, 2492, 2520, 2195, 2114, 2114, 2114, 6394, 6394, 6576, 6576, 6578, 6578, 6574, 6574}
		local randomChance = math.random(1, 22)
		if randomChance > 0 and randomChance < 4 then
			count = 10
		end
	end
	doPlayerAddItem(cid, randomPresent[randomChance], count)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid, 1)
	return FALSE
	end
	return TRUE
end
 
Thanks.
Ok now the blue surpricebag is working, but the red one still not working.. and not getting any error messages.

^_^
 
hmm try this
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local count = 1
	if item.itemid == 6570 then
		local randomPresent = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}
		local randomChance = math.random(1, 11)
		if randomChance == 1 then
			count = 10
		elseif randomChance == 2 then
			count = 3
	elseif item.itemid == 6571 then
		local randomPresent = {2152, 2152, 2152, 2153, 5944, 2112, 6568, 6566, 2492, 2520, 2195, 2114, 2114, 2114, 6394, 6394, 6576, 6576, 6578, 6578, 6574, 6574}
		local randomChance = math.random(1, 22)
		if randomChance > 0 and randomChance < 4 then
			count = 10
		end
	doPlayerAddItem(cid, randomPresent[randomChance], count)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid, 1)
	 end
	return FALSE
   end
  return TRUE
end
 
The second code not giving errors but nothing happening...
So I put the first code to open the blue gifts and found this one that seems to be working with the red one.

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

if math.random(0,10) == 0 and item.itemid == 6571 then
doTransformItem(item.uid,6388)
elseif math.random(0,10) == 1 and item.itemid == 6571 then
doTransformItem(item.uid,6527)
elseif math.random(0,10) == 2 and item.itemid == 6571 then
doTransformItem(item.uid,6512)
elseif math.random(0,10) == 3 and item.itemid == 6571 then
doTransformItem(item.uid,6531)
elseif math.random(0,10) == 4 and item.itemid == 6571 then
doTransformItem(item.uid,6567)
elseif math.random(0,10) == 5 and item.itemid == 6571 then
doTransformItem(item.uid,4850)
elseif math.random(0,10) == 6 and item.itemid == 6571 then
doTransformItem(item.uid,5808)
elseif math.random(0,10) == 7 and item.itemid == 6571 then
doTransformItem(item.uid,5803)
elseif math.random(0,10) == 8 and item.itemid == 6571 then
doTransformItem(item.uid,5801)
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,6569,3)
else
return 0
end
return 1
end
 
Back
Top