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.

121 lines
3.2 KiB

  1. //
  2. // ADMIN SPECTATE FILTER SCRIPT
  3. // kye 2007
  4. //
  5. #pragma tabsize 0
  6. #include <a_samp>
  7. #include <core>
  8. #include <float>
  9. #include "../include/gl_common.inc"
  10. #define COLOR_GREY 0xAFAFAFAA
  11. #define COLOR_GREEN 0x33AA33AA
  12. #define COLOR_RED 0xAA3333AA
  13. #define COLOR_YELLOW 0xFFFF00AA
  14. #define COLOR_WHITE 0xFFFFFFFF
  15. //------------------------------------------------------------------------------------------------------
  16. #define ADMIN_SPEC_TYPE_NONE 0
  17. #define ADMIN_SPEC_TYPE_PLAYER 1
  18. #define ADMIN_SPEC_TYPE_VEHICLE 2
  19. new gSpectateID[MAX_PLAYERS];
  20. new gSpectateType[MAX_PLAYERS];
  21. //------------------------------------------------------------------------------------------------------
  22. public OnFilterScriptInit()
  23. {
  24. }
  25. //------------------------------------------------------------------------------------------------------
  26. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  27. {
  28. // IF ANYONE IS SPECTATING THIS PLAYER, WE'LL ALSO HAVE
  29. // TO CHANGE THEIR INTERIOR ID TO MATCH
  30. new x = 0;
  31. while(x!=MAX_PLAYERS) {
  32. if( IsPlayerConnected(x) && GetPlayerState(x) == PLAYER_STATE_SPECTATING &&
  33. gSpectateID[x] == playerid && gSpectateType[x] == ADMIN_SPEC_TYPE_PLAYER )
  34. {
  35. SetPlayerInterior(x,newinteriorid);
  36. }
  37. x++;
  38. }
  39. }
  40. //------------------------------------------------------------------------------------------------------
  41. public OnPlayerCommandText(playerid, cmdtext[])
  42. {
  43. new cmd[256];
  44. new specplayerid, specvehicleid, idx;
  45. // WE ONLY DEAL WITH COMMANDS FROM ADMINS IN THIS FILTERSCRIPT
  46. if(!IsPlayerAdmin(playerid)) return 0;
  47. cmd = strtok(cmdtext, idx);
  48. // SPECTATE A PLAYER
  49. if(strcmp(cmd, "/specplayer", true) == 0) {
  50. new tmp[256];
  51. tmp = strtok(cmdtext, idx);
  52. if(!strlen(tmp)) {
  53. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /specplayer [playerid]");
  54. return 1;
  55. }
  56. specplayerid = strval(tmp);
  57. if(!IsPlayerConnected(specplayerid)) {
  58. SendClientMessage(playerid, COLOR_RED, "specplayer: that player isn't active.");
  59. return 1;
  60. }
  61. TogglePlayerSpectating(playerid, 1);
  62. PlayerSpectatePlayer(playerid, specplayerid);
  63. SetPlayerInterior(playerid,GetPlayerInterior(specplayerid));
  64. gSpectateID[playerid] = specplayerid;
  65. gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
  66. return 1;
  67. }
  68. // SPECTATE A VEHICLE
  69. if(strcmp(cmd, "/specvehicle", true) == 0) {
  70. new tmp[256];
  71. tmp = strtok(cmdtext, idx);
  72. if(!strlen(tmp)) {
  73. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /specvehicle [vehicleid]");
  74. return 1;
  75. }
  76. specvehicleid = strval(tmp);
  77. if(specvehicleid < MAX_VEHICLES) {
  78. TogglePlayerSpectating(playerid, 1);
  79. PlayerSpectateVehicle(playerid, specvehicleid);
  80. gSpectateID[playerid] = specvehicleid;
  81. gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
  82. }
  83. return 1;
  84. }
  85. // STOP SPECTATING
  86. if(strcmp(cmd, "/specoff", true) == 0) {
  87. TogglePlayerSpectating(playerid, 0);
  88. gSpectateID[playerid] = INVALID_PLAYER_ID;
  89. gSpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
  90. return 1;
  91. }
  92. return 0;
  93. }
  94. //------------------------------------------------------------------------------------------------------