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.

78 lines
1.7 KiB

5 years ago
  1. //
  2. // Admin player 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 gNetStatsDisplayId = INVALID_PLAYER_ID;
  10. new gNetStatsTimerId = 0;
  11. forward NetStatsDisplay();
  12. //------------------------------------------------
  13. public OnFilterScriptInit()
  14. {
  15. print("\n--Admin Netstats FS loaded.\n");
  16. return 1;
  17. }
  18. //------------------------------------------------
  19. public NetStatsDisplay()
  20. {
  21. new netstats_str[2048+1];
  22. GetPlayerNetworkStats(gNetStatsDisplayId, netstats_str, 2048);
  23. ShowPlayerDialog(gNetStatsPlayerId, ADMIN_NETSTATS_DIALOGID, DIALOG_STYLE_MSGBOX, "Player NetStats", netstats_str, "Ok", "");
  24. }
  25. //------------------------------------------------
  26. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  27. {
  28. if(!IsPlayerAdmin(playerid)) return 0; // this is an admin only script
  29. if(dialogid == ADMIN_NETSTATS_DIALOGID) {
  30. KillTimer(gNetStatsTimerId);
  31. gNetStatsPlayerId = INVALID_PLAYER_ID;
  32. return 1;
  33. }
  34. return 0;
  35. }
  36. //------------------------------------------------
  37. public OnPlayerCommandText(playerid, cmdtext[])
  38. {
  39. new cmd[256+1];
  40. new idx;
  41. if(!IsPlayerAdmin(playerid)) return 0;
  42. cmd = strtok(cmdtext, idx);
  43. // netstats command
  44. if(strcmp("/pnetstats", cmd, true) == 0)
  45. {
  46. new tmp[128];
  47. tmp = strtok(cmdtext, idx);
  48. if(!strlen(tmp)) { return 1; }
  49. gNetStatsPlayerId = playerid;
  50. gNetStatsDisplayId = strval(tmp);
  51. NetStatsDisplay();
  52. gNetStatsTimerId = SetTimer("NetStatsDisplay", 3000, true); // this will refresh the display every 3 seconds
  53. return 1;
  54. }
  55. return 0;
  56. }
  57. //------------------------------------------------