Advertisement
Fr3ak

Taze System

Aug 8th, 2011
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. ////////////////////////////////////////////////////////////////////////////////
  3. ////////////////////////////////////////////////////////////////////////////////
  4. //////////////////////////////Taze System///////////////////////////////////////
  5. //////////////////////////Scripted by Fr3ak/////////////////////////////////////
  6. ///////////////////////Leave me in the Credits//////////////////////////////////
  7. ////////////////////////////////////////////////////////////////////////////////
  8. ////////////////////////////////////////////////////////////////////////////////
  9. ////////////////////////////////////////////////////////////////////////////////
  10.  
  11. #include <a_samp>
  12.  
  13. #define filterscript
  14.  
  15. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) rreturn 1
  16. //-------------- EDIT BELOW THIS LINE --------------
  17. #define COLOR_KILLED 0x880000FF //The color, when a player gets killed by tazing
  18. #define COLOR_ERROR 0xFF0000AA //The color the of the message, when an error occurs
  19. #define COLOR_MSG 0x00FFFFFF //Color of general messages
  20. #define STUNNED_TIME 4 //The time in seconds the stun lasts
  21. #define ANTISPAM 5 //The minimum allowed time between /taze commands
  22. //-----------------NO NEED TO EDIT BELOW THIS LINE -----------------
  23.  
  24. new stunned[MAX_PLAYERS];
  25. new tazetime[MAX_PLAYERS];
  26.  
  27. stock ReturnPlayerName(ID)
  28. {
  29. new name[25];
  30. GetPlayerName(ID, name, 25);
  31. return name;
  32. }
  33.  
  34.  
  35. stock Float:GetDistanceBetweenPlayers(p1,p2)
  36. {
  37. new Float:x1,Float:y1,Float:z1,Float:x3,Float:y3,Float:z3;
  38. if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
  39. {
  40. return -1.00;
  41. }
  42. GetPlayerPos(p1,x1,y1,z1);
  43. GetPlayerPos(p2,x3,y3,z3);
  44. return floatsqroot(floatpower(floatabs(floatsub(x3,x1)),2)+floatpower(floatabs(floatsub(y3,y1)),2)+floatpower(floatabs(floatsub(z3,z1)),2));
  45. }
  46.  
  47. forward stuntimer(taze);
  48. forward tazetimer(i);
  49.  
  50. dcmd_taze(playerid, params[])
  51. {
  52. new taze = strval(params);
  53. if(!strlen(params))
  54. {
  55. SendClientMessage(playerid, COLOR_ERROR, "USAGE: /taze [ID]");
  56. }
  57. else
  58. {
  59. if(IsPlayerConnected(taze))
  60. {
  61. if(GetDistanceBetweenPlayers(playerid, taze) <= 6)
  62. {
  63. if(tazetime[playerid] == 0)
  64. {
  65. new tehtaze = random(5);
  66. if(tehtaze == 1 || tehtaze == 2 || tehtaze == 3 || tehtaze == 4)
  67. {
  68. new string[256], Float:thlth;
  69. format(string, sizeof(string), "%s (%i) has tazed you.",ReturnPlayerName(playerid), playerid);
  70. SendClientMessage(taze, COLOR_MSG, string);
  71. format(string, sizeof(string), "You have tazed %s (%i).",ReturnPlayerName(taze), taze);
  72. SendClientMessage(playerid, COLOR_MSG, string);
  73. GetPlayerHealth(taze, thlth);
  74. new Float:tehtaze3 = thlth-15-random(30);
  75. SetPlayerHealth(taze, tehtaze3);
  76. if(thlth < tehtaze3)
  77. {
  78. format(string, sizeof(string), "%s (%i) has been tazed to death", ReturnPlayerName(taze), taze);
  79. SendClientMessageToAll(COLOR_KILLED, string);
  80. }
  81. else
  82. {
  83. SendClientMessage(taze, COLOR_MSG, "You are stunned for a while.");
  84. TogglePlayerControllable(taze, 0);
  85. stunned[taze] = 1;
  86. tazetime[playerid] = 1;
  87. SetTimerEx("tazetimer", ANTISPAM*1000, 0, "i", playerid);
  88. SetTimerEx("stuntimer", STUNNED_TIME*1000, 0, "i", taze);
  89. }
  90. }
  91. else
  92. {
  93. new string[256], Float:phlth;
  94. format(string, sizeof(string), "%s (%i) has accidentally held the tazer the wrong way and tazed himself",ReturnPlayerName(playerid), playerid);
  95. SendClientMessage(taze, COLOR_MSG, string);
  96. SendClientMessage(playerid, COLOR_MSG, "You accidentally held the tazer the wrong way and tazed yourself");
  97. GetPlayerHealth(playerid, phlth);
  98. new Float:tehtaze2 = phlth-25-random(30);
  99. SetPlayerHealth(playerid, tehtaze2);
  100. if(phlth < tehtaze2)
  101. {
  102. format(string, sizeof(string), "%s (%i) has been tazed to death",ReturnPlayerName(playerid), playerid);
  103. SendClientMessageToAll(COLOR_KILLED, string);
  104. }
  105. else
  106. {
  107. SendClientMessage(playerid, COLOR_MSG, "You are stunned for a while.");
  108. TogglePlayerControllable(playerid, 0);
  109. stunned[playerid] = 1;
  110. SetTimerEx("stuntimer", STUNNED_TIME*1000, 0, "i", playerid);
  111. SetTimerEx("tazetimer", ANTISPAM*1000, 0, "i", playerid);
  112. tazetime[playerid] = 1;
  113. }
  114. }
  115. }
  116. else
  117. {
  118. SendClientMessage(playerid, COLOR_MSG, "Please wait before tazing someone again!");
  119. }
  120. }
  121. else
  122. {
  123. new string[256];
  124. format(string, sizeof(string), "%s (%i) is not close enough to taze!", ReturnPlayerName(taze), taze);
  125. }
  126. }
  127. else
  128. {
  129. SendClientMessage(playerid, COLOR_MSG, "That player is not connected!");
  130. }
  131. }
  132. return 1;
  133. }
  134.  
  135. public OnPlayerCommandText(playerid, cmdtext[])
  136. {
  137. dcmd(taze, 4, cmdtext);
  138. return 0;
  139. }
  140.  
  141. public stuntimer(taze)
  142. {
  143. stunned[taze] = 0;
  144. TogglePlayerControllable(taze, 1);
  145. SendClientMessage(taze, COLOR_MSG, "You have recovered from the tazer-shock");
  146. }
  147. public tazetimer(i)
  148. {
  149. tazetime[i] = 0;
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement