• 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 Problem with simple script

Killzon32

There killing our dudes.
Joined
Aug 11, 2010
Messages
235
Reaction score
8
Location
mount olympus
PHP:
local PRESENT_LARGEBOX = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}

function onUse(cid, item, fromPosition, itemEx, toPosition)

	local count = 1
	if(item.itemid == 10503) then
		local randomChance = math.random(1, 6 == 1) then
		doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
		doRemoveItem(item.uid, 1)
		
	else
	
	doSendMagicEffect(fromPosition, CONST_ME_POFF)
	doPlayerAddItem(cid, PRESENT_LARGEBOX[randomChance], count)

	return true
	end
end

I am not good at scripting trying to make a script but its giving me a unexpected symbol near 'then'
 
Lua:
local PRESENT_LARGEBOX = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}
local count = 1
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 10503) then
	local randomChance = math.random(1, 6)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid, 1)
else
    doSendMagicEffect(fromPosition, CONST_ME_POFF)
    doPlayerAddItem(cid, PRESENT_LARGEBOX[randomChance], count)
end
return true
end
 
I don't know whats wrong with it but now the script does not give me anything ;P
I just want it to have it give me a random item out of the list then have the chance to break:(
like 1-6 chance to break rest of the time it gives a random item.
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local PRESENT_LARGEBOX = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}
local count = 1
local randomChance = math.random(1, 10)
if(item.itemid == 10503) then
	if randomChance < 6 then
		doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
		doRemoveItem(item.uid, 1)
	else
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerAddItem(cid, PRESENT_LARGEBOX[randomChance], count)
	end
end
return true
end
change 10 to higher number to higher the break chance
 
Last edited:
I did and tested it even if its <1 it still go's away after use and gives item It poof's and go's away every single time u click on it there is no 20% chance of it breaking.

- - - Updated - - -

I fixed the script
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local PRESENT_LARGEBOX = {2687, 6394, 6280, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2114}
local count = 1
local randomChance = math.random(1, 10)
if(item.itemid == 10503) then
	if randomChance < 9 then
		doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
		doPlayerAddItem(cid, PRESENT_LARGEBOX[randomChance], count)
	else
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doRemoveItem(item.uid, 1)
		end

	end
	
return true
end
 
Last edited:
Back
Top