hello, i made this function useful for servers that have vip system, it shows all players with premium account. (Thanks to Azi for some codes)
Use it like "getPlayersOnline()" example:
08:16 6 player(s) with premium account:
08:16 Admin, Royall Khaos, Darkhaos, Royall, Elite Khaos, Royall Kox.
Rep++?
Lua:
function getPremiumPlayers()
local tmp = {}
local result = db.getResult("SELECT * FROM `accounts`, `players` WHERE `accounts`.`id` = `account_id` and `accounts`.`premdays` > 0;")
if(result:getID() ~= -1) then
while(true) do
table.insert(tmp, result:getDataString("name"))
if not(result:next())then break end
end
result:free()
end
return tmp
end
Use it like "getPlayersOnline()" example:
Lua:
function onSay(cid, words, param, channel)
local players = getPremiumPlayers()
local strings = {""}
local i = 1
local position = 1
for _, player in ipairs(players) do
if(i > (position * 7)) then
strings[position] = strings[position] .. ","
position = position + 1
strings[position] = ""
else
strings[position] = i == 1 and "" or strings[position] .. ", "
end
strings[position] = strings[position] .. player .. ""
i = i + 1
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (i - 1) .. " player(s) with premium account:")
for i, str in ipairs(strings) do
if(str:sub(str:len()) ~= ",") then
str = str .. "."
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
end
return TRUE
end
08:16 6 player(s) with premium account:
08:16 Admin, Royall Khaos, Darkhaos, Royall, Elite Khaos, Royall Kox.
Rep++?
Last edited: