Advertisement
Guest User

[FS] Taser - SAMP 0.3d

a guest
Mar 18th, 2012
1,582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. /////////////////////////////////////////////////////////
  2. ///////// FS - Taser - by TiNCH010 //////////////////////
  3. //////// www.forum.sa-mp.com ////////////////////////////
  4. /////////////////////////////////////////////////////////
  5.  
  6. #define FILTERSCRIPT
  7.  
  8. #include <a_samp>
  9.  
  10. #pragma tabsize 0 // We avoid the warning 'loose identiation'.
  11.  
  12.  
  13. //|________________ Configuration ________________|
  14.  
  15. #define Taser_Time 5000 // Number of milliseconds that lasts the paralyzation of the taser, change if desired.
  16. #define WEAPON 23 // Weapon ID that we are gonna use.
  17. #define R_SOUND 50.0 // The radius of the sound of the taser that will sound.
  18. #define WHITE -1 // White colour by default.
  19. #define YELLOW 0xFFFF00AA // Yellow colour.
  20.  
  21. // |______________________________________________|
  22.  
  23. new ContinueTaser[MAX_PLAYERS];
  24.  
  25. forward GetClosestPlayer(p1);
  26. forward Float:GetDistanceBetweenPlayers(p1,p2);
  27.  
  28. main()
  29. {
  30. }
  31.  
  32. public OnPlayerConnect(playerid)
  33. {
  34. ContinueTaser[playerid] = 0;
  35. return 1;
  36. }
  37.  
  38. public OnPlayerDisconnect(playerid, reason)
  39. {
  40. ContinueTaser[playerid] = 0;
  41. return 1;
  42. }
  43.  
  44. public OnPlayerSpawn(playerid)
  45. {
  46. ContinueTaser[playerid] = 0;
  47. return 1;
  48. }
  49.  
  50. public OnPlayerDeath(playerid, killerid, reason)
  51. {
  52. ContinueTaser[playerid] = 0;
  53. return 1;
  54. }
  55.  
  56. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  57. {
  58. if(newkeys & KEY_FIRE) // If you push left click you're gonna play the taser.
  59. {
  60. new victimid = GetClosestPlayer(playerid);
  61. if(IsPlayerConnected(victimid))
  62. {
  63. if(ContinueTaser[playerid] == 1)
  64. {
  65. TogglePlayerControllable(playerid, 0);
  66. TogglePlayerControllable(victimid, 0);
  67. ContinueTaser[playerid] = 1;
  68. SendClientMessage(playerid, WHITE, "You used your {FFCC33}taser{FFFFFF} again!");
  69. SendClientMessage(playerid, YELLOW, "You can continue to shoot the taser and the victim will return to receive electricity.");
  70. SendClientMessage(victimid, WHITE, "You have received again a {FFCC33}taser{FFFFFF} dart!");
  71. ApplyAnimation(victimid,"PED","KO_skid_front",4.1,0,1,1,1,0);
  72. ApplyAnimation(victimid,"PED","KO_skid_front",4.1,0,1,1,1,0);
  73. SetTimerEx("TaserTime", Taser_Time, 0, "d", victimid);
  74. SetTimerEx("StopTaser", Taser_Time, 0, "d", playerid);
  75. }
  76. }
  77. return 1;
  78. }
  79. return 1;
  80. }
  81.  
  82. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
  83. {
  84. if(issuerid != INVALID_PLAYER_ID)
  85. {
  86. new Float:Chaleco, Float:Vida; GetPlayerArmour(playerid, Chaleco); GetPlayerHealth(playerid, Vida);
  87. if(weaponid == WEAPON)
  88. {
  89. if(IsPlayerInAnyVehicle(playerid))
  90. {
  91. return 1;
  92. }
  93.  
  94. GameTextForPlayer(playerid, "~r~paralyzed by the taser again", Taser_Time, 3);
  95. TogglePlayerControllable(playerid, 0);
  96. TogglePlayerControllable(issuerid, 0);
  97. ContinueTaser[issuerid] = 1;
  98. new Float:Audio_X, Float:Audio_Y, Float:Audio_Z;
  99. GetPlayerPos(playerid, Audio_X, Audio_Y, Audio_Z);
  100. StopAudioStreamForPlayer(playerid);
  101. PlayAudioStreamForPlayer(playerid, "http://k004.kiwi6.com/hotlink/9s19772cbe/taser_sound.mp3", Audio_X, Audio_Y, Audio_Z, R_SOUND, 1);
  102. SendClientMessage(issuerid, WHITE, "You used your {FFCC33}taser{FFFFFF}!");
  103. SendClientMessage(issuerid, YELLOW, "You can continue to shoot the taser and the victim will return to receive electricity.");
  104. SendClientMessage(playerid, WHITE, "You have received {FFCC33}taser{FFFFFF} dart!");
  105. ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
  106. ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
  107. SetTimerEx("TaserTime", Taser_Time, 0, "d", playerid);
  108. SetTimerEx("StopTaser", Taser_Time, 0, "d", issuerid);
  109. }
  110. }
  111. return 1;
  112. }
  113.  
  114. forward TaserTime(playerid);
  115. public TaserTime(playerid)
  116. {
  117. TogglePlayerControllable(playerid, 1);
  118. ClearAnimations(playerid);
  119. return 1;
  120. }
  121.  
  122. forward StopTaser(playerid);
  123. public StopTaser(playerid)
  124. {
  125. TogglePlayerControllable(playerid, 1);
  126. ClearAnimations(playerid);
  127. ContinueTaser[playerid] = 0;
  128. return 1;
  129. }
  130.  
  131. public GetClosestPlayer(p1)
  132. {
  133. new x,Float:dis,Float:dis2,player2;
  134. player2 = -1;
  135. dis = 99999.99;
  136. for (x=0;x<MAX_PLAYERS;x++)
  137. {
  138. if(IsPlayerConnected(x))
  139. {
  140. if(x != p1)
  141. {
  142. dis2 = GetDistanceBetweenPlayers(x,p1);
  143. if(dis2 < dis && dis2 != -1.00)
  144. {
  145. dis = dis2;
  146. player2 = x;
  147. }
  148. }
  149. }
  150. }
  151. return player2;
  152. }
  153.  
  154. public Float:GetDistanceBetweenPlayers(p1,p2)
  155. {
  156. new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  157. if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
  158. {
  159. return -1.00;
  160. }
  161. GetPlayerPos(p1,x1,y1,z1);
  162. GetPlayerPos(p2,x2,y2,z2);
  163. return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  164. }
  165.  
  166. // Keep the credits!
  167. // © 2012
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement