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

TalkAction The Numeric Lottery!

[18/09/2009 05:18:29] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/lotto/drawLots.lua)
[18/09/2009 05:18:29] data/talkactions/scripts/lotto/drawLots.lua:1: '<eof>' expected near 'end'
[18/09/2009 05:18:29] Reloaded talk actions.


any idea? pls help i need it for my funserver
 
when i used !ticked i got these errors
PHP:
[30/03/2010 17:13:15] Lua Script Error: [TalkAction Interface] 
[30/03/2010 17:13:15] data/talkactions/scripts/lotto/ticket.lua:onSay

[30/03/2010 17:13:15] data/talkactions/scripts/lotto/ticket.lua:15: attempt to get length of local 'nbrs' (a nil value)
[30/03/2010 17:13:15] stack traceback:
[30/03/2010 17:13:15] 	data/talkactions/scripts/lotto/ticket.lua:15: in function <data/talkactions/scripts/lotto/ticket.lua:8>


When i use !result i got this error
PHP:
[30/03/2010 17:13:34] Lua Script Error: [TalkAction Interface] 
[30/03/2010 17:13:34] data/talkactions/scripts/lotto/result.lua:onSay

[30/03/2010 17:13:34] data/lib/database.lua:76: [Result:getDataString] Result not set!
[30/03/2010 17:13:34] stack traceback:
[30/03/2010 17:13:34] 	[C]: in function 'error'
[30/03/2010 17:13:34] 	data/lib/database.lua:76: in function 'getDataString'
[30/03/2010 17:13:34] 	data/talkactions/scripts/lotto/result.lua:7: in function <data/talkactions/scripts/lotto/result.lua:1>


Please help! ^^
 
i got error

[17/10/2011 09:07:28] [Error - TalkAction Interface]
[17/10/2011 09:07:28] data/talkactions/scripts/lotto/ticket.lua:eek:nSay
[17/10/2011 09:07:28] Description:
[17/10/2011 09:07:28] data/talkactions/scripts/lotto/ticket.lua:13: attempt to compare nil with number
[17/10/2011 09:07:28] stack traceback:
[17/10/2011 09:07:28] data/talkactions/scripts/lotto/ticket.lua:13: in function <data/talkactions/scripts/lotto/ticket.lua:8>

help?
 
I really like this idea. I'm fixing part of the script. Who can help or have ideas, thank you.

Ticked.lua tested in 0.4
PHP:
local config = {
	numberOfNumbers = 6, -- how many numbers you can type
	numbers = {1,20}, -- the range is to be type numbers
	cost = 15000, -- ticket cost
	level = 50,
}
function onSay(cid, words, param, channel)
	local types = {}
	local err=0
	local typ = ""
	local nbrs = string.explode(param, ",") 
	if (getPlayerLevel(cid) >= config.level) then
		if(getPlayerMoney(cid) >= config.cost)then
			if(#nbrs >= config.numberOfNumbers)then
				for i=1, config.numberOfNumbers do
					if(tonumber(nbrs[i]) >= config.numbers[1] and tonumber(nbrs[i]) <= config.numbers[2] and err ~= 4)then
						if(isInArray(types, tonumber(nbrs[i])) == TRUE)then
							err = 5
						elseif(err ~= 5)then
							table.insert(types, tonumber(nbrs[i]))
							err = 0
						end
					else
						doPlayerSendTextMessage(cid, 19, "The rage of type numbers must be "..config.numbers[1].." between "..config.numbers[2]..".")
					end
				end
			else
				doPlayerSendTextMessage(cid, 19, "You need to type "..config.numberOfNumbers.." numbers (!ticked x,x,x,x,x,x).")
			end
		else
			doPlayerSendTextMessage(cid, 19, "You need pay "..config.cost.." gp to play.")
		end
	else
		doPlayerSendTextMessage(cid, 19, "You need "..config["level"].." level to play.")
	end
	
	if(err == 0)then
		for i = 1,(config.numberOfNumbers)-1 do
			typ = typ..""..types[i]..","
		end
		typ = typ..""..types[config.numberOfNumbers]
		doPlayerRemoveMoney(cid, config.cost)
		local itemname = "letter"
		local letter = doPlayerAddItem(cid, getItemIdByName(itemname), 1)
		doSetItemText(letter, "You sent ticket for lotto!\n Your typed numbers: "..typ)
		
		doPlayerSendTextMessage(cid, 19, "Ticked Sent! Cost: "..config.cost.." gp.\nNumber Types: "..typ..".")
		db.query("INSERT INTO `lotto_fate` (`player_id`, `time`, `numbers`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", '"..typ.."');")
	end
	
	return TRUE
end

drawLots.lua tested in 0.4
PHP:
local config = {
	numberOfNumbers = 6, -- how many numbers you can type
	numbers = {1,20}, -- the range is to be type numbers
	cost = 1500
}	

function drawLots(config)
	numbers = {}
		for a=-5, config.numberOfNumbers do
		 rand = math.random(config.numbers[1],config.numbers[2])
			for x=1,50 do
				if(isInArray(numbers, rand) == FALSE)then
					table.insert(numbers, rand)
				x=10
				end
			end
		end
	return numbers
end

function onSay(cid, words, param, channel)
	local numbers = drawLots(config)
	local lot = ""
	for i=1,(config.numberOfNumbers)-1 do
		lot = lot..""..numbers[i]..","
	end
		lot = lot..""..numbers[config.numberOfNumbers]
		db.query("DELETE FROM `lotto_fate` WHERE `time` <= (SELECT `time` FROM `lotto_result` ORDER BY `time` DESC LIMIT 1);")
		db.query("DELETE FROM `lotto_result`;")
		local rows = db.getResult("SELECT `player_id` FROM `lotto_fate`;")
		if(rows:getID() ~= -1) then
			local rate = ((rows:numRows(true)*config.cost)*2)
			db.query("INSERT INTO `lotto_result` (`time`, `numbers`, `rate`) VALUES (" .. os.time() .. ", '"..lot.."', "..rate..");")
			doBroadcastMessage("The Draw lot of our lottery!!\nWinning Numbers: "..lot..".\n Price is "..rate.." gp!\nCongratulations to the winners!", MESSAGE_STATUS_WARNING)
		else
		doPlayerSendCancel(cid, "Anybody sent ticket.")
	end
	
	return TRUE
end

result.lua ERROR in 0.4
PHP:
function onSay(cid, words, param)
	local fate = db.getResult("SELECT `numbers` FROM `lotto_fate` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
	local result = db.getResult("SELECT `rate`,`numbers` FROM `lotto_result` ;")
	local numbers = {}
	local results = {}
	local win = 0
	results = string.explode(result:getDataString("numbers"), ",")
	local traf = 0
	if(fate:getID() ~= -1) then
		while(true) do
			numbers = string.explode(fate:getDataString("numbers"), ",")
				traf=0
				for i=1, #numbers do
					if(isInArray(results, numbers[i]) == TRUE)then
						traf=traf+1
					end
					if(traf == 6)then
						win = 1
					end
				end
			if not(fate:next()) or win==1 then
				break
			end
		end
		fate:free()
		if(win == 0)then
			doPlayerSendTextMessage(cid, 19, "You lose!")
		else
			doPlayerPopupFYI(cid, "Congratulations, You win "..result:getDataInt("rate").." gp!")
			doPlayerAddMoney(cid, result:getDataInt("rate"))
			db.query("DELETE FROM `lotto_fate` WHERE `player_id`=".. getPlayerGUID(cid) ..";")
		end
	else
		doPlayerSendCancel(cid, "You don\'t send a tickets or take the prize earlier")
	end
	return TRUE
end

ERROR:
PHP:
[21:59:57.168] [Error - TalkAction Interface]
[21:59:57.169] data/talkactions/scripts/result.lua:onSay
[21:59:57.169] Description:
[21:59:57.170] data/lib/004-database.lua:76: [Result:getDataString] Result not s
et!
[21:59:57.170] stack traceback:
[21:59:57.170]  [C]: in function 'error'
[21:59:57.170]  data/lib/004-database.lua:76: in function 'getDataString'
[21:59:57.171]  data/talkactions/scripts/result.lua:7: in function <data/tal
kactions/scripts/result.lua:1>


I can't fix that.
 
Last edited:
Back
Top