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

[GlobalEvent] Top 5 lvl free VIP

zemiex

New Member
Joined
Mar 27, 2012
Messages
11
Reaction score
2
Hello,

This script gives, weekly (can be set in globalevents.xml and in config) that is, the top 5 players with the higest level on your server free vip time for 4 days (can also be set in config). Players online will recieve a message.

Script can be shorter with loops etc, I know.

Hope u like it. Dont forget to rep++.

Code:
-- CONFIG --
local vipdays = 4
local dayexecute = "Sunday"
local message  = "Free VIP has been added, because your a top 5 player on Phyxia! Please do relog to active."

function onTime()
	if (os.date('%A') == dayexecute) then
		--rank1
		local a = db.getResult("SELECT `account_id`, `name` FROM `players` WHERE `group_id` < 4 ORDER BY `experience` DESC LIMIT 1;")
		local result1 = a:getDataString("account_id")
		local naam1 = a:getDataString("name")
		--rank2
		local b = db.getResult("SELECT `account_id`, `name` FROM `players` WHERE `group_id` < 4 AND `account_id` != '" .. result1 .. "' ORDER BY `experience` DESC LIMIT 1;")
		local result2 = b:getDataString("account_id")
		local naam2 = b:getDataString("name")
		--rank3
		local c = db.getResult("SELECT `account_id`, `name` FROM `players` WHERE `group_id` < 4 AND `account_id` != '" .. result1 .. "' AND `account_id` != '" .. result2 .. "' ORDER BY `experience` DESC LIMIT 1;")
		local result3 = c:getDataString("account_id")
		local naam3 = c:getDataString("name")
		--rank4
		local d = db.getResult("SELECT `account_id`, `name` FROM `players` WHERE `group_id` < 4 AND `account_id` != '" .. result1 .. "' AND `account_id` != '" .. result2 .. "' AND `account_id` != '" .. result3 .. "' ORDER BY `experience` DESC LIMIT 1;")
		local result4 = d:getDataString("account_id")
		local naam4 = d:getDataString("name")
		--rank5
		local e = db.getResult("SELECT `account_id`, `name` FROM `players` WHERE `group_id` < 4 AND `account_id` != '" .. result1 .. "' AND `account_id` != '" .. result2 .. "' AND `account_id` != '" .. result3 .. "' AND `account_id` != '" .. result4 .. "' ORDER BY `experience` DESC LIMIT 1;")
		local result5 = e:getDataString("account_id")
		local naam5 = e:getDataString("name")
		
		-- query for vip days
		db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + vipdays WHERE `id` = '" .. result1 .. "' OR `id` = '" .. result2 .. "' OR `id` = '" .. result3 .. "' OR `id` = '" .. result4 .. "' OR `id` = '" .. result5 .. "';")
		
		-- shows message to ONLINE players
		if(isPlayer(getCreatureByName(naam1))) then
			doPlayerSendTextMessage(getCreatureByName(naam1), MESSAGE_EVENT_ORANGE, message)
                        a:free()
		end
		if(isPlayer(getCreatureByName(naam2))) then
			doPlayerSendTextMessage(getCreatureByName(naam2), MESSAGE_EVENT_ORANGE, message)
                        b:free()
		end
		if(isPlayer(getCreatureByName(naam3))) then
			doPlayerSendTextMessage(getCreatureByName(naam3), MESSAGE_EVENT_ORANGE, message)
                        c:free()
		end
		if(isPlayer(getCreatureByName(naam4))) then
			doPlayerSendTextMessage(getCreatureByName(naam4), MESSAGE_EVENT_ORANGE, message)
                        d:free()
		end
		if(isPlayer(getCreatureByName(naam5))) then
			doPlayerSendTextMessage(getCreatureByName(naam5), MESSAGE_EVENT_ORANGE, message)
                        e:free()
		end
		return TRUE
	end
end
 
Last edited:
i might use this since my server will be donation free, thanks for the contribution!
 
I think this won't work as you planned, if the top 5 ppl get more exp.. they will stay the top 5 because exping is easies for them... so it's kinda unfair for the rest ? -sorry for bad english
 
Back
Top