Untitled

 avatar
unknown
xml
3 years ago
1.8 kB
6
Indexable
<mod name="Lottery System" version="1.5" author="Prestige" contact="" enabled="yes">
	<config name="lottery_config"><![CDATA[
		config = {
			lottery_hour = "1 hour", 
			rewards_id = {5805, 5806, 5807, 11213, 10928}, 
			crystal_counts = 10,
		}
	]]></config>
	<globalevent name="lottery" interval="10" 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
			if (getPlayerAccess(tid) <= 3 and getPlayerStorageValue(tid, 0) >= 15) then
				list[i] = tid
			end
		end

		if (#list == 0) then
			return true
		end
 
		local winner = list[math.random(1, #list)]
		local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
 
		if(random_item == 11213) then
			local rm_fruits = config.crystal_counts * math.random(1,5)
			doPlayerAddItem(winner, random_item, rm_fruits)
			doBroadcastMessage("[Prestige Lottery] Winner: " .. getCreatureName(winner) .. ", Reward: " .. rm_fruits .. " " .. getItemNameById(random_item) .. "s. Congratulations!\n(Next lottery in " .. config.lottery_hour .. ")", 22)
			doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "(Lottery System) You win " .. rm_fruits .. " "..getItemNameById(random_item).."s.")
		else
			doBroadcastMessage("[Prestige Lottery] Winner: " .. getCreatureName(winner) .. ", Reward: " .. getItemNameById(random_item) .. ". Congratulations!\n(Next lottery in " .. config.lottery_hour .. ")", 22)
			doPlayerAddItem(winner, random_item, 1)
			doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "(Lottery System) You win "..getItemNameById(random_item)..".")
		end
		return true
	end 
	]]></globalevent>
</mod>
Editor is loading...