Advertisement
SlashQ

tazer

Nov 26th, 2011
2,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.39 KB | None | 0 0
  1. /*
  2.     Tazer Script by SlashQ
  3.    
  4.     This is a simple tazer script done in about 3 minutes. This will ONLY work for
  5.     cop skins, and not everyone else. However, this can be adjusted.
  6.  
  7.     The SECONDS define means amount of seconds that the tazed player will get
  8.     unfrozen and go back to normal in (10 by default).
  9.    
  10.     The TAZE_MS define means amount of milliseconds that the function
  11.     "OnPlayerTazePlayer" gets called in each time (400 by default).
  12.    
  13.     Now look at the IsNotCop define, and change:
  14.    
  15.     ((GetPlayerSkin(%0) < 280 && GetPlayerSkin(%0) > 288))
  16.     to ((PlayerInfo[%0][pMember] != 1))
  17.    
  18.     Or whatever variable you use for teams. Enjoy!
  19. */
  20.  
  21. #include <a_samp>
  22. #tryinclude <angdist>
  23.  
  24. #if !defined IsPlayerAimingAtPlayer
  25.     #error You need the 'angdist' include. You can get it at the release topic.
  26. #endif
  27.  
  28. #define SECONDS 10
  29. #define TAZE_MS 400
  30. #define IsNotCop(%0) ((GetPlayerSkin(%0) < 280 && GetPlayerSkin(%0) > 288))
  31.  
  32. forward Unfreeze(playerid);
  33. forward OnPlayerTazePlayer(playerid);
  34.  
  35. public OnFilterScriptInit() {
  36.  
  37.     for(new i = 0; i < MAX_PLAYERS; i++)
  38.     {
  39.         if(IsPlayerConnected(i))
  40.             SetPVarInt(i, "TazeTimer", SetTimerEx("OnPlayerTazePlayer", TAZE_MS, true, "i", i));
  41.     }
  42.     return 1;
  43. }
  44.  
  45. public OnPlayerConnect(playerid) {
  46.  
  47.     SetPVarInt(playerid, "TazeTimer", SetTimerEx("OnPlayerTazePlayer", TAZE_MS, true, "i", playerid));
  48.     return 1;
  49. }
  50.  
  51. public OnPlayerDisconnect(playerid) {
  52.  
  53.     KillTimer(GetPVarInt(playerid, "TazeTimer"));
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerTazePlayer(playerid) {
  58.  
  59.     new
  60.         Keys[3];
  61.  
  62.     GetPlayerKeys(playerid, Keys[0], Keys[1], Keys[2]);
  63.  
  64.     if(Keys[0] & KEY_FIRE) {
  65.    
  66.         if(IsNotCop(playerid)) return 1;
  67.  
  68.         else {
  69.  
  70.             if((GetPlayerWeapon(playerid) == 23) && (GetPVarInt(playerid, "HasTazer")) == 1) {
  71.  
  72.                 new targetid = 0;
  73.                 while ((targetid < MAX_PLAYERS) && (IsPlayerConnected(targetid))) {
  74.            
  75.                     if(GetDistanceBetweenPlayers(playerid, targetid) >= 4) {
  76.                
  77.                         if(IsPlayerAimingAtPlayer(playerid, targetid) == 1) {
  78.                    
  79.                             if(IsPlayerInAnyVehicle(targetid) == 0 && IsPlayerInAnyVehicle(playerid) == 0) {
  80.                        
  81.                                 if(targetid != playerid) {
  82.                            
  83.                                     // Feel free to add some other stuff here...
  84.                                     // Remember, variable 'targetid' is the player who got tazed!
  85.                                     if(GetPVarInt(targetid, "Tazed") == 1) return 0;
  86.                                     ApplyAnimation(targetid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
  87.                                     TogglePlayerControllable(targetid, 0);
  88.                                     SetTimerEx("Unfreeze", (SECONDS * 1000), false, "i", targetid);
  89.                                     SetPVarInt(targetid, "Tazed", 1);
  90.                                 }
  91.                             }
  92.                         }
  93.                     }
  94.                     targetid ++;
  95.                 }
  96.             }
  97.         }
  98.     }
  99.     return 1;
  100. }
  101.  
  102. public OnPlayerCommandText(playerid, cmdtext[]) {
  103.  
  104.     if(!strcmp(cmdtext, "/tazer", true)) {
  105.    
  106.         if(IsNotCop(playerid))
  107.             return 1;
  108.        
  109.         if(GetPVarInt(playerid, "HasTazer") == 0) {
  110.        
  111.             SetPVarInt(playerid, "HasTazer", 1);
  112.             GivePlayerWeapon(playerid, 23, 65500);
  113.             SendClientMessage(playerid, 0xFFFF00FF, "Tazer unholstered.");
  114.         }
  115.         else {
  116.        
  117.             DeletePVar(playerid, "HasTazer");
  118.             SetPlayerAmmo(playerid, 23, 0);
  119.             SendClientMessage(playerid, 0xFFFF00FF, "Tazer holstered.");
  120.         }
  121.         return 1;
  122.     }
  123.     return 0;
  124. }
  125.        
  126. public Unfreeze(playerid) {
  127.  
  128.     TogglePlayerControllable(playerid, 1);
  129.     DeletePVar(playerid, "Tazed");
  130.     return ClearAnimations(playerid);
  131. }
  132.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement