Advertisement
Mciko123

[PAWN]Anti-Cheat

Dec 24th, 2016
3,068
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.23 KB | None | 0 0
  1. #include <a_samp>
  2. #include <foreach>
  3.  
  4. #define INFO(%0,%1) SCM(%0, 0x6EF83CFF, ""YELLOW"INFO | "WHITE" "%1)
  5. #define ERROR(%0,%1) SCM(%0, 0xF81414FF, ""RED"ERROR | "WHITE" "%1)
  6. #define USAGE(%0,%1) SCM(%0, 0xC0C0C0FF, ""GRAY"USAGE | "WHITE" "%1)
  7. #define SERVER(%0,%1) SCMTA(0xC0C0C0FF, ""SERVERBLUE"SERVER | "WHITE" "%1)
  8.  
  9. #define SPVW SetPlayerVirtualWorld
  10. #define SCMTA SendClientMessageToAll
  11. #define SCM SendClientMessage
  12. #define SPD ShowPlayerDialog
  13. #define SPP SetPlayerPos
  14. #define GPP GetPlayerPos
  15. #define SPH SetPlayerHealth
  16. #define GPH GetPlayerHealth
  17.  
  18. #define SERVERBLUE "{00A2D7}"
  19. #define WHITE "{FFFFFF}"
  20. #define YELLOW "{6EF83C}"
  21. #define GRAY "{C0C0C0}"
  22. #define RED "{F81414}"
  23. #define HGREEN "{04CC29}"
  24. #define OGREEN "{00D1AE}"
  25.  
  26. new ACTimer,
  27. AirBreak_Warn [MAX_PLAYERS],
  28. Float:AirBreak_Pos [MAX_PLAYERS][3],
  29. Float:Vehicle_Pos [MAX_VEHICLES][4],
  30. AirBreak_Speed [MAX_PLAYERS],
  31. AirBreak_Height [MAX_PLAYERS];
  32. RImmunity [MAX_PLAYERS],
  33. VehHP [MAX_PLAYERS],
  34.  
  35. veh_created = 0;
  36.  
  37. new Float:MaxVehSpeed[213] =
  38. {
  39. //MAX SPEED //ACCELERATION
  40. 160.0, //25.0
  41. 160.0, //15.0
  42. 200.0, //28.0
  43. 120.0, //25.0
  44. 150.0, //18.0
  45. 165.0, //24.0
  46. 110.0, //25.0
  47. 170.0, //27.0
  48. 110.0, //20.0
  49. 180.0, //18.0
  50. 160.0, //19.0
  51. 240.0, //30.0
  52. 160.0, //23.0
  53. 160.0, //15.0
  54. 140.0, //18.0
  55. 230.0, //30.0
  56. 155.0, //24.0
  57. 200.0, //16.0
  58. 150.0, //15.0
  59. 160.0, //18.0
  60. 180.0, //19.0
  61. 180.0, //21.0
  62. 165.0, //20.0
  63. 145.0, //14.0
  64. 170.0, //30.0
  65. 200.0, //16.0
  66. 200.0, //22.0
  67. 170.0, //20.0
  68. 170.0, //15.0
  69. 200.0, //33.0
  70. 190.0, //1.7
  71. 130.0, //14.0
  72. 80.0, //40.0
  73. 180.0, //20.0
  74. 200.0, //28.0
  75. 120.0, //18.0
  76. 160.0, //18.0
  77. 160.0, //18.0
  78. 160.0, //24.0
  79. 160.0, //23.0
  80. 160.0, //18.0
  81. 75.0, //35.0
  82. 150.0, //16.0
  83. 150.0, //13.0
  84. 110.0, //45.0
  85. 165.0, //22.0
  86. 190.0, //3.0
  87. 200.0, //16.0
  88. 190.0, //30.0
  89. 150.0, //25.0
  90. 120.0, //18.0
  91. 240.0, //30.0
  92. 190.0, //2.5
  93. 190.0, //0.7
  94. 190.0, //1.4
  95. 140.0, //25.0
  96. 160.0, //14.0
  97. 160.0, //15.0
  98. 165.0, //20.0
  99. 160.0, //15.0
  100. 200.0, //1.7
  101. 190.0, //50.0
  102. 190.0, //30.0
  103. 190.0, //40.0
  104. 75.0, //1.0
  105. 75.0, //35.0
  106. 160.0, //22.0
  107. 160.0, //16.0
  108. 190.0, //50.0
  109. 200.0, //16.0
  110. 170.0, //25.0
  111. 160.0, //25.0
  112. 190.0, //1.6
  113. 190.0, //1.2
  114. 160.0, //18.0
  115. 160.0, //24.0
  116. 200.0, //16.0
  117. 200.0, //28.0
  118. 150.0, //14.0
  119. 165.0, //16.0
  120. 200.0, //30.0
  121. 120.0, //18.0
  122. 150.0, //25.0
  123. 120.0, //16.0
  124. 190.0, //0.5
  125. 160.0, //20.0
  126. 100.0, //35.0
  127. 200.0, //16.0
  128. 200.0, //16.0
  129. 170.0, //20.0
  130. 170.0, //22.0
  131. 160.0, //18.0
  132. 160.0, //20.0
  133. 190.0, //3.0
  134. 220.0, //26.0
  135. 170.0, //28.0
  136. 200.0, //26.0
  137. 200.0, //16.0
  138. 140.0, //14.0
  139. 140.0, //14.0
  140. 160.0, //24.0
  141. 75.0, //35.0
  142. 220.0, //26.0
  143. 220.0, //26.0
  144. 160.0, //24.0
  145. 170.0, //20.0
  146. 230.0, //26.0
  147. 165.0, //20.0
  148. 140.0, //14.0
  149. 190.0, //50.0
  150. 190.0, //50.0
  151. 200.0, //16.0
  152. 200.0, //16.0
  153. 200.0, //16.0
  154. 120.0, //25.0
  155. 120.0, //25.0
  156. 165.0, //20.0
  157. 165.0, //22.0
  158. 160.0, //24.0
  159. 200.0, //16.0
  160. 200.0, //16.0
  161. 190.0, //50.0
  162. 190.0, //60.0
  163. 190.0, //50.0
  164. 110.0, //20.0
  165. 160.0, //25.0
  166. 160.0, //20.0
  167. 160.0, //20.0
  168. 170.0, //25.0
  169. 160.0, //18.0
  170. 60.0, //20.0
  171. 70.0, //20.0
  172. 140.0, //25.0
  173. 200.0, //28.0
  174. 160.0, //23.0
  175. 160.0, //40.0
  176. 160.0, //24.0
  177. 110.0, //20.0
  178. 110.0, //20.0
  179. 150.0, //2.0
  180. 160.0, //18.0
  181. 230.0, //30.0
  182. 160.0, //24.0
  183. 165.0, //25.0
  184. 170.0, //27.0
  185. 160.0, //22.0
  186. 160.0, //18.0
  187. 160.0, //18.0
  188. 200.0, //16.0
  189. 160.0, //24.0
  190. 160.0, //17.0
  191. 165.0, //22.0
  192. 160.0, //18.0
  193. 200.0, //16.0
  194. 170.0, //25.0
  195. 180.0, //30.0
  196. 110.0, //45.0
  197. 110.0, //45.0
  198. 200.0, //20.0
  199. 200.0, //28.0
  200. 200.0, //28.0
  201. 200.0, //20.0
  202. 200.0, //28.0
  203. 200.0, //16.0
  204. 75.0, //35.0
  205. 200.0, //24.0
  206. 160.0, //24.0
  207. 160.0, //24.0
  208. 170.0, //35.0
  209. 110.0, //20.0
  210. 110.0, //20.0
  211. 90.0, //18.0
  212. 60.0, //12.0
  213. 110.0, //35.0
  214. 60.0, //12.0
  215. 160.0, //20.0
  216. 160.0, //20.0
  217. 200.0, //16.0
  218. 110.0, //20.0
  219. 160.0, //25.0
  220. 165.0, //24.0
  221. 190.0, //50.0
  222. 160.0, //15.0
  223. 170.0, //15.0
  224. 120.0, //18.0
  225. 165.0, //21.0
  226. 190.0, //40.0
  227. 200.0, //24.0
  228. 140.0, //14.0
  229. 200.0, //30.0
  230. 110.0, //20.0
  231. 120.0, //18.0
  232. 200.0, //16.0
  233. 200.0, //16.0
  234. 60.0, //50.0
  235. 190.0, //1.5
  236. 200.0, //25.0
  237. 200.0, //25.0
  238. 200.0, //25.0
  239. 160.0, //30.0
  240. 165.0, //25.0
  241. 110.0, //24.0
  242. 200.0, //23.0
  243. 200.0, //26.0
  244. 0.0, //0.0
  245. 0.0, //0.0
  246. 160.0, //20.0
  247. 160.0, //20.0
  248. 160.0, //20.0
  249. 140.0, //14.0
  250. 160.0, //20.0
  251. 60.0, //20.0
  252. };
  253.  
  254. public OnGameModeInit()
  255. {
  256. ACTimer = SetTimer("AntiCheat", 1000, true);
  257. return 1;
  258. }
  259.  
  260. public OnGameModeExit()
  261. {
  262. KillTimer(ACTimer);
  263. return 1;
  264. }
  265.  
  266. public OnPlayerConnect(playerid)
  267. {
  268. AirBreak_Warn[playerid] = 0;
  269. AirBreak_Speed[playerid] = 0;
  270. AirBreak_Height[playerid] = 0;
  271. return 1;
  272. }
  273.  
  274. public OnPlayerStateChange(playerid, newstate, oldstate)
  275. {
  276. AirBreak_Speed[playerid] = 0;
  277. GetPlayerPos(playerid, AirBreak_Pos[playerid][0], AirBreak_Pos[playerid][0], AirBreak_Pos[playerid][0]);
  278. return 1;
  279. }
  280.  
  281. public OnVehicleSpawn(vehicleid)
  282. {
  283. m_SetVehicleHealth(vehicleid, 999.0);
  284. return 1;
  285. }
  286.  
  287. forward AntiCheat();
  288. public AntiCheat()
  289. {
  290. foreach(new i: Player)
  291. {
  292. if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
  293. {
  294. new Float:X, Float:Y, Float:Z;
  295. GetPlayerVelocity(i, X, Y, Z);
  296. if(floatround(X) > 0 || floatround(Y) > 0 || floatround(Z) > 0)
  297. {
  298. SCM(i, -1, ""RED"CHEAT | "WHITE"You have been kicked for using speed hack (ON-FOOT)");
  299. new string[128];
  300. format(string, sizeof(string), ""SERVERBLUE"SERVER | "WHITE"Player %s has been kicked for using speed hack (ON-FOOT)!", GetName(i));
  301. SCMTA(-1, string);
  302. DelayedKick(i);
  303. return 1;
  304. }
  305. }
  306. if(!IsPlayerNPC(i))
  307. {
  308. new speed, time = GetTickCount(), string[128];
  309. if(GetPlayerSurfingVehicleID(i) == INVALID_VEHICLE_ID && GetPlayerSurfingObjectID(i) == INVALID_OBJECT_ID && GetPlayerPing(i) < 260 && GetSpeed(i) < 30 && (GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_ONFOOT))
  310. {
  311. speed = floatround((GetPlayerDistanceFromPoint(i, AirBreak_Pos[i][0], AirBreak_Pos[i][1], AirBreak_Pos[i][2]) / float (time - AirBreak_Height[i])) * 1000.0);
  312. GetPlayerPos(i, AirBreak_Pos[i][0], AirBreak_Pos[i][1], AirBreak_Pos[i][2]);
  313. if(speed > 65 && AirBreak_Speed[i] > 65)
  314. {
  315. AirBreak_Warn[i] ++;
  316. if(AirBreak_Warn[i] < 3)
  317. {
  318. format(string, sizeof(string), ""RED"CHEAT | "WHITE"Player %s might be using AIRBREAK", GetName(i));
  319. AdminMessage(-1, string);
  320. AirBreak_Speed[i] = 0;
  321. }
  322. else
  323. {
  324. SCM(i, -1, ""RED"CHEAT | "WHITE"You have been kicked for using Airbreak");
  325. format(string, sizeof(string), ""SERVERBLUE"SERVER | "WHITE"Player %s has been kicked for using Airbreak", GetName(i));
  326. SCMTA(-1, string);
  327. DelayedKick(i);
  328. return 1;
  329. }
  330. }
  331. AirBreak_Speed[i] = speed;
  332. }
  333. else
  334. {
  335. GetPlayerPos(i, AirBreak_Pos[i][0], AirBreak_Pos[i][1], AirBreak_Pos[i][2]);
  336. AirBreak_Speed[i] = 0;
  337. }
  338. AirBreak_Height[i] = time;
  339. }
  340. }
  341. if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
  342. {
  343. SetTimer("FallingChecker", 1000, true);
  344. new vid = GetPlayerVehicleID(i), mid = GetVehicleModel(vid), Float:speed = GetSpeed(i);
  345. if(speed > MaxVehSpeed[mid - 400] && MaxVehSpeed[mid - 400] > 35) //change value 35 if you want. THis means if max speed of veh is 200. If player goes 235 it will detect him..
  346. {
  347. SCM(i, -1, ""RED"CHEAT | "WHITE"You have been kicked for using speed hack (IN-VEHICLE)");
  348. new string[128];
  349. format(string, sizeof(string), ""SERVERBLUE"SERVER | "WHITE"Player %s has been kicked for using speed hack (IN-VEHICLE)!", GetName(i));
  350. SCMTA(-1, string);
  351. DelayedKick(i);
  352. return 1;
  353. }
  354. }
  355. if(GetPlayerState(i) == PLAYER_STATE_DRIVER && GetPlayerPing(i) < 260)
  356. {
  357. new Float:vhp;
  358. GetVehicleHealth(GetPlayerVehicleID(i), vhp);
  359. if(NearTuning(i) || NearSpray(i))
  360. {
  361. if(vhp > 999.0)
  362. {
  363. RImmunity[i] = 1;
  364. SetVehicleHealth(GetPlayerVehicleID(i), 999.0);
  365. }
  366. }
  367. if(vhp > 999.0 && RImmunity[i] == 0)
  368. {
  369. if(!NearTuning(i) || NearSpray(i))
  370. {
  371. VehHP[i] ++;
  372. {
  373. if(VehHP[i] < 2)
  374. {
  375. new string[128];
  376. format(string, sizeof(string), ""RED"CHEAT | "WHITE"Player %s might be using Vehicle-Repair Hack", GetName(i));
  377. AdminMessage(-1, string);
  378. m_SetVehicleHealth(GetPlayerVehicleID(i), 999.0);
  379. }
  380. if(VehHP[i] >= 2)
  381. {
  382. SCM(i, -1, ""RED"CHEAT | "WHITE"You have been kicked for using Vehicle-Repair Hack");
  383. new string[120];
  384. format(string, sizeof(string), ""SERVERBLUE"SERVER | "WHITE"Player %s has been kicked for using Vehicle-Repair Hack", GetName(i));
  385. SCMTA(-1, string);
  386. m_SetVehicleHealth(GetPlayerVehicleID(i), 999.0);
  387. SetVehicleToRespawn(GetPlayerVehicleID(i));
  388. DelayedKick(i);
  389. return 1;
  390. }
  391. }
  392. }
  393. }
  394. }
  395. if(RImmunity[i] == 1)
  396. {
  397. RImmunity[i] = 0;
  398. return 1;
  399. }
  400. }
  401. return 1;
  402. }
  403.  
  404. CMD:fv(playerid)
  405. {
  406. if(PlayerInfo[playerid][Admin] < 1) //change this so it fits your system
  407. {
  408. ERROR(playerid, "You are not allowed to use this command");
  409. return 1;
  410. }
  411. if(!IsPlayerInAnyVehicle(playerid))
  412. {
  413. ERROR(playerid, "You need to be in vehicle to use this command");
  414. return 1;
  415. }
  416. new string[128];
  417. RepairVehicle(GetPlayerVehicleID(playerid));
  418. m_SetVehicleHealth(GetPlayerVehicleID(i), 999.0);
  419. INFO(playerid, "Vehicle repaired");
  420. return 1;
  421. }
  422.  
  423. forward _KickPlayerDelayed(playerid);
  424. public _KickPlayerDelayed(playerid)
  425. {
  426. Kick(playerid);
  427. return 1;
  428. }
  429.  
  430. GetSpeed(playerid)
  431. {
  432. new Float:X, Float:Y, Float:Z, Float:A;
  433. if(IsPlayerInAnyVehicle(playerid))
  434. GetVehicleVelocity(GetPlayerVehicleID(playerid), X, Y, Z);
  435. else GetPlayerVelocity(playerid, X, Y, Z);
  436. A = floatsqroot((X * X)+(Y * Y)+(Z * Z)) * 178.8617875;
  437. return floatround(A);
  438. }
  439.  
  440. AdminMessage(color, string[])
  441. {
  442. foreach(new i: Player)
  443. {
  444. if(IsPlayerConnected(i) && PlayerInfo[i][Admin] >= 1)
  445. {
  446. SCM(i, color, string);
  447. }
  448. }
  449. return 0;
  450. }
  451.  
  452. NearTuning(playerid)
  453. {
  454. if(IsPlayerInRangeOfPoint(playerid, 25.0, 1041.5073,-1030.9069,31.7923)) return 1;
  455. else if(IsPlayerInRangeOfPoint(playerid, 25.0, 2645.1272,-2033.8993,13.2808)) return 1;
  456. else if(IsPlayerInRangeOfPoint(playerid, 25.0, -1935.9835,231.4505,33.8772)) return 1;
  457. else if(IsPlayerInRangeOfPoint(playerid, 25.0, -2713.1533,216.9000,3.9767)) return 1;
  458. else if(IsPlayerInRangeOfPoint(playerid, 25.0, 617.5360,-1.9900,1000.6378)) return 1;
  459. else if(IsPlayerInRangeOfPoint(playerid, 25.0, 2386.6309,1037.3684,10.8203)) return 1;
  460. else if(IsPlayerInRangeOfPoint(playerid, 25.0, 615.2858,-124.2390,997.6057)) return 1;
  461. else if(IsPlayerInRangeOfPoint(playerid, 25.0, 616.7612,-74.8120,997.8828)) return 1;
  462. else return 0;
  463. }
  464. /////////////////////////////////////////////////////////////////////////////////
  465. NearSpray(playerid)
  466. {
  467. if(IsPlayerInRangeOfPoint(playerid, 15.0, 2389.6, 1483.26, 9.81843)) return 1;
  468. else if(IsPlayerInRangeOfPoint(playerid, 15.0, -2430.13, 1013.71, 49.3413)) return 1;
  469. else if(IsPlayerInRangeOfPoint(playerid, 15.0, -1908.93, 292.353, 40.0413)) return 1;
  470. else if(IsPlayerInRangeOfPoint(playerid, 15.0, 491.103, -1747.55, 9.45516)) return 1;
  471. else if(IsPlayerInRangeOfPoint(playerid, 15.0, 1021.81, -1018.71, 30.9081)) return 1;
  472. else if(IsPlayerInRangeOfPoint(playerid, 15.0, 2056.6, -1835.9, 12.5443)) return 1;
  473. else if(IsPlayerInRangeOfPoint(playerid, 15.0, 2640.78, -2049.99, 12.543)) return 1;
  474. else if(IsPlayerInRangeOfPoint(playerid, 15.0, -1941.04, 251.714, 33.4274)) return 1;
  475. else if(IsPlayerInRangeOfPoint(playerid, 15.0, -2728.53, 212.295, 3.45112)) return 1;
  476. else if(IsPlayerInRangeOfPoint(playerid, 15.0, -1424.11, 2576.61, 54.8156)) return 1;
  477. else if(IsPlayerInRangeOfPoint(playerid, 15.0, -103.636, 1112.42, 18.7017)) return 1;
  478. else if(IsPlayerInRangeOfPoint(playerid, 15.0, 715.806, -462.403, 14.9635)) return 1;
  479. else if(IsPlayerInRangeOfPoint(playerid, 15.0, 1025.0094,-1025.0917,32.1016)) return 1;
  480. else if(IsPlayerInRangeOfPoint(playerid, 15.0, 1968.23, 2157.88, 9.59696)) return 1;
  481. else if(IsPlayerInRangeOfPoint(playerid, 15.0, 1851.0931,-1856.4600,13.1099)) return 1; //bomb place
  482. return 0;
  483. }
  484.  
  485. m_CreateVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay)
  486. {
  487. if(veh_created <= MAX_VEHICLES)
  488. {
  489. new o;
  490. o = CreateVehicle(vehicletype, x, y, z, rotation, color1, color2, respawn_delay);
  491. m_SetVehicleHealth(o, 999.0);
  492. SetVehicleParamsCarWindows(o, 1, 1, 1, 1);
  493. Vehicle_Pos[o][0] = x;
  494. Vehicle_Pos[o][1] = y;
  495. Vehicle_Pos[o][2] = z;
  496. Vehicle_Pos[o][3] = rotation;
  497. veh_created ++;
  498. return o;
  499. }
  500. return 1;
  501. }
  502.  
  503. m_SetVehicleHealth(vehicleid, Float:hp)
  504. {
  505. if(hp > 999.0) SetVehicleHealth(vehicleid, 999.0);
  506. else SetVehicleHealth(vehicleid, hp);
  507. return 1;
  508. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement