Guest User

Untitled

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