Guest User

0.3C Tazer By AlexzzPro

a guest
Apr 30th, 2011
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.02 KB | None | 0 0
  1. /*
  2. ||||||||||||||||||||||||||||||||||||||||||||||||||
  3. ||0.3C Tazer System By AlexzzPro ||
  4. ||Please do not re-release without my permission||
  5. ||Do not claim this as your own ||
  6. ||Enjoy! ||
  7. ||||||||||||||||||||||||||||||||||||||||||||||||||
  8. */
  9. #define FILTERSCRIPT
  10. #include <a_samp>
  11. #include <zcmd>
  12. #define GREEN 0x21DD00FF
  13. new tazeronbelt[MAX_PLAYERS];
  14. new tazertimer[MAX_PLAYERS];
  15. forward Float:GetDistanceBetweenPlayers(p1,p2); // Not created by me, Dont know who made this.
  16. forward tazeroff(playerid);
  17. forward usetazeragain(playerid);
  18. #if defined FILTERSCRIPT
  19.  
  20. public OnFilterScriptInit()
  21. {
  22. print("\n--------------------------------------");
  23. print(" Tazer System By AlexzzPro Loaded");
  24. print("--------------------------------------\n");
  25. return 1;
  26. }
  27. #endif
  28. public OnFilterScriptExit()
  29. {
  30. print("\n--------------------------------------");
  31. print(" Tazer System By AlexzzPro Un-Loaded");
  32. print("--------------------------------------\n");
  33. return 1;
  34. }
  35. public OnPlayerConnect(playerid)
  36. {
  37. tazeronbelt[playerid] = 1;
  38. return 1;
  39. }
  40.  
  41. public OnPlayerDisconnect(playerid, reason)
  42. {
  43. tazeronbelt[playerid] = 1;
  44. return 1;
  45. }
  46. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  47. {
  48. if(newkeys & KEY_FIRE)
  49. {
  50. if(tazeronbelt[playerid] == 0)
  51. {
  52. if(GetPlayerSkin(playerid) == 280 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 282 || GetPlayerSkin(playerid) == 283 || GetPlayerSkin(playerid) == 288 || GetPlayerSkin(playerid) == 284)
  53. {
  54. new tazervictim = GetClosestPlayer(playerid);
  55. new Float:health;
  56. if(GetPlayerSkin(tazervictim) == 280 || GetPlayerSkin(tazervictim) == 281 || GetPlayerSkin(tazervictim) == 282 || GetPlayerSkin(tazervictim) == 283 || GetPlayerSkin(tazervictim) == 288 || GetPlayerSkin(tazervictim) == 284)
  57. {
  58. SendClientMessage(playerid, GREEN, "You cant tazer other cops");
  59. return 1;
  60. }
  61. if(tazertimer[playerid] == 1)
  62. {
  63. SendClientMessage(playerid, GREEN, "Please wait before tazing again");
  64. return 1;
  65. }
  66. if(GetDistanceBetweenPlayers(playerid,tazervictim) < 2)
  67. {
  68. ApplyAnimation(playerid,"KNIFE","knife_3",4.1,0,1,1,0,0,1);
  69. TogglePlayerControllable(tazervictim, 0);
  70. ApplyAnimation(tazervictim, "PED","FLOOR_hit_f", 4.0, 1, 0, 0, 0, 0);
  71. GetPlayerHealth(tazervictim, health);
  72. SetPlayerHealth(tazervictim, health - 2);
  73. SendClientMessage(tazervictim, GREEN, "You have been tazed for 20 seconds");
  74. SetTimerEx("tazeroff", 20000, false, "i", tazervictim);
  75. SetTimerEx("usetazeragain", 9000, false, "i", playerid);
  76. tazertimer[playerid] = 1;
  77. }
  78. }
  79. return 1;
  80. }
  81. }
  82. return 1;
  83. }
  84. public usetazeragain(playerid)
  85. {
  86. tazertimer[playerid] = 0;
  87. return 1;
  88. }
  89. public tazeroff(playerid)
  90. {
  91. new tazervictim = GetClosestPlayer(playerid);
  92. TogglePlayerControllable(tazervictim, 1);
  93. SendClientMessage(playerid, GREEN, "You have been un-tazed");
  94. return 1;
  95. }
  96. CMD:tazer(playerid,params[])
  97. {
  98. if(IsPlayerConnected(playerid))
  99. {
  100. if(GetPlayerSkin(playerid) == 280 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 282 || GetPlayerSkin(playerid) == 283 || GetPlayerSkin(playerid) == 288 || GetPlayerSkin(playerid) == 284)
  101. {
  102. if(tazeronbelt[playerid] == 1)
  103. {
  104. tazeronbelt[playerid] = 0;
  105. SetPlayerAttachedObject(playerid, 0, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0);
  106. SendClientMessage(playerid,GREEN,"Your tazer has been un-holsterd");
  107. }
  108. else if(tazeronbelt[playerid] == 0)
  109. {
  110. tazeronbelt[playerid] = 1;
  111. RemovePlayerAttachedObject(playerid, 0);
  112. SendClientMessage(playerid,GREEN, "Your tazer has been holsterd");
  113. }
  114. else
  115. {
  116. SendClientMessage(playerid, GREEN, "You are not connected");
  117. }
  118. }
  119. else
  120. {
  121. SendClientMessage(playerid, GREEN, "You are not a cop");
  122. }
  123. return 1;
  124. }
  125. return 1;
  126. }
  127. stock GetClosestPlayer(playerid) // Not created by me, Dont know who made this.
  128. {
  129. new Float:cdist, targetid = -1;
  130. for(new i; i<MAX_PLAYERS; i++)
  131. {
  132. if (IsPlayerConnected(i) && playerid != i && (targetid < 0 || cdist > GetDistanceBetweenPlayers(playerid, i)))
  133. {
  134. targetid = i;
  135. cdist = GetDistanceBetweenPlayers(playerid, i);
  136. }
  137. }
  138. return targetid;
  139. }
  140. public Float:GetDistanceBetweenPlayers(p1,p2) // Not created by me, Dont know who made this.
  141. {
  142. new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  143. if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
  144. {
  145. return -1.00;
  146. }
  147. GetPlayerPos(p1,x1,y1,z1);
  148. GetPlayerPos(p2,x2,y2,z2);
  149. return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  150. }
Advertisement
Add Comment
Please, Sign In to add comment