Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //created by GangstaSunny - Have a great day!
- //Copyright by www.german-samplife.de (2016)
- #include <a_samp>
- #define RCON_ADMIN_ONLY // comment this out if erveryone should can check the server and player statistics
- #define REFRESH_SECONDS 1 // set the time (in seconds) when the statistics should be refreshed
- forward sSShowServerStatistics(playerid);
- forward sSShowPlayerStatistics(playerid, clickedplayerid);
- new sSShowStats[MAX_PLAYERS];
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/serverstats", cmdtext, true, 10) == 0)
- {
- #if defined RCON_ADMIN_ONLY
- if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,0xFFFFFFFF,"{FFE600}[Info]: {FFFFFF}This command is for RCON Administrators only.");
- #endif
- sSShowStats[playerid] = SetTimerEx("sSShowServerStatistics", REFRESH_SECONDS*1000, 1, "i", playerid);
- new sSheadline[64], sSregex[128];
- GetServerVarAsString("hostname", sSheadline, sizeof(sSheadline));
- format(sSregex,128,"{FFE600}[Info]: Watching server statistics of - %s (refreshing every %d second(s))",sSheadline,REFRESH_SECONDS);
- SendClientMessage(playerid,0xFFFFFFFF,sSregex);
- return 1;
- }
- return 0;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- #if defined RCON_ADMIN_ONLY
- if(!IsPlayerAdmin(playerid))return 0;
- #endif
- new sSname[MAX_PLAYER_NAME], sSregex[128];
- GetPlayerName(playerid, sSname, MAX_PLAYER_NAME);
- format(sSregex,128,"{FFE600}[Info]: Watching player statistics of - {FFC800}%s (id: %i) - (refreshing every %d second(s))",sSname,clickedplayerid,REFRESH_SECONDS);
- SendClientMessage(playerid,0xFFFFFFFF,sSregex);
- sSShowStats[playerid] = SetTimerEx("sSShowPlayerStatistics", REFRESH_SECONDS*1000, 1, "ii", playerid, clickedplayerid);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){if(dialogid == 9988){KillTimer(sSShowStats[playerid]);}}
- public sSShowServerStatistics(playerid)
- {
- ShowPlayerDialog(playerid, -1, 1, "", "", "", "");//Safley closing the dialog first
- new sSheadline[64], sSregex[1024];
- GetServerVarAsString("hostname", sSheadline, sizeof(sSheadline));
- GetNetworkStats(sSregex, sizeof(sSregex));
- strins(sSregex, "Statistic\tValue\n", 0);
- strins(sSheadline, "{FFC800}", 0);
- for(new stat = 0; stat < 17; stat++)
- {
- new delpos = strfind(sSregex, ":", true);
- strdel(sSregex, delpos, delpos+1);
- strins(sSregex, "\t", delpos);
- }
- ShowPlayerDialog(playerid,9988,DIALOG_STYLE_TABLIST_HEADERS,sSheadline,sSregex,"Close","");
- return 1;
- }
- public sSShowPlayerStatistics(playerid, clickedplayerid)
- {
- ShowPlayerDialog(playerid, -1, 1, "", "", "", "");//Safley closing the dialog first
- new sSheadline[64], sSregex[1024];
- GetServerVarAsString("hostname", sSheadline, sizeof(sSheadline));
- GetPlayerNetworkStats(clickedplayerid, sSregex, sizeof(sSregex));
- strins(sSregex, "Statistic\tValue\n", 0);
- strins(sSheadline, "{FFE600}", 0);
- for(new stat = 0; stat < 18; stat++)
- {
- new delpos = strfind(sSregex, ":", true);
- strdel(sSregex, delpos, delpos+1);
- strins(sSregex, "\t", delpos);
- }
- ShowPlayerDialog(playerid,9988,DIALOG_STYLE_TABLIST_HEADERS,sSheadline,sSregex,"Close","");
- return 1;
- }
Add Comment
Please, Sign In to add comment