• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

GlobalEvent [MOD] Chojrak's Lottery System

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Solutions
2
Reaction score
160
Code:
<mod name="Lottery System" version="1.0" author="Chojrak" contact="[email protected]" enabled="yes">
	<config name="lottery">
	<![CDATA[
		config = {
			broadcast = true,
			rewards = {
				-- Item ID[, count]
				{2160, 1},
				{2148}, -- Count = 1
				{2152, 100}
			}
		}
	]]>
	</config>
	<globalevent name="lottery" interval="10800" event="script">
	<![CDATA[
		domodlib("lottery")
		function onThink(interval, lastExecution)
			local list = getPlayersOnline()
			if (#list == 0) then
				return true
			end

			local winner = list[math.random(#list)]
			local item = config.rewards[math.random(#config.rewards)]

			doPlayerAddItem(winner, item[1], item[2] or 1)
			if (config.broadcast) then
				doBroadcastMessage(".: Lottery System :.\nWinner: ".. getCreatureName(winner) .."\nReward: ".. getItemNameById(item[1]) .."\nNext lottery in ".. interval / 60 .." minutes.")
			end
			return true
		end
	]]>
</globalevent>
</mod>

0.3.5+ :peace:
 
Last edited:
Hm, there are lots of these, but nice work! :thumbup:
 
@Beon:
I can't understand your english, sorry. ;p
 
Code:
item[2] and item[2] or 1
=
item[2] or 1
Other than that, nice !
 
Back
Top