Advertisement
Frost12

Specing System

Sep 12th, 2015
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. //
  2. // ADMIN SPECTATE SCRIPT
  3. // Frost 2015
  4. //
  5.  
  6. #pragma tabsize 0
  7. #include <a_samp>
  8. #include <core>
  9. #include <float>
  10.  
  11. #include "../include/gl_common.inc"
  12.  
  13. #define COLOR_GREY 0xAFAFAFAA
  14. #define COLOR_GREEN 0x33AA33AA
  15. #define COLOR_RED 0xAA3333AA
  16. #define COLOR_YELLOW 0xFFFF00AA
  17. #define COLOR_WHITE 0xFFFFFFFF
  18.  
  19. //------------------------------------------------------------------------------------------------------
  20.  
  21. #define ADMIN_SPEC_TYPE_NONE 0
  22. #define ADMIN_SPEC_TYPE_PLAYER 1
  23. #define ADMIN_SPEC_TYPE_VEHICLE 2
  24.  
  25. new gSpectateID[MAX_PLAYERS];
  26. new gSpectateType[MAX_PLAYERS];
  27.  
  28. //------------------------------------------------------------------------------------------------------
  29.  
  30. public OnFilterScriptInit()
  31. {
  32. }
  33.  
  34. //------------------------------------------------------------------------------------------------------
  35.  
  36. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  37. {
  38. // IF ANYONE IS SPECTATING THIS PLAYER, WE'LL ALSO HAVE
  39. // TO CHANGE THEIR INTERIOR ID TO MATCH
  40. new x = 0;
  41. while(x!=MAX_PLAYERS) {
  42. if( IsPlayerConnected(x) && GetPlayerState(x) == PLAYER_STATE_SPECTATING &&
  43. gSpectateID[x] == playerid && gSpectateType[x] == ADMIN_SPEC_TYPE_PLAYER )
  44. {
  45. SetPlayerInterior(x,newinteriorid);
  46. }
  47. x++;
  48. }
  49. }
  50.  
  51. //------------------------------------------------------------------------------------------------------
  52.  
  53. public OnPlayerCommandText(playerid, cmdtext[])
  54. {
  55. new cmd[256];
  56. new specplayerid, specvehicleid, idx;
  57.  
  58. // WE ONLY DEAL WITH COMMANDS FROM ADMINS IN THIS FILTERSCRIPT
  59. if(!IsPlayerAdmin(playerid)) return 0;
  60.  
  61. cmd = strtok(cmdtext, idx);
  62.  
  63. // SPECTATE A PLAYER
  64. if(strcmp(cmd, "/specplayer", true) == 0) {
  65. new tmp[256];
  66. tmp = strtok(cmdtext, idx);
  67.  
  68. if(!strlen(tmp)) {
  69. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /specplayer [playerid]");
  70. return 1;
  71. }
  72. specplayerid = strval(tmp);
  73.  
  74. if(!IsPlayerConnected(specplayerid)) {
  75. SendClientMessage(playerid, COLOR_RED, "specplayer: that player isn't active.");
  76. return 1;
  77. }
  78.  
  79. TogglePlayerSpectating(playerid, 1);
  80. PlayerSpectatePlayer(playerid, specplayerid);
  81. SetPlayerInterior(playerid,GetPlayerInterior(specplayerid));
  82. gSpectateID[playerid] = specplayerid;
  83. gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
  84.  
  85. return 1;
  86. }
  87.  
  88. // SPECTATE A VEHICLE
  89. if(strcmp(cmd, "/specvehicle", true) == 0) {
  90. new tmp[256];
  91. tmp = strtok(cmdtext, idx);
  92.  
  93. if(!strlen(tmp)) {
  94. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /specvehicle [vehicleid]");
  95. return 1;
  96. }
  97. specvehicleid = strval(tmp);
  98.  
  99. if(specvehicleid < MAX_VEHICLES) {
  100. TogglePlayerSpectating(playerid, 1);
  101. PlayerSpectateVehicle(playerid, specvehicleid);
  102. gSpectateID[playerid] = specvehicleid;
  103. gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
  104. }
  105. return 1;
  106. }
  107.  
  108. // STOP SPECTATING
  109. if(strcmp(cmd, "/specoff", true) == 0) {
  110. TogglePlayerSpectating(playerid, 0);
  111. gSpectateID[playerid] = INVALID_PLAYER_ID;
  112. gSpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
  113. return 1;
  114. }
  115.  
  116. return 0;
  117. }
  118.  
  119. //------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement