• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Brodcasting a list or something

Status
Not open for further replies.

Mathias

Exalted Member
Hello i was wondering how i could make this:

I got a Table in my database where i have a few columns

the columns looks like this

PlayerName, Level

and how i want this to be is

when people do

#checklevel80

it will display all people online that is level 80 in some kind of list like .gm ingame commando does

i hope this is not too hard

i can pay a few $ if its really required but not much


i can do most of this but not the part with actualy showing it all the rest i can
 
Last edited:

Neth

BETA Tester
basicly you want to do this

for (PlayerList::const_iterator i = playerList.begin(); i != playerList.end(); ++i)
{
// see who is level 80 here
player->Getlevel(80) // not even sure if this function exist
// then send that shit to whever you want
}

this is a pseudo code
 

Mathias

Exalted Member
also it have to use DB since its not really level i am going to use it for i just dont want to say what :S
 

Mathias

Exalted Member
you'll have to wait tommy or someone else, I can't understand you

hmm you know the .gm ingame? i want like that but not exactly i want it to show like that but i was it to extract all rows in my database that have like Level '80' the column is called level and i want it in eluna
 

Tommy

Founder
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:

Code:
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
            repeat
                local name = query:GetString(0)
                player:SendBroadcastMessage("Level 80 player(s) \n"..name..)
            until not query:NextRow()
        end
    end
end

RegisterServerHook(18, OnChat)

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.

I used (in the above example):

RegisterServerHook

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.
 

Mathias

Exalted Member
No problem. I also noticed I didn't use 'tolower' on the command. Meh, give feedback and I'm sure anyone can fix it right up for you if there's something wrong. :3

what you mean with tolower?? also i got to add this at the end of the brodcast "" else it would error :p but i know some lua so it wasnt hard to fix it

but else all worked just as i wanted thank you again


(Mark this as solved)
 
Last edited:

Tommy

Founder
what you mean with tolower?? also i got to add this at the end of the brodcast "" else it would error :p but i know some lua so it wasnt hard to fix it

but else all worked just as i wanted thank you again


(Mark this as solved)

Glad to see it works. "tolower" makes the command that the player enters if there are any capital letters to lowercase letters so the command will work despite how many upper case letters they use.

Anyway, marking as solved!
 
Status
Not open for further replies.
Top