Guest User

RP Taser System

a guest
Feb 20th, 2012
2,435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.38 KB | None | 0 0
  1. //RP TASER SYSTEM BY JUSTLUCA (IVMyLife)
  2. //The "TazerAcceso" variable check if the Taser was ON or OFF. 1 for ON and 0 for OFF.
  3.  
  4. //===========================[Includes]=========================================
  5. #include <a_samp>
  6. //===========================[Defines]==========================================
  7. #define FILTERSCRIPT
  8. #if defined FILTERSCRIPT
  9. //===========================[New]==============================================
  10. new TazerAcceso[MAX_PLAYERS];
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.     print("\n-----------------------------------------");
  15.     print(" Taser System by JustLuca (IVMyLife) LOADED");
  16.     print("-------------------------------------------\n");
  17.     return 1;
  18. }
  19.  
  20. public OnFilterScriptExit()
  21. {
  22.     print("\n--------------------------------------------");
  23.     print(" Taser System by JustLuca (IVMyLife) UNLOADED ");
  24.     print("---------------------------------------------\n");
  25.     return 1;
  26. }
  27.  
  28. #endif
  29.  
  30. public OnPlayerConnect(playerid)
  31. {
  32.     SendClientMessage(playerid,-1,"[Info:] This server uses Taser System v.1.0 by JustLuca (IVMyLife)");
  33.     TazerAcceso[playerid] = 0;
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerDisconnect(playerid, reason)
  38. {
  39.     return 1;
  40. }
  41.  
  42. public OnPlayerDeath(playerid, killerid, reason)
  43. {
  44.     TazerAcceso[playerid] = 0;
  45.     return 1;
  46. }
  47.  
  48. public OnPlayerUpdate(playerid)
  49. {
  50.     if(TazerAcceso[playerid] == 1)
  51.     {
  52.         if(GetPlayerWeapon(playerid) == 0)
  53.         {
  54.             SetPlayerAttachedObject(playerid, 7, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0); //Taser
  55.             return 1;
  56.         }
  57.         if(GetPlayerWeapon(playerid) != 0)
  58.         {
  59.             RemovePlayerAttachedObject(playerid, 7); //This remove the taser
  60.             return 1;
  61.         }
  62.     }
  63.     return 1;
  64. }
  65.  
  66. forward Float:GetDistanceBetweenPlayers(p1,p2);
  67. public Float:GetDistanceBetweenPlayers(p1,p2)
  68. {
  69.     new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  70.     if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
  71.     {
  72.         return -1.00;
  73.     }
  74.     GetPlayerPos(p1,x1,y1,z1);
  75.     GetPlayerPos(p2,x2,y2,z2);
  76.     return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  77. }
  78.  
  79. forward GetClosestPlayer(p1);
  80. public GetClosestPlayer(p1)
  81. {
  82.     new x,Float:dis,Float:dis2,player;
  83.     player = -1;
  84.     dis = 99999.99;
  85.     for (x=0;x<MAX_PLAYERS;x++)
  86.     {
  87.         if(IsPlayerConnected(x))
  88.         {
  89.             if(x != p1)
  90.             {
  91.                 dis2 = GetDistanceBetweenPlayers(x,p1);
  92.                 if(dis2 < dis && dis2 != -1.00)
  93.                 {
  94.                     dis = dis2;
  95.                     player = x;
  96.                 }
  97.             }
  98.         }
  99.     }
  100.     return player;
  101. }
  102.  
  103. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
  104. {
  105.     if(TazerAcceso[playerid] == 1)
  106.     {
  107.     if(GetPlayerWeapon(playerid) == 0)
  108.     {
  109.             ApplyAnimation(playerid,"KNIFE", "knife_3", 4.0, 0, 1, 1, 1, 1000);
  110.             SetTimerEx("TimerClear",2000,false,"d",playerid);
  111.             new victimid = GetClosestPlayer(playerid);
  112.             if(IsPlayerConnected(victimid))
  113.             {
  114.                 if(GetDistanceBetweenPlayers(playerid,victimid) < 2)
  115.                 {
  116.                     new Float:health;
  117.                     GetPlayerHealth(victimid, health);
  118.                     SetPlayerHealth(victimid, health - 5.0);
  119.                     SetTimerEx("TimerFall",300,false,"d",victimid);
  120.                     TogglePlayerControllable(victimid, 0);
  121.                     SetTimerEx("Untaze", 20000, false, "i", victimid);
  122.                  }
  123.              }
  124.           }
  125.     }
  126.     return 1;
  127. }
  128.  
  129. forward Untaze(playerid);
  130. public Untaze(playerid)
  131. {
  132.     SendClientMessage(playerid, -1, "[Info:] You are not more Tased");
  133.     TogglePlayerControllable(playerid, 1);
  134.     return 1;
  135. }
  136.  
  137. forward TimeClear(playerid);
  138. public TimeClear(playerid)
  139. {
  140.     ClearAnimations(playerid);
  141. }
  142.  
  143. forward TimerFall(playerid);
  144. public TimerFall(playerid)
  145. {
  146.     ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
  147.     SetTimerEx("TimerClear",19700,false,"d",playerid);
  148. }
  149. forward TimerCrack(playerid);
  150. public TimerCrack(playerid)
  151. {
  152.     ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
  153.     SetTimerEx("TimeClear",19700,false,"d",playerid);
  154. }
  155.  
  156. public OnPlayerCommandText(playerid, cmdtext[])
  157. {
  158.     if (strcmp("/taseron", cmdtext, true, 8) == 0)
  159.     {
  160.         if(TazerAcceso[playerid] == 1)
  161.         {
  162.             SendClientMessage(playerid,-1,"[Info:] Your taser is already on!");
  163.             return 1;
  164.         }
  165.         TazerAcceso[playerid] = 1;
  166.         SetPlayerAttachedObject(playerid, 7, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0);
  167.         SendClientMessage(playerid,-1,"[Info:] Type /taseroff for turn off.");
  168.         SendClientMessage(playerid,-1,"[Info:] The taser will auto-equip when you select the fists.");
  169.         SendClientMessage(playerid,-1,"[Info:] For use the taser, you just need to punch with who you want use it.");
  170.         return 1;
  171.     }
  172.     if (strcmp("/taseroff", cmdtext, true, 9) == 0)
  173.     {
  174.         if(TazerAcceso[playerid] == 0)
  175.         {
  176.             SendClientMessage(playerid,-1,"[Info:] Your taser is already off!");
  177.             return 1;
  178.         }
  179.         TazerAcceso[playerid] = 1;
  180.         RemovePlayerAttachedObject(playerid, 7);
  181.         SendClientMessage(playerid,-1,"[Info:] You turn off your taser, for turn on type /tazeron .");
  182.         SendClientMessage(playerid,-1,"[Info:] You turned off your taser! Remember to turn on it.");
  183.         return 1;
  184.     }
  185.     return 0;
  186. }
  187.  
  188. /*================================================================================================================================
  189. End of the line.
  190. ================================================================================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment