• 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] Script Help :D

Zarabustor

Human Being
Joined
Sep 10, 2009
Messages
186
Reaction score
0
Location
Cancun, Mexico
Code:
local ITEMS = {7417, 7423, 8924, 7865, 7880, 11296, 11295, 6433,2316, 11298, 11297,5809, 9653, 8907, 8866, 7730, 7892, 9662, 2196, 8304,2275,2300,11257,5785,2663,8854,7365}
local GOOD_ITEMS = {2663,8866,8907,7730,7892,2196,2275,9653,2316,2300,8303,5809}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local rand = math.random(1, #ITEMS)
	if isInArray(GOOD_ITEMS, ITEMS[rand]) then
		doBroadcastMessage(getCreatureName(cid) .. " is very lucky to win " .. getItemInfo(ITEMS[rand]).article .. " " .. getItemInfo(ITEMS[rand]).name .. " from lottery bird.", MESSAGE_EVENT_ADVANCE)
	end
	doPlayerAddItem(cid, ITEMS[rand], rand == 1 and 10 or rand == 2 and 3 or 1)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid)
	return true
end

Hello! Greetings .. hi i need help with this script... i want that the GOOD ITEM have less chance than the others, so i mean that the good items will be hard to get.
 
LUA:
local ITEMS = {7417, 7423, 8924, 7865, 7880, 11296, 11295, 6433,2316, 11298, 11297,5809, 9653, 8907, 8866, 7730, 7892, 9662, 2196, 8304,2275,2300,11257,5785,2663,8854,7365}
local GOOD_ITEMS = {2663,8866,8907,7730,7892,2196,2275,9653,2316,2300,8303,5809}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	addEvent(lottery, 1, params)
	return true
end

function awardGoodItem(params)
	doBroadcastMessage(getCreatureName(cid) .. " is very lucky to win " .. getItemInfo(ITEMS[rand]).article .. " " .. getItemInfo(ITEMS[rand]).name .. " from lottery bird.", MESSAGE_EVENT_ADVANCE)		
	doPlayerAddItem(cid, ITEMS[rand], rand == 1 and 10 or rand == 2 and 3 or 1)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid)
end

function awardNormalItem(params)
	doPlayerAddItem(cid, ITEMS[rand], rand == 1 and 10 or rand == 2 and 3 or 1)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid)
end

function lottery(params)
	local rand = math.random(1, #ITEMS)
	
	if isInArray(GOOD_ITEMS, ITEMS[rand]) then
		if math.random(1, 5) == 5 then
			addEvent(awardGoodItem, 1, params)
		else
			addEvent(lottery, 1, params)
		end
	else
		addEvent(awardNormalItem, 1, params)
		doPlayerAddItem(cid, ITEMS[rand], rand == 1 and 10 or rand == 2 and 3 or 1)
	end
end
 
LUA:
local ITEMS = {7417, 7423, 8924, 7865, 7880, 11296, 11295, 6433,2316, 11298, 11297,5809, 9653, 8907, 8866, 7730, 7892, 9662, 2196, 8304,2275,2300,11257,5785,2663,8854,7365}
local GOOD_ITEMS = {2663,8866,8907,7730,7892,2196,2275,9653,2316,2300,8303,5809}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	addEvent(lottery, 1, params)
	return true
end

function awardGoodItem(params)
	doBroadcastMessage(getCreatureName(cid) .. " is very lucky to win " .. getItemInfo(ITEMS[rand]).article .. " " .. getItemInfo(ITEMS[rand]).name .. " from lottery bird.", MESSAGE_EVENT_ADVANCE)		
	doPlayerAddItem(cid, ITEMS[rand], rand == 1 and 10 or rand == 2 and 3 or 1)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid)
end

function awardNormalItem(params)
	doPlayerAddItem(cid, ITEMS[rand], rand == 1 and 10 or rand == 2 and 3 or 1)
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid)
end

function lottery(params)
	local rand = math.random(1, #ITEMS)
	
	if isInArray(GOOD_ITEMS, ITEMS[rand]) then
		if math.random(1, 5) == 5 then
			addEvent(awardGoodItem, 1, params)
		else
			addEvent(lottery, 1, params)
		end
	else
		addEvent(awardNormalItem, 1, params)
		doPlayerAddItem(cid, ITEMS[rand], rand == 1 and 10 or rand == 2 and 3 or 1)
	end
end

[28/04/2010 15:05:50] [Error - Action Interface]
[28/04/2010 15:05:50] In a timer event called from:
[28/04/2010 15:05:50] data/actions/scripts/andres/lottery.lua:onUse
[28/04/2010 15:05:50] Description:
[28/04/2010 15:05:50] attempt to index a nil value
[28/04/2010 15:05:50] stack traceback:
[28/04/2010 15:05:50] [C]: in function 'doSendMagicEffect'
[28/04/2010 15:05:50] data/actions/scripts/andres/lottery.lua:18: in function <data/actions/scripts/andres/lottery.lua:16>

Appears that :P Thnx
 
Back
Top