Advertisement
Boar

[Filterscript] Taser Gun - SAMP

Dec 25th, 2015
1,884
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.12 KB | None | 0 0
  1. /*
  2.  
  3.  _____                     _____            
  4. |_   _|                   |  __ \            
  5.   | | __ _ ___  ___ _ __  | |  \/_   _ _ __  
  6.   | |/ _` / __|/ _ \ '__| | | __| | | | '_ \
  7.   | | (_| \__ \  __/ |    | |_\ \ |_| | | | |
  8.   \_/\__,_|___/\___|_|     \____/\__,_|_| |_|
  9.  
  10. Filterscript made by Boar.
  11.  
  12. */
  13.  
  14. #define FILTERSCRIPT
  15.  
  16. #include <a_samp>
  17. #include <zcmd>
  18. #include <foreach>
  19.  
  20. #define TASER_EFFECT_TIME 5000 // The time during which the hit player is under the effect of the taser.
  21. #define TASER_GIVING_TIME 3000 // The time after which the taser will be given again.
  22. #define TASER_WEAPON WEAPON_SILENCED // The weapon which will work as a taser.
  23. #define TASER_WEAPON_SLOT 2 // The slot of the chosen weapon.
  24. #define TASER_WEAPON_OBJECT 347 // The ID of the object of the chosen weapon.
  25.  
  26. new bool:taser[MAX_PLAYERS];
  27. new GiveTaserAgainTimer[MAX_PLAYERS];
  28. new lastWeapon[MAX_PLAYERS];
  29.  
  30. public OnPlayerConnect(playerid)
  31. {
  32.     taser[playerid] = false;
  33.     GiveTaserAgainTimer[playerid] = 0;
  34.     lastWeapon[playerid] = 0;
  35.  
  36.     // Preload the animation libraries used.
  37.     ApplyAnimation(playerid, "SWORD", "null", 0.0, 0, 0, 0, 0, 0);
  38.     ApplyAnimation(playerid, "CRACK", "null", 0.0, 0, 0, 0, 0, 0);
  39.     return 1;
  40. }
  41.  
  42. public OnPlayerDeath(playerid, killerid, reason)
  43. {
  44.     taser[playerid] = false;
  45.     GiveTaserAgainTimer[playerid] = 0;
  46.     lastWeapon[playerid] = 0;
  47.     return 1;
  48. }
  49.  
  50. public OnPlayerUpdate(playerid)
  51. {
  52.     new w = GetPlayerWeapon(playerid);
  53.     if (w != lastWeapon[playerid]) OnPlayerChangeWeapon(playerid, w, lastWeapon[playerid]);
  54.     lastWeapon[playerid] = w;
  55.     return 1;
  56. }
  57.  
  58. forward OnPlayerChangeWeapon(playerid, newWeap, oldWeap);
  59. public OnPlayerChangeWeapon(playerid, newWeap, oldWeap)
  60. {
  61.     if (IsPlayerAttachedObjectSlotUsed(playerid, 0) && taser[playerid]) SetPlayerArmedWeapon(playerid, 0);
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
  66. {
  67.     if (weaponid == TASER_WEAPON)
  68.     {
  69.         if (taser[issuerid])
  70.         {
  71.             new Float:health;
  72.             GetPlayerHealth(playerid, health);
  73.             SetPlayerHealth(playerid, health+amount);
  74.         }
  75.     }
  76.     return 1;
  77. }
  78.  
  79. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  80. {
  81.     if (weaponid == TASER_WEAPON)
  82.     {
  83.         if (taser[playerid])
  84.         {
  85.             GiveTaserAgainTimer[playerid] = SetTimerEx("GiveTaserAgain", TASER_GIVING_TIME, 0, "i", playerid);
  86.             ApplyAnimation(playerid, "SWORD", "sword_block", 50.0, 0, 1, 0, 1, 1, 1);
  87.             SetPlayerAttachedObject(playerid, 0, TASER_WEAPON_OBJECT, 6);
  88.             SetPlayerArmedWeapon(playerid, 0);
  89.  
  90.             if (hittype == BULLET_HIT_TYPE_PLAYER) {
  91.                 new Float:x, Float:y, Float:z;
  92.                 GetPlayerPos(hitid, x, y, z);
  93.                 foreach(Player, i) if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z)) PlayAudioStreamForPlayer(i, "https://a.clyp.it/b0w3dcsr.mp3", x, y, z, 30.0, 1);
  94.                 ApplyAnimation(hitid, "CRACK", "crckdeth2", 4.1, 0, 1, 1, 1, TASER_EFFECT_TIME, 1);
  95.                 SetPlayerDrunkLevel(hitid, 5000);
  96.                 SetTimerEx("EndTaserEffect", TASER_EFFECT_TIME, 0, "i", hitid);
  97.             }
  98.         }
  99.     }
  100.     return 1;
  101. }
  102.  
  103. forward EndTaserEffect(playerid);
  104. public EndTaserEffect(playerid)
  105. {
  106.     new skin = GetPlayerSkin(playerid);
  107.     SetPlayerSkin(playerid, skin);
  108.     ClearAnimations(playerid, 1);
  109.     SetPlayerDrunkLevel(playerid, 0);
  110.     return 1;
  111. }
  112.  
  113. forward GiveTaserAgain(playerid);
  114. public GiveTaserAgain(playerid)
  115. {
  116.     RemovePlayerAttachedObject(playerid, 0);
  117.     GivePlayerWeapon(playerid, TASER_WEAPON, 1);
  118.  
  119.     new skin = GetPlayerSkin(playerid);
  120.     SetPlayerSkin(playerid, skin);
  121.     ClearAnimations(playerid, 1);
  122.     return 1;
  123. }
  124.  
  125. CMD:taser(playerid, params[])
  126. {
  127.     new weapon, ammo;
  128.     GetPlayerWeaponData(playerid, TASER_WEAPON_SLOT, weapon, ammo);
  129.     GivePlayerWeapon(playerid, weapon, -ammo);
  130.  
  131.     if (taser[playerid])
  132.     {
  133.         taser[playerid] = false;
  134.         if (GiveTaserAgainTimer[playerid]) KillTimer(GiveTaserAgainTimer[playerid]);
  135.         if (IsPlayerAttachedObjectSlotUsed(playerid, 0)) {
  136.             new skin = GetPlayerSkin(playerid);
  137.             SetPlayerSkin(playerid, skin);
  138.             ClearAnimations(playerid, 1);
  139.             RemovePlayerAttachedObject(playerid, 0);
  140.         }
  141.     }
  142.     else
  143.     {
  144.         taser[playerid] = true;
  145.         GivePlayerWeapon(playerid, TASER_WEAPON, 1);
  146.     }
  147.     return 1;
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement