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

Get online players by account id

frann

New Member
Joined
Feb 28, 2009
Messages
7
Reaction score
0
Yo.
How can i check how many players with specified account id are online?
 
Lua:
local i = {}
function onSay(cid, words, param, channel)
	if (param == '') then
		return doPlayerSendTextMessage(cid, 27, "Command param required.") and true
	end
	if not (isNumber(param)) then
		return doPlayerSendTextMessage(cid, 27, "Command param should only be numbers") and true
	end
	local o = db.getResult("SELECT MAX(id) AS id FROM accounts")
	local u = o:getDataInt('id')
	if (param > ''..u..'') then
		doPlayerSendTextMessage(cid, 27, "Sorry, the highest account id value is "..u)
	else
	local w = db.getResult("SELECT name FROM accounts WHERE id ="..param)
	local q = w:getDataInt('name')
		for _, pid in ipairs(getPlayersOnline()) do
			if (getPlayerAccount(pid) == ''..q..'') then
				table.insert(i, {getCreatureName(pid), getPlayerLevel(pid)})
			end
		end
			doPlayerSendTextMessage(cid, 27, "Players online with account id "..param..":")
			if (#i == 0) then
				doPlayerSendTextMessage(cid, 27, "None")
			end
			for k = 1, #i do
				doPlayerSendTextMessage(cid, 27, k..": Name: "..i[k][1]..", level: "..i[k][2]..".")
			end
		i = {}
	end
return TRUE
end
 
Lua:
function onSay(cid, words, param, channel)
	param = tonumber(param)
	if param == nil then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Command param must be a number.')
	end

	local s
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Players online with account id '.. param ..':')

	for i, pid in ipairs(getPlayersOnline()) do
		if getPlayerAccountId(pid) == param then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, i .. ': Name: ' .. getCreatureName(pid) .. ', level: ' .. getPlayerLevel(pid) .. '.')
			s = true
		end
	end

	if s == nil then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'None')
	end
	return true
end
 
Back
Top