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++.
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: