You know that's what the 'who list' is for. Depending on the amount of players online it would just spam the player's chatbox.
But if you really want it, here is an example:
I didn't test this, as I said it is an example on how to do this. For further information, all you need to do is go on the wiki and search for what you want to use.
local cmd = "#checklevel80"
function OnChat(event, player, msg, _type, lang)
if (msg == cmd) then
local query = WorldDBQuery("SELECT PlayerName FROM TABLENAME WHERE Level='80'") -- Change TABLENAME to your table name and if it isn't WorldDBQuery use 'CharDBQuery' or 'AuthDBQuery'
if (query) then
local name = query:GetString(0)
player:SendBroadcastMessage("Level 80 player(s) \n"..name..)
until not query:NextRow()
I used (in the above example):
PLAYER_EVENT_ON_CHAT = 18, - (event, player, msg, Type, lang) - Can return false to stop chat message
Global Method "WorldDBQuery" and if your table isn't in the world database use CharDBQuery or AuthDBQuery.