/admins with offline function
#1

Hello guys,i want to start to make a cmd,/admins

If you type /admins,a list with full admin name is shown,and after their name,Offline if they are Offline or Online if they are online.

example:
admin A-Offline
admin B-Online
admin C-Online
admin D-Online
admin E-Offline

any ideas on how to do this?[mysql server]
Reply
#2

Its quite simple


Check admins in SQL
Quote:

mysql_query("SELECT username FROM users WHERE admin='1'"); //select all level 1 admins for example

//fetch the stuff etc...
if(IsPlayerConnected(DataFromSQL['username'])) format(string,sizeof(string),"%s ONLINE");

This was just an example code of course
Reply
#3

I guess a better way to do that is exporting the admin list into a file every couple of hours or so and then retrieve the info from there. Just incase he has a big amount of users in his table.
Reply
#4

Lack of information, the admin level is in the main players table or you have a separated table for admins? Either way, retrieving the player's name and use it in sscanf (1st parameter) with "r" or "u" specifier can easily figure out if the player is connected (if variable (3rd parameter) is not equal to INVALID_PLAYER_ID then player is connected).

Don't forget to set the admin level column as index in the table's structure to make it faster.
Reply
#5

so,i got admin on users table,not in a separated one.

i was wondering if i can make another table in my database called adminlist,and where i can manually put my admin names on it.
But i dont know how to make a function that gets the names from the adminlist and checks if they are offline,i tried my best still all of them appear to be OFFLINE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)