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

Setting premium points as reward in lottery!

beybus

New Member
Joined
Oct 2, 2010
Messages
110
Reaction score
2
Hi guys, im using this mod:

Code:
<mod name="Lottery System" version="1.5" author="vDk" contact="[email protected]" enabled="yes">
	<config name="lottery_config"><![CDATA[
		config = {
			lottery_hour = "3h", -- Time to next lottery (only for broadcast message, real time you can set on globalevents.xml)
			rewards_id = {2494, 2472, 2514, 2160}, -- Rewards ID
			crystal_counts = 10, -- Used only if on rewards_id is crystal coin (ID: 2160).
			website = "yes" -- Only if you have php scripts and table `lottery` in your database!
		}
	]]></config>
	<globalevent name="lottery" interval="10800" event="script"><![CDATA[
		domodlib('lottery_config')
	function onThink(interval, lastExecution)
	if(getWorldCreatures(0) == 0)then
		return true
	end
		local list = {}
		for i, tid in ipairs(getPlayersOnline()) do
		list[i] = tid
	end
 
		local winner = list[math.random(1, #list)]
		local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
 
	if(random_item == 2160) then
		doPlayerAddItem(winner, random_item, config.crystal_counts)
		doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .. " " .. getItemNameById(random_item) .. "s! Congratulations! (Next Lottery in " .. config.lottery_hour .. ")")
	else
		doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. getItemNameById(random_item) .. "! Congratulations! (Next Lottery in " .. config.lottery_hour .. ")")
		doPlayerAddItem(winner, random_item, 1)
	end
 
	if(config.website == "yes") then
		db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');")
	end
	return true
	end 
	]]></globalevent>
</mod>

I need to change reward from items to premium points.
Trying to use this: http://otland.net/f16/lottery-system-rewards-129276/
But didnt worked for me. Any ideas?
 
Lua:
<mod name="Lottery System" version="1.5" author="vDk" contact="[email protected]" enabled="yes">
	<config name="lottery_config"><![CDATA[
		config = {
			lottery_hour = "3h", -- Time to next lottery (only for broadcast message, real time you can set on globalevents.xml)
			points = 10, --Amount of premium_points to add ( if not random )
			rand = "yes", --Use random amount of premium_points?
			rand_points = {1, 3, 15, 9}, -- Random amount of premium_points as reward
			website = "yes" -- Only if you have php scripts and table `lottery` in your database!
		}
	]]></config>
	<globalevent name="lottery" interval="10800" event="script"><![CDATA[
		domodlib('lottery_config')
	function onThink(interval, lastExecution)
	if(getWorldCreatures(0) == 0)then
		return true
	end
		local list = {}
		for i, tid in ipairs(getPlayersOnline()) do
		list[i] = tid
	end
	local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(winner) .. ";")
	local pointz = query:getDataInt("premium_points")
		local winner = list[math.random(1, #list)]
 
 
	if(rand == "yes") then
		local random_points = config.rand_points[math.random(1, #config.rand_points)]
		db.executeQuery("UPDATE `accounts` SET `premium_points` = "..(pointz + random_points).." WHERE `id` = " .. getPlayerAccountId(winner) .. "; ")
		doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. random_points .. " Premium Points! Congratulations! (Next Lottery in " .. config.lottery_hour .. ")")
	else
		db.executeQuery("UPDATE `accounts` SET `premium_points` = "..(pointz + config.points).." WHERE `id` = " .. getPlayerAccountId(winner) .. "; ")
		doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.points .. " Premium Points! Congratulations! (Next Lottery in " .. config.lottery_hour .. ")")
	end
	
	
	if(config.website == "yes") then
		if(rand == "yes") then
			db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. random_points .." Premium Points');")
		else
			db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. config.points .." Premium Points');")
		end
	end
	return true
	end 
	]]></globalevent>
</mod>
 
Code:
[Error - GlobalEvent Interface]
buffer:onThink
Description:
[string "loadBuffer"]:10: attempt to concatenate a boolean value
stack traceback:
[string "loadBuffer"]:10: in function <[string "loadBuffer"]:2>
[Error - GlobalEvents::think] Couldn't execute event: lottery

Not working..
 
Code:
<mod name="Lottery System" version="1.5" author="vDk" contact="[email protected]" enabled="yes">
	<config name="lottery_config"><![CDATA[
		config = {
			points = {5, 10, 15},
			website = true
		}
	]]></config>
	<globalevent name="lottery" interval="10800" event="script"><![CDATA[
	domodlib('lottery_config')
	function onThink(interval)
		local t = getPlayersOnline()
		if #t == 0 then
			return true
		end

		local winner = t[math.random(#t)]
		local n = type(config.points) == 'number' and config.points or config.points[math.random(#config.points)]

		db.executeQuery("UPDATE accounts SET premium_points = ".. n .." WHERE id = " .. getPlayerAccountId(winner))
		doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. n .. " Premium Points! Congratulations! (Next Lottery in " .. interval/3600 .. " hours)")

		if config.website then
			db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES (".. db.escapeString(getCreatureName(winner)) ..", '".. n .." Premium Points')")
		end
		return true
	end
	]]></globalevent>
</mod>
 
Back
Top Bottom