Advertisement
Guest User

Untitled

a guest
Dec 12th, 2013
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.41 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #include <zcmd>
  4. #include <CopTools>
  5. //________Colors_________
  6. #define GREEN 0x21DD00FF
  7.  
  8. //________Dialogs________
  9. #define POLICE 8000
  10. #define POLICE2 8001
  11. #define POLICE3 8002
  12.  
  13. //________Random Shit_________
  14. new Tazer[MAX_PLAYERS];
  15. new CantUseTazer[MAX_PLAYERS];
  16. forward Float:GetDistanceBetweenPlayers(p1,p2);
  17. forward TazerFade(playerid);
  18. forward TazerOn(playerid);
  19. new Float:x, Float:y, Float:z;
  20.  
  21.  
  22. public OnFilterScriptInit()
  23. {
  24. print("\n--------------------------------------");
  25. print(" Police Panel by [SWE]Alexzz");
  26. print("--------------------------------------\n");
  27. return 1;
  28. }
  29.  
  30. public OnFilterScriptExit()
  31. {
  32. print("\n--------------------------------------");
  33. print(" Police Panel by [SWE]Alexzz unloaded");
  34. print("--------------------------------------\n");
  35. return 1;
  36. }
  37.  
  38.  
  39. public OnPlayerConnect(playerid)
  40. {
  41. Tazer[playerid] = 0;
  42. CantUseTazer[playerid] = 0;
  43. return 1;
  44. }
  45.  
  46. public OnPlayerDisconnect(playerid, reason)
  47. {
  48. Tazer[playerid] = 0;
  49. CantUseTazer[playerid] = 0;
  50. return 1;
  51. }
  52.  
  53. public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
  54. {
  55. if(Tazer[playerid] == 1 && GetPlayerWeapon(playerid) == 23)
  56. {
  57. new Float:health;
  58. GetPlayerHealth(damagedid,health);
  59. if(CantUseTazer[playerid] == 1)
  60. {
  61. SendClientMessage(playerid, GREEN, "Please wait before using your tazer again!");
  62. return 1;
  63. }
  64. GetPlayerPos(damagedid, x, y, z);
  65. TogglePlayerControllable(damagedid, 0);
  66. SetPlayerHealth(damagedid, health - 2);
  67. SendClientMessage(damagedid, GREEN, "You have been tazed for 20 seconds");
  68. SetTimerEx("TazerFade", 20000, false, "i", damagedid);
  69. SetTimerEx("TazerOn", 9000, false, "i", playerid);
  70. CantUseTazer[playerid] = 1;
  71. }
  72. return 1;
  73. }
  74. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  75. {
  76. if(newkeys & KEY_FIRE)
  77. {
  78. if(Tazer[playerid] == 2)
  79. {
  80. new tazervictim = GetClosestPlayer(playerid);
  81. new Float:health;
  82. if(CantUseTazer[playerid] == 1)
  83. {
  84. SendClientMessage(playerid, GREEN, "Please wait before using your tazer again!");
  85. return 1;
  86. }
  87. if(GetDistanceBetweenPlayers(playerid,tazervictim) < 2)
  88. {
  89. ApplyAnimation(playerid,"KNIFE","knife_3",4.1,0,1,1,0,0,1);
  90. TogglePlayerControllable(tazervictim, 0);
  91. ApplyAnimation(tazervictim, "PED","FLOOR_hit_f", 4.0, 1, 0, 0, 0, 0);
  92. GetPlayerHealth(tazervictim, health);
  93. SetPlayerHealth(tazervictim, health - 2);
  94. SendClientMessage(tazervictim, GREEN, "You have been tazed for 20 seconds");
  95. SetTimerEx("TazerFade", 20000, false, "i", tazervictim);
  96. SetTimerEx("TazerOn", 9000, false, "i", playerid);
  97. CantUseTazer[playerid] = 1;
  98. }
  99. }
  100. return 1;
  101. }
  102. return 1;
  103. }
  104. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  105. {
  106. if(dialogid == POLICE)
  107. {
  108. if(response)
  109. {
  110. if(listitem == 0)
  111. {
  112. ShowPlayerDialog(playerid, POLICE2, DIALOG_STYLE_MSGBOX, "Riot Shield","Do you wish to put your riot shield on the back or on your arm?","Back","Arm");
  113. }
  114. if(listitem == 1)
  115. {
  116. GiveFlashLight(playerid);
  117. SendClientMessage(playerid, GREEN, "Flashlight has been attached");
  118. }
  119. if(listitem == 2)
  120. {
  121. ShowPlayerDialog(playerid, POLICE3, DIALOG_STYLE_MSGBOX, "Tazer","Do you want a ranged or melee tazer?","Ranged","Melee");
  122. }
  123. if(listitem == 3)
  124. {
  125. RemoveItems(playerid);
  126. SendClientMessage(playerid, GREEN, "All items have been deattached");
  127. Tazer[playerid] = 0;
  128. }
  129. }
  130. if(dialogid == POLICE3)
  131. {
  132. if(response)
  133. {
  134. SendClientMessage(playerid, GREEN, "Ranged tazer has been given to you!");
  135. GivePlayerWeapon(playerid,23,10);
  136. Tazer[playerid] = 1;
  137. }
  138. if(!response)
  139. {
  140. GiveTazer(playerid);
  141. SendClientMessage(playerid, GREEN, "Melee tazer has been given to you!");
  142. Tazer[playerid] = 2;
  143. }
  144. }
  145. if(dialogid == POLICE2)
  146. {
  147. if(response)
  148. {
  149. PutRiotShieldOnBack(playerid);
  150. SendClientMessage(playerid, GREEN, "Riot Shield have been attached to your back!");
  151. }
  152. if(!response)
  153. {
  154. PutRiotShieldOnArm(playerid);
  155. SendClientMessage(playerid, GREEN, "Riot Shield have been attached to your arm!");
  156. }
  157. }
  158. }
  159. return 1;
  160. }
  161.  
  162. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  163. {
  164. return 1;
  165. }
  166.  
  167. CMD:police(playerid, params[])
  168. {
  169. if(IsPlayerConnected(playerid))
  170. {
  171. if(GetPlayerSkin(playerid) == 280 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 282 || GetPlayerSkin(playerid) == 283 || GetPlayerSkin(playerid) == 288 || GetPlayerSkin(playerid) == 284)
  172. {
  173. ShowPlayerDialog(playerid, POLICE, DIALOG_STYLE_LIST, "Police Panel","Riot Shield\nFlashlight\nTazer\nRemove Items","Choose","Close");
  174. }
  175. else
  176. {
  177. SendClientMessage(playerid, GREEN, "You are not connected");
  178. }
  179. }
  180. else
  181. {
  182. SendClientMessage(playerid, GREEN, "You need to be a cop to use that command!");
  183. }
  184. return 1;
  185. }
  186. public TazerOn(playerid)
  187. {
  188. CantUseTazer[playerid] = 0;
  189. return 1;
  190. }
  191. public TazerFade(playerid)
  192. {
  193. new tazervictim = GetClosestPlayer(playerid);
  194. TogglePlayerControllable(tazervictim, 1);
  195. SendClientMessage(playerid, GREEN, "Tazer effect has been removed");
  196. return 1;
  197. }
  198.  
  199. stock GetClosestPlayer(playerid)
  200. {
  201. new Float:cdist, targetid = -1;
  202. for(new i; i<MAX_PLAYERS; i++)
  203. {
  204. if (IsPlayerConnected(i) && playerid != i && (targetid < 0 || cdist > GetDistanceBetweenPlayers(playerid, i)))
  205. {
  206. targetid = i;
  207. cdist = GetDistanceBetweenPlayers(playerid, i);
  208. }
  209. }
  210. return targetid;
  211. }
  212. public Float:GetDistanceBetweenPlayers(p1,p2)
  213. {
  214. new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  215. if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
  216. {
  217. return -1.00;
  218. }
  219. GetPlayerPos(p1,x1,y1,z1);
  220. GetPlayerPos(p2,x2,y2,z2);
  221. return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement