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

[getPremiumPlayers()]

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
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)

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:
Yyy, is this is called function? It does nothing, just wasting resources, as it just simply adds query results to table, sorry but, its lame and have no sense. You can create same way 243345 other functions, which obviously will just select few fields from database and insert them to table.

Also, not "SELECT *" but "SELECT `players`.`name`" because you only need this field.
 
Yyy, is this is called function? It does nothing, just wasting resources, as it just simply adds query results to table, sorry but, its lame and have no sense. You can create same way 243345 other functions, which obviously will just select few fields from database and insert them to table.

Also, not "SELECT *" but "SELECT `players`.`name`" because you only need this field.

I'm pretty sure you have no idea what is going on.
Nice job Khaos
 
Yyy, is this is called function? It does nothing, just wasting resources, as it just simply adds query results to table, sorry but, its lame and have no sense. You can create same way 243345 other functions, which obviously will just select few fields from database and insert them to table.

Also, not "SELECT *" but "SELECT `players`.`name`" because you only need this field.

Thanks i love you too
 
argh.. sorry, I was to nervous yesterday ;/

But still you could use "`players`.`name`" instead "*" because its faster :thumbup:
 
name of each player must be in new line :p^_^ or group them.
 
SeeAllVips
Lua:
<talkaction words="/vipsall" access="5" script="SeeAllVips.lua"/>
SeeAllVips
Lua:
function getAllVips()
	local tmp = {}
	local result = db.getResult("SELECT * FROM `accounts`, `players` WHERE `accounts`.`id` = `account_id` and `accounts`.`vip_days` > 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


function onSay(cid, words, param, channel)
	local players = getAllVips()
	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 vip 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

------------------------
SeeOnlineVips
Lua:
<talkaction words="/vipsonline" access="5" script="SeeOnlineVips.lua"/>
SeeOnlineVips
Lua:
function getOnlineVips()
	local tmp = {}
	local result = db.getResult("SELECT * FROM `accounts`, `players` WHERE `accounts`.`id` = `account_id` and `accounts`.`vip_days` > 0 and `players`.`online` > 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

function onSay(cid, words, param, channel)
	local players = getOnlineVips()
	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 vip 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

how to join these two scripts?
Sample: /vipsonline /vipsall


Or Best! whoever is online, name in green, and who's offline, name in red?
 
Last edited:
and may modify this script to saying the command. !online, this shows the free accounts and accounts premiums, for example:

Premium players online: Knight God, Puppy, Raws.
Free players online: H2o, Punk, MS Rix.

Command:
PHP:
local config = {
	showGamemasters = getBooleanFromString(getConfigValue('displayGamemastersWithOnlineCommand'))
}

function onSay(cid, words, param, channel)
	local players = getPlayersOnline()
	local strings = {""}

	local i, position = 1, 1
	local added = false
	for _, pid in ipairs(players) do
		if(added) then
			if(i > (position * 7)) then
				strings[position] = strings[position] .. ","
				position = position + 1
				strings[position] = ""
			else
				strings[position] = i == 1 and "" or strings[position] .. ", "
			end
		end

		if((config.showGamemasters or getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) or not getPlayerCustomFlagValue(pid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) and (not isPlayerGhost(pid) or getPlayerGhostAccess(cid) >= getPlayerGhostAccess(pid))) then
			strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
			i = i + 1
			added = true
		else
			added = false
		end
	end

	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (i - 1) .. " player(s) online:")
	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

if is possible please help me :)
 
Last edited:
Back
Top