Guest User

Untitled

a guest
Jan 18th, 2015
1,749
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. #define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <sscanf2>
  7. #include <zcmd>
  8. #include <YSI\y_ini>
  9.  
  10. //========================Enum====================//
  11. enum pInfo
  12. {
  13. pPolice
  14. };
  15. new PlayerInfo[MAX_PLAYERS][pInfo];
  16. //====================Defines===================//
  17. #define PATH "/police/%s.ini"
  18. #define COLOR_RED 0xFF0000AA
  19. #define COLOR_WHITE 0xFFFFFFAA
  20. #define COLOR_YELLOW 0xFFFF00AA
  21. #define COLOR_GREEN 0x00FF00CE
  22. new JailTimer[MAX_PLAYERS];
  23. new bool:inJail[MAX_PLAYERS];
  24. //============================================//
  25.  
  26.  
  27. #if defined FILTERSCRIPT
  28.  
  29. public OnFilterScriptInit()
  30. {
  31. print("\n--------------------------------------");
  32. print(" Police System By Ahmed_Nezoo ");
  33. print("--------------------------------------\n");
  34. return 1;
  35. }
  36.  
  37. stock UserPath(targetid)
  38. {
  39. new string[128],playername[MAX_PLAYER_NAME];
  40. GetPlayerName(targetid,playername,sizeof(playername));
  41. format(string,sizeof(string),PATH,playername);
  42. return string;
  43. }
  44. stock LoadLevel(name[],value[],playerid)
  45. {
  46. new file[60];
  47. format(file,sizeof(file),"/police/%s.ini",playerid);
  48. INI_Open(file);
  49. return 1;
  50. }
  51.  
  52.  
  53. public OnPlayerConnect(playerid)
  54. {
  55. LoadLevel("Police",PlayerInfo[playerid][pPolice],playerid);
  56. return 1;
  57. }
  58.  
  59.  
  60. public OnPlayerDisconnect(playerid, reason)
  61. {
  62. new INI:File = INI_Open(UserPath(playerid));
  63. INI_SetTag(File,"data");
  64. INI_WriteInt(File,"Police",PlayerInfo[playerid][pPolice]);
  65. INI_Close(File);
  66. return 1;
  67. }
  68.  
  69. stock PlayerName(id)
  70. {
  71. new name[MAX_PLAYER_NAME];
  72. GetPlayerName(id, name, MAX_PLAYER_NAME);
  73. return name;
  74. }
  75.  
  76. CMD:makepolice(playerid, params[])
  77. {
  78. new targetid, level, string[128];
  79. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You aren't the RCON admin !");
  80. if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
  81. if(sscanf(params,"ui",targetid, level)) return SendClientMessage(playerid, -1, "Make a police officer: /makepolice [ID] (level)");
  82. PlayerInfo[targetid][pPolice] = level;
  83. new INI:File = INI_Open(UserPath(playerid));
  84. INI_SetTag(File,"data");
  85. INI_WriteInt(File,"Police",PlayerInfo[playerid][pPolice]);
  86. INI_Close(File);
  87. if(level > 8 || level < 0) return SendClientMessage(playerid, COLOR_RED, "Police level can't be less than 0 or more than 8");
  88. if(level == 0)
  89. {
  90. format(string,sizeof(string),"%s has set %s police level to: None", PlayerName(playerid), PlayerName(targetid));
  91. SendClientMessageToAll(COLOR_RED,string);
  92. SetPlayerSkin(targetid, 0);
  93. }
  94. else if(level == 1)
  95. {
  96. format(string,sizeof(string),"%s has employed %s as a: Police Officer", PlayerName(playerid), PlayerName(targetid));
  97. SendClientMessageToAll(COLOR_RED,string);
  98. SetPlayerSkin(targetid, 280);
  99. }
  100. else if(level == 2)
  101. {
  102. format(string,sizeof(string),"%s has employed %s as an: Investigator", PlayerName(playerid), PlayerName(targetid));
  103. SendClientMessageToAll(COLOR_RED,string);
  104. SetPlayerSkin(targetid, 284);
  105. }
  106. else if(level == 3)
  107. {
  108. format(string,sizeof(string),"%s has employed %s as a: Sergeant", PlayerName(playerid), PlayerName(targetid));
  109. SendClientMessageToAll(COLOR_RED,string);
  110. SetPlayerSkin(targetid, 165);
  111. }
  112. else if(level == 4)
  113. {
  114. format(string,sizeof(string),"%s has employed %s as a: Lieutenant", PlayerName(playerid), PlayerName(targetid));
  115. SendClientMessageToAll(COLOR_RED,string);
  116. SetPlayerSkin(targetid, 166);
  117. }
  118. else if(level == 5)
  119. {
  120. format(string,sizeof(string),"%s has employed %s as a: Major", PlayerName(playerid), PlayerName(targetid));
  121. SendClientMessageToAll(COLOR_RED,string);
  122. SetPlayerSkin(targetid, 282);
  123. }
  124. else if(level == 6)
  125. {
  126. format(string,sizeof(string),"%s has employed %s as a: Captain", PlayerName(playerid), PlayerName(targetid));
  127. SendClientMessageToAll(COLOR_RED,string);
  128. SetPlayerSkin(targetid, 286);
  129. }
  130. else if(level == 7)
  131. {
  132. format(string,sizeof(string),"%s has employed %s as a: Commander", PlayerName(playerid), PlayerName(targetid));
  133. SendClientMessageToAll(COLOR_RED,string);
  134. SetPlayerSkin(targetid, 287);
  135. }
  136. else if(level == 8)
  137. {
  138. format(string,sizeof(string),"%s has employed %s as a: Commissioner", PlayerName(playerid), PlayerName(targetid));
  139. SendClientMessageToAll(COLOR_RED,string);
  140. SetPlayerSkin(targetid, 285);
  141. }
  142. return 1;
  143. }
  144.  
  145.  
  146. CMD:cuff(playerid, params[])
  147. {
  148. new targetid;
  149. if(PlayerInfo[playerid][pPolice] == 0) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
  150. if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /cuff [id]");
  151. if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
  152. if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is inside a vehicle you can't cuff him");
  153. new Float:x, Float:y, Float:z;
  154. GetPlayerPos(targetid, x, y, z);
  155. if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
  156. {
  157. SetPlayerAttachedObject(targetid, 0, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000);
  158. SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
  159. SendClientMessage(targetid, COLOR_YELLOW, "You get cuffed by a police officer");
  160. }
  161. else
  162. {
  163. SendClientMessage(playerid, COLOR_RED, "This player is too far away !");
  164. }
  165. return 1;
  166. }
  167.  
  168. CMD:uncuff(playerid, params[])
  169. {
  170. new targetid;
  171. if(PlayerInfo[playerid][pPolice] == 0) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
  172. if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /uncuff [id]");
  173. if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Thhis player is not connected");
  174. if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is inside a vehicle you can't uncuff him");
  175. new Float:x, Float:y, Float:z;
  176. GetPlayerPos(targetid, x, y, z);
  177. if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
  178. {
  179. if(!IsPlayerAttachedObjectSlotUsed(targetid, 0))return SendClientMessage(playerid, COLOR_RED,"This player is not cuffed");
  180. SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);
  181. SendClientMessage(targetid, COLOR_YELLOW, "You get uncuffed by a police officer");
  182. RemovePlayerAttachedObject(targetid, 0);
  183. }
  184. else
  185. {
  186. SendClientMessage(playerid, COLOR_RED, "This player is too far away !");
  187. }
  188. return 1;
  189. }
  190.  
  191. CMD:pfreeze(playerid, params[])
  192. {
  193. new targetid;
  194. if(PlayerInfo[playerid][pPolice] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
  195. if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /freeze [id]");
  196. if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Thhis player is not connected");
  197. if(!IsPlayerAttachedObjectSlotUsed(targetid, 0))return SendClientMessage(playerid, COLOR_RED,"This player is not cuffed");
  198. if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is inside a vehicle you can't freeze him");
  199. new Float:x, Float:y, Float:z;
  200. GetPlayerPos(targetid, x, y, z);
  201. if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) return SendClientMessage(playerid, COLOR_RED, "This player is too far away");
  202. TogglePlayerControllable(targetid,0);
  203. return 1;
  204. }
  205.  
  206. CMD:punfreeze(playerid, params[])
  207. {
  208. new targetid;
  209. if(PlayerInfo[playerid][pPolice] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
  210. if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /freeze [id]");
  211. if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Thhis player is not connected");
  212. if(!IsPlayerAttachedObjectSlotUsed(targetid, 0))return SendClientMessage(playerid, COLOR_RED,"This player is not cuffed");
  213. if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is inside a vehicle you can't unfreeze him");
  214. new Float:x, Float:y, Float:z;
  215. GetPlayerPos(targetid, x, y, z);
  216. if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) return SendClientMessage(playerid, COLOR_RED, "This player is too far away");
  217. TogglePlayerControllable(targetid,1);
  218. return 1;
  219. }
  220.  
  221.  
  222. CMD:jail(playerid, params[])
  223. {
  224. if(PlayerInfo[playerid][pPolice] >= 1)
  225. {
  226. new targetid, minutes;
  227. if(sscanf(params, "ri", targetid, minutes)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /jail [playerid] (Time)");
  228. if(minutes <= 0 || minutes >= 16) return SendClientMessage(playerid, COLOR_RED, "Minutes can't be less than 0 or more than 15");
  229. new Float:x, Float:y, Float:z;
  230. GetPlayerPos(targetid, x, y, z);
  231. if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) return SendClientMessage(playerid, COLOR_RED, "This player is too far away");
  232. if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is inside a vehicle you can't jail him");
  233. if(!IsPlayerAttachedObjectSlotUsed(targetid, 0))return SendClientMessage(playerid, COLOR_RED,"This player is not cuffed");
  234. else
  235. {
  236. new str[128];
  237. format(str, sizeof(str), "%s jailed by %s for %d minutes", PlayerName(targetid), PlayerName(playerid), minutes);
  238. SendClientMessageToAll(COLOR_RED, str);
  239. SetPlayerInterior(targetid, 6);
  240. SetPlayerVirtualWorld(targetid, 10);
  241. SetPlayerFacingAngle(targetid, 360.0);
  242. SetPlayerPos(targetid, 264.5485,77.8464,1001.3657);
  243. SetPlayerHealth(targetid, 9999999999.0);
  244. ResetPlayerWeapons(targetid);
  245. JailTimer[targetid] = SetTimerEx("Unjail",minutes*60000, false, "i", targetid);//jail timer
  246. TogglePlayerControllable(targetid,1);
  247. RemovePlayerAttachedObject(targetid, 0);
  248. SetPlayerScore(playerid, GetPlayerScore(playerid)+2);
  249. }
  250. }
  251. else
  252. {
  253. SendClientMessage(playerid, COLOR_RED, "You can't use this command");
  254. }
  255. return 1;
  256. }
  257.  
  258. forward Unjail(playerid);
  259. public Unjail(playerid)
  260. {
  261. SetPlayerInterior(playerid, 0);
  262. SetPlayerVirtualWorld(playerid, 0);
  263. SetPlayerPos(playerid,1545.7330,-1675.2095,13.5609);
  264. SetPlayerHealth(playerid, 100);
  265. GameTextForPlayer(playerid, "~p~Unjailed", 10000, 6);
  266. }
  267.  
  268. public OnPlayerSpawn(playerid)
  269. {
  270. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  271. if(PlayerInfo[playerid][pPolice] == 1)
  272. {
  273. SetPlayerSkin(playerid, 280);
  274. GivePlayerWeapon(playerid, 26, 100);
  275. SetPlayerArmour(playerid, 20);
  276. GivePlayerWeapon(playerid, 22, 100);
  277. GivePlayerWeapon(playerid, 28, 1000);
  278. GivePlayerWeapon(playerid, 31, 1000);
  279. GivePlayerWeapon(playerid, 34, 30);
  280. }
  281. else if(PlayerInfo[playerid][pPolice] == 2)
  282. {
  283. SetPlayerSkin(playerid, 284);
  284. GivePlayerWeapon(playerid, 26, 500);
  285. SetPlayerArmour(playerid, 40);
  286. GivePlayerWeapon(playerid, 22, 500);
  287. GivePlayerWeapon(playerid, 28, 2000);
  288. GivePlayerWeapon(playerid, 31, 2000);
  289. GivePlayerWeapon(playerid, 34, 50);
  290. }
  291. else if(PlayerInfo[playerid][pPolice] == 3)
  292. {
  293. SetPlayerSkin(playerid, 165);
  294. GivePlayerWeapon(playerid, 26, 700);
  295. SetPlayerArmour(playerid, 20);
  296. GivePlayerWeapon(playerid, 22, 700);
  297. GivePlayerWeapon(playerid, 28, 3000);
  298. GivePlayerWeapon(playerid, 31, 3000);
  299. GivePlayerWeapon(playerid, 34, 50);
  300. }
  301. else if(PlayerInfo[playerid][pPolice] == 4)
  302. {
  303. SetPlayerSkin(playerid, 166);
  304. GivePlayerWeapon(playerid, 26, 900);
  305. SetPlayerArmour(playerid, 20);
  306. GivePlayerWeapon(playerid, 22, 900);
  307. GivePlayerWeapon(playerid, 28, 5000);
  308. GivePlayerWeapon(playerid, 31, 5000);
  309. GivePlayerWeapon(playerid, 34, 50);
  310. }
  311. else if(PlayerInfo[playerid][pPolice] == 5)
  312. {
  313. SetPlayerSkin(playerid, 282);
  314. GivePlayerWeapon(playerid, 26, 1100);
  315. SetPlayerArmour(playerid, 20);
  316. GivePlayerWeapon(playerid, 22, 1100);
  317. GivePlayerWeapon(playerid, 28, 7000);
  318. GivePlayerWeapon(playerid, 31, 7000);
  319. GivePlayerWeapon(playerid, 34, 70);
  320. }
  321. else if(PlayerInfo[playerid][pPolice] == 6)
  322. {
  323. SetPlayerSkin(playerid, 286);
  324. GivePlayerWeapon(playerid, 26, 1300);
  325. SetPlayerArmour(playerid, 20);
  326. GivePlayerWeapon(playerid, 22, 1300);
  327. GivePlayerWeapon(playerid, 28, 9000);
  328. GivePlayerWeapon(playerid, 31, 9000);
  329. GivePlayerWeapon(playerid, 34, 90);
  330. }
  331. else if(PlayerInfo[playerid][pPolice] == 7)
  332. {
  333. SetPlayerSkin(playerid, 287);
  334. GivePlayerWeapon(playerid, 26, 1500);
  335. SetPlayerArmour(playerid, 20);
  336. GivePlayerWeapon(playerid, 22, 1500);
  337. GivePlayerWeapon(playerid, 28, 11000);
  338. GivePlayerWeapon(playerid, 31, 11000);
  339. GivePlayerWeapon(playerid, 34, 95);
  340. }
  341. else if(PlayerInfo[playerid][pPolice] == 8)
  342. {
  343. SetPlayerSkin(playerid, 285);
  344. GivePlayerWeapon(playerid, 26, 1700);
  345. SetPlayerArmour(playerid, 20);
  346. GivePlayerWeapon(playerid, 22, 1700);
  347. GivePlayerWeapon(playerid, 28, 13000);
  348. GivePlayerWeapon(playerid, 31, 13000);
  349. GivePlayerWeapon(playerid, 34, 100);
  350. }
  351. return 1;
  352. }
  353. public OnFilterScriptExit()
  354. {
  355. return 1;
  356. }
  357.  
  358. #endif
RAW Paste Data