SAMP Gitlab CI Test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB

  1. //
  2. // Admin netstats display
  3. //
  4. #include <a_samp>
  5. #include "../include/gl_common.inc"
  6. #define ADMINFS_MESSAGE_COLOR 0xFF444499
  7. #define ADMIN_NETSTATS_DIALOGID 12898
  8. new gNetStatsPlayerId = INVALID_PLAYER_ID;
  9. new gNetStatsTimerId = 0;
  10. forward NetStatsDisplay();
  11. //------------------------------------------------
  12. public OnFilterScriptInit()
  13. {
  14. print("\n--Admin Netstats FS loaded.\n");
  15. return 1;
  16. }
  17. //------------------------------------------------
  18. public NetStatsDisplay()
  19. {
  20. new netstats_str[2048+1];
  21. GetNetworkStats(netstats_str, 2048);
  22. ShowPlayerDialog(gNetStatsPlayerId, ADMIN_NETSTATS_DIALOGID, DIALOG_STYLE_MSGBOX, "Server NetStats", netstats_str, "Ok", "");
  23. }
  24. //------------------------------------------------
  25. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  26. {
  27. if(!IsPlayerAdmin(playerid)) return 0; // this is an admin only script
  28. if(dialogid == ADMIN_NETSTATS_DIALOGID) {
  29. KillTimer(gNetStatsTimerId);
  30. gNetStatsPlayerId = INVALID_PLAYER_ID;
  31. return 1;
  32. }
  33. return 0;
  34. }
  35. //------------------------------------------------
  36. public OnPlayerCommandText(playerid, cmdtext[])
  37. {
  38. new cmd[256+1];
  39. new idx;
  40. if(!IsPlayerAdmin(playerid)) return 0;
  41. cmd = strtok(cmdtext, idx);
  42. // netstats command
  43. if(strcmp("/netstats", cmd, true) == 0)
  44. {
  45. gNetStatsPlayerId = playerid;
  46. NetStatsDisplay();
  47. gNetStatsTimerId = SetTimer("NetStatsDisplay", 3000, true); // this will refresh the display every 3 seconds
  48. return 1;
  49. }
  50. return 0;
  51. }
  52. //------------------------------------------------