SA-MP Forums Archive
/admins with offline function - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /admins with offline function (/showthread.php?tid=622106)



/admins with offline function - PepsiCola23 - 18.11.2016

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]


Re: /admins with offline function - TwinkiDaBoss - 18.11.2016

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


Re: /admins with offline function - ranme15 - 19.11.2016

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.


Re: /admins with offline function - Konstantinos - 19.11.2016

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.


Re: /admins with offline function - PepsiCola23 - 19.11.2016

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