Guest User

Untitled

a guest
Sep 10th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.62 KB | None | 0 0
  1. //----------------------------------------------------------------------------------------------------------------.
  2. // //
  3. // FairPlay Version 1.2 //
  4. // //
  5. //------------------------------------------------------------------------------------------------------------//
  6. //-----------------------------------------------------------------------------------------------------------//
  7. // //
  8. // Credits //
  9. // - Scripting: Ricky Phelps (SuperViper) //
  10. // - Testing: Chriham3/Alex Shock //
  11. // //
  12. //-----------------------------------------------------------------------------------------------------//
  13. //----------------------------------------------------------------------------------------------------//
  14. // ============================================ SETTINGS =========================================== //
  15.  
  16. /* Unfair play list (comment the line of anything you don't want to be detected) */
  17. #define FP_HIGH_PING (1)
  18. #define FP_WEAPON_HACK (2)
  19. #define FP_VEHICLE_SPEED_HACK (3)
  20. #define FP_JETPACK_HACK (4)
  21. #define FP_DRIVER_DRIVEBY (5) // Commenting this will ENABLE driver driveby
  22. #define FP_DRIVEBY_WEAPONS_RESTRICT (6)
  23. #define FP_SWEARING (7)
  24. #define FP_FLY_HACK (8)
  25. #define FP_CHAT_SPAM (9)
  26. #define FP_AFK (10)
  27. #define FP_TABBING (11)
  28. #define FP_NINJA_JACK (12)
  29. #define FP_CAR_RAM (13)
  30. #define FP_HELIBLADE (14)
  31. #define FP_VEHICLE_MOD_HACK (15)
  32. #define FP_SERVER_AD (16)
  33. #define FP_FAKE_KILL (17)
  34. #define FP_TELEPORT_HACK (18)
  35.  
  36. #if defined FP_MASTER
  37. /* This is the interval of the timer which checks for fair play */
  38. #define FP_TIMER_INTERVAL (1250)
  39.  
  40. /* The maximum ping allowed on the server (will be ignored if high ping detection is disabled) */
  41. #define FP_MAX_PING (500)
  42.  
  43. /* The weapons which are allowed for drivebys (separate with space - will be ignored if driveby weapons restriction is disabled) */
  44. #define FP_DRIVEBY_WEAPONS "28 29 32"
  45.  
  46. /* The IP address of your server (will be ignored if server advertisement detection is disabled) */
  47. #define FP_SERVER_IP "127.0.0.1"
  48.  
  49. /* The domain of your server (will be ignored if server advertisement detection is disabled) */
  50. #define FP_SERVER_DOMAIN "samp.servername.com"
  51.  
  52. /* Curse words (will be ignored if swearing detection is disabled) */
  53. new FP_CurseWords[][] =
  54. {
  55. "ass", "bitch", "cunt", "fuck", "nigga", "nigger", "shit", "whore"
  56. };
  57. #endif
  58.  
  59. // ================================================================================================= //
  60. // =============================== DO NOT TOUCH ANYTHING BELOW THIS =============================== //
  61. // =============================================================================================== //
  62.  
  63. #define FAIRPLAY_INCLUDED
  64.  
  65. #if !defined sscanf
  66. #tryinclude <sscanf2>
  67. #endif
  68.  
  69. forward public FP_Detection(playerid);
  70. forward public OnPlayerUnfairPlay(playerid, playType);
  71.  
  72. forward public FP_ReduceChatCounter(playerid);
  73. forward public FP_VehicleJackCheck(playerid);
  74.  
  75. forward public FP_OnPlayerConnect(playerid);
  76. forward public FP_OnPlayerDisconnect(playerid, reason);
  77. forward public FP_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  78. forward public FP_OnPlayerDeath(playerid, killerid, reason);
  79. forward public FP_OnPlayerSpawn(playerid);
  80. forward public FP_OnPlayerStateChange(playerid, newstate, oldstate);
  81. forward public FP_OnPlayerText(playerid, text[]);
  82. forward public FP_OnPlayerCommandText(playerid, cmdtext[]);
  83. forward public FP_OnPlayerUpdate(playerid);
  84. forward public FP_OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid);
  85. forward public FP_OnVehicleMod(playerid, vehicleid, componentid);
  86. forward public FP_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger);
  87.  
  88. new FP_WeaponSlots[47] =
  89. {
  90. 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10,
  91. 10, 10, 10, 10, 8, 8, 8, -1, -1, -1,
  92. 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 4, 6,
  93. 6, 7, 7, 7, 7, 8, 12, 9, 9, 9, 11,
  94. 11, 11
  95. };
  96.  
  97. #if defined FP_MASTER
  98. stock SetPlayerFairPlayImmune(playerid, immune)
  99. {
  100. return SetPVarInt(playerid, "FP_Immune", immune);
  101. }
  102.  
  103. FP_GetVehicleSpeed(vehicleID)
  104. {
  105. new Float: vehiclesVelocity[3];
  106. GetVehicleVelocity(vehicleID, vehiclesVelocity[0], vehiclesVelocity[1], vehiclesVelocity[2]);
  107. return floatround(floatsqroot((vehiclesVelocity[0] * vehiclesVelocity[1] + vehiclesVelocity[2] * vehiclesVelocity[2])) * 100 * 1.6);
  108. }
  109.  
  110. FP_GetHighestWaterLevel(playerid)
  111. {
  112. if(IsPlayerInRangeOfPoint(playerid, 50.0, 1962.15, -1198.71, 17.45)) return 19;
  113. if(IsPlayerInRangeOfPoint(playerid, 100.0, -1127.58, 2764.43, 40.00)) return 43;
  114. if(IsPlayerInRangeOfPoint(playerid, 100.0, -988.19, 2486.89, 40.00)) return 43;
  115. if(IsPlayerInRangeOfPoint(playerid, 100.0, -924.33, 2306.59, 40.00)) return 43;
  116. if(IsPlayerInRangeOfPoint(playerid, 100.0, -1104.15, 2175.83, 40.00)) return 43;
  117. if(IsPlayerInRangeOfPoint(playerid, 100.0, -1307.06, 2119.33, 40.00)) return 43;
  118. if(IsPlayerInRangeOfPoint(playerid, 100.0, -831.85, 2122.23, 40.00)) return 43;
  119. if(IsPlayerInRangeOfPoint(playerid, 100.0, -595.76, 2138.34, 40.00)) return 43;
  120. if(IsPlayerInRangeOfPoint(playerid, 100.0, -569.24, 2274.40, 40.00)) return 43;
  121. if(IsPlayerInRangeOfPoint(playerid, 12.0, 1095.800, -674.950, 111.908)) return 113;
  122. if(IsPlayerInRangeOfPoint(playerid, 12.0, 224.500, -1185.725, 73.908)) return 76;
  123. if(IsPlayerInRangeOfPoint(playerid, 12.0, 193.700, -1230.608, 76.603)) return 79;
  124. if(IsPlayerInRangeOfPoint(playerid, 12.0, 1277.500, -805.200, 86.581)) return 88;
  125. if(IsPlayerInRangeOfPoint(playerid, 12.0, 2582.0, 2387.0, 16.0)) return 18;
  126. return 10;
  127. }
  128.  
  129. public FP_Detection(playerid)
  130. {
  131. if(!GetPVarInt(playerid, "FP_Immune"))
  132. {
  133. new Float: playersPosition[3], playersState = GetPlayerState(playerid);
  134. GetPlayerPos(playerid, playersPosition[0], playersPosition[1], playersPosition[2]);
  135.  
  136. #if defined FP_TELEPORT_HACK
  137. if(playersState == PLAYER_STATE_ONFOOT || playersState == PLAYER_STATE_DRIVER || playersState == PLAYER_STATE_PASSENGER || playersState == PLAYER_STATE_SPAWNED)
  138. {
  139. if(tickcount() - GetPVarInt(playerid, "FP_LastPositionSet") > FP_TIMER_INTERVAL * 5)
  140. {
  141. if(GetPVarFloat(playerid, "FP_LastPositionZ"))
  142. {
  143. if(!IsPlayerInAnyVehicle(playerid) && !GetPlayerInterior(playerid) && GetPlayerSurfingVehicleID(playerid) == INVALID_VEHICLE_ID)
  144. {
  145. if(!IsPlayerInRangeOfPoint(playerid, 100, GetPVarFloat(playerid, "FP_LastPositionX"), GetPVarFloat(playerid, "FP_LastPositionY"), GetPVarFloat(playerid, "FP_LastPositionZ")))
  146. {
  147. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_TELEPORT_HACK);
  148. }
  149. }
  150. }
  151. }
  152. }
  153. #endif
  154.  
  155. if(playersPosition[0] != GetPVarFloat(playerid, "FP_LastPositionX") || playersPosition[1] != GetPVarFloat(playerid, "FP_LastPositionY") || playersPosition[2] != GetPVarFloat(playerid, "FP_LastPositionZ"))
  156. {
  157. SetPVarFloat(playerid, "FP_LastPositionX", playersPosition[0]), SetPVarFloat(playerid, "FP_LastPositionY", playersPosition[1]), SetPVarFloat(playerid, "FP_LastPositionZ", playersPosition[2]);
  158. SetPVarInt(playerid, "FP_LastUpdate", tickcount());
  159. }
  160.  
  161. SetPVarInt(playerid, "FP_TabbedUpdates", GetPVarInt(playerid, "FP_TabbedUpdates") + 1);
  162.  
  163. #if defined FP_HIGH_PING
  164. if(GetPlayerPing(playerid) >= FP_MAX_PING)
  165. {
  166. SetPVarInt(playerid, "FP_PingWarnings", GetPVarInt(playerid, "FP_PingWarnings") + 1);
  167.  
  168. if(GetPVarInt(playerid, "FP_PingWarnings") >= 3)
  169. {
  170. SetPVarInt(playerid, "FP_PingWarnings", 0);
  171. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_HIGH_PING);
  172. }
  173. }
  174. #endif
  175.  
  176. #if defined FP_VEHICLE_SPEED_HACK
  177. new playersVehicle = GetPlayerVehicleID(playerid);
  178.  
  179. if(playersVehicle)
  180. {
  181. new playersSpeed = FP_GetVehicleSpeed(playersVehicle), vehicleModel = GetVehicleModel(playersVehicle);
  182.  
  183. if((playersSpeed >= 550 && vehicleModel != 460 && vehicleModel != 476 && (vehicleModel < 511 || vehicleModel > 513) && vehicleModel != 519 && vehicleModel != 520 && vehicleModel != 553 && vehicleModel != 577 && vehicleModel != 592 && vehicleModel != 593) || (playersSpeed >= 200 && vehicleModel != 448 && (vehicleModel < 461 || vehicleModel > 463) && vehicleModel != 468 && (vehicleModel < 521 || vehicleModel > 523) && vehicleModel != 581 && vehicleModel != 586) || playersSpeed >= 1250)
  184. {
  185. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_VEHICLE_SPEED_HACK);
  186. }
  187. }
  188. #endif
  189.  
  190. #if defined FP_JETPACK_HACK
  191. if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK)
  192. {
  193. if(!GetPVarInt(playerid, "FP_PlayerJetpack"))
  194. {
  195. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_JETPACK_HACK);
  196. }
  197. }
  198. else
  199. {
  200. SetPVarInt(playerid, "FP_PlayerJetpack", 0);
  201. }
  202. #endif
  203.  
  204. #if defined FP_FLY_HACK
  205. new animationIndex = GetPlayerAnimationIndex(playerid);
  206.  
  207. if(animationIndex >= 1538 && animationIndex <= 1544 && animationIndex != 1542 && !GetPlayerInterior(playerid))
  208. {
  209. if(playersPosition[2] >= FP_GetHighestWaterLevel(playerid))
  210. {
  211. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_FLY_HACK);
  212. }
  213. }
  214. #endif
  215.  
  216. #if defined FP_AFK
  217. if(tickcount() - GetPVarInt(playerid, "FP_LastUpdate") >= 300000)
  218. {
  219. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_AFK);
  220. }
  221. #endif
  222.  
  223. #if defined FP_TABBING
  224. if(GetPVarInt(playerid, "FP_TabbedUpdates") >= 3)
  225. {
  226. if(playersState == PLAYER_STATE_ONFOOT || playersState == PLAYER_STATE_DRIVER || playersState == PLAYER_STATE_PASSENGER || playersState == PLAYER_STATE_SPAWNED)
  227. {
  228. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_TABBING);
  229. }
  230. }
  231. #endif
  232. }
  233.  
  234. return 1;
  235. }
  236.  
  237. public FP_ReduceChatCounter(playerid)
  238. {
  239. SetPVarInt(playerid, "FP_ChatCounter", GetPVarInt(playerid, "FP_ChatCounter") - 1);
  240. return 1;
  241. }
  242.  
  243. public FP_VehicleJackCheck(playerid)
  244. {
  245. SetPVarInt(playerid, "FP_VehicleJacker", INVALID_PLAYER_ID);
  246. return 1;
  247. }
  248.  
  249. public OnPlayerConnect(playerid)
  250. {
  251. for(new weaponIndex, variableName[20]; weaponIndex < 13; weaponIndex++)
  252. {
  253. format(variableName, sizeof(variableName), "FP_PlayerWeapon%d", weaponIndex);
  254. SetPVarInt(playerid, variableName, 0);
  255. }
  256.  
  257. SetPVarInt(playerid, "FP_PingWarnings", 0);
  258.  
  259. SetPVarInt(playerid, "FP_PlayerJetpack", 0);
  260.  
  261. SetPVarInt(playerid, "FP_ChatCounter", 0);
  262.  
  263. SetPVarInt(playerid, "FP_LastUpdate", tickcount());
  264.  
  265. SetPVarInt(playerid, "FP_TabbedUpdates", 0);
  266.  
  267. SetPVarInt(playerid, "FP_VehicleJacker", INVALID_PLAYER_ID);
  268. SetPVarInt(playerid, "FP_VehicleJackTimer", -1);
  269.  
  270. SetPVarInt(playerid, "FP_PlayerAlive", 0);
  271.  
  272. SetPVarInt(playerid, "FP_LastPositionSet", tickcount());
  273.  
  274. SetPVarInt(playerid, "FP_PlayerDetectionTimer", SetTimerEx("FP_Detection", FP_TIMER_INTERVAL, true, "d", playerid));
  275. return (funcidx("FP_OnPlayerConnect") == -1) ? 1 : CallLocalFunction("FP_OnPlayerConnect", "d", playerid);
  276. }
  277.  
  278. #if defined _ALS_OnPlayerConnect
  279. #undef OnPlayerConnect
  280. #else
  281. #define _ALS_OnPlayerConnect
  282. #endif
  283.  
  284. #define OnPlayerConnect FP_OnPlayerConnect
  285.  
  286. public OnPlayerDisconnect(playerid, reason)
  287. {
  288. KillTimer(GetPVarInt(playerid, "FP_PlayerDetectionTimer"));
  289.  
  290. if(GetPVarInt(playerid, "FP_VehicleJackTimer") != -1)
  291. {
  292. KillTimer(GetPVarInt(playerid, "FP_VehicleJackTimer"));
  293. }
  294.  
  295. return (funcidx("FP_OnPlayerDisconnect") == -1) ? 1 : CallLocalFunction("FP_OnPlayerDisconnect", "dd", playerid, reason);
  296. }
  297.  
  298. #if defined _ALS_OnPlayerDisconnect
  299. #undef OnPlayerDisconnect
  300. #else
  301. #define _ALS_OnPlayerDisconnect
  302. #endif
  303.  
  304. #define OnPlayerDisconnect FP_OnPlayerDisconnect
  305.  
  306. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  307. {
  308. if(!GetPVarInt(playerid, "FP_Immune"))
  309. {
  310. #if defined FP_WEAPON_HACK
  311. if(newkeys & KEY_FIRE && !IsPlayerInAnyVehicle(playerid))
  312. {
  313. new playersWeapon = GetPlayerWeapon(playerid);
  314.  
  315. if(playersWeapon && playersWeapon != 40 && playersWeapon != 46)
  316. {
  317. new variableName[20];
  318. format(variableName, sizeof(variableName), "FP_PlayerWeapon%d", FP_WeaponSlots[playersWeapon]);
  319.  
  320. if(GetPVarInt(playerid, variableName) != playersWeapon)
  321. {
  322. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_WEAPON_HACK);
  323. }
  324. }
  325. }
  326. #endif
  327. }
  328.  
  329. return (funcidx("FP_OnPlayerKeyStateChange") == -1) ? 1 : CallLocalFunction("FP_OnPlayerKeyStateChange", "ddd", playerid, newkeys, oldkeys);
  330. }
  331.  
  332. #if defined _ALS_OnPlayerKeyStateChange
  333. #undef OnPlayerKeyStateChange
  334. #else
  335. #define _ALS_OnPlayerKeyStateChange
  336. #endif
  337.  
  338. #define OnPlayerKeyStateChange FP_OnPlayerKeyStateChange
  339.  
  340. public OnPlayerDeath(playerid, killerid, reason)
  341. {
  342. new playerAlive = GetPVarInt(playerid, "FP_PlayerAlive");
  343.  
  344. switch(playerAlive)
  345. {
  346. case 0, 1:
  347. {
  348. SetPVarInt(playerid, "FP_PlayerAlive", (playerAlive) ? 0 : 2);
  349. }
  350.  
  351. case 2:
  352. {
  353. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_FAKE_KILL);
  354. }
  355. }
  356.  
  357. SetPVarInt(playerid, "FP_PlayerJetpack", 0);
  358.  
  359. if(!GetPVarInt(playerid, "FP_Immune"))
  360. {
  361. #if defined FP_NINJA_JACK
  362. if(GetPVarInt(playerid, "FP_VehicleJacker") != INVALID_PLAYER_ID)
  363. {
  364. CallLocalFunction("OnPlayerUnfairPlay", "dd", GetPVarInt(playerid, "FP_VehicleJacker"), FP_NINJA_JACK);
  365. }
  366. #endif
  367.  
  368. #if defined FP_FAKE_KILL
  369. if(killerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid) && !IsPlayerNPC(killerid))
  370. {
  371. new Float: playersHealth;
  372. GetPlayerHealth(playerid, playersHealth);
  373.  
  374. if(playersHealth)
  375. {
  376. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_FAKE_KILL);
  377. }
  378. }
  379. #endif
  380. }
  381.  
  382. SetPVarInt(playerid, "FP_LastPositionSet", tickcount());
  383. return (funcidx("FP_OnPlayerDeath") == -1) ? 1 : CallLocalFunction("FP_OnPlayerDeath", "ddd", playerid, killerid, reason);
  384. }
  385.  
  386. #if defined _ALS_OnPlayerDeath
  387. #undef OnPlayerDeath
  388. #else
  389. #define _ALS_OnPlayerDeath
  390. #endif
  391.  
  392. #define OnPlayerDeath FP_OnPlayerDeath
  393.  
  394. public OnPlayerSpawn(playerid)
  395. {
  396. SetPVarInt(playerid, "FP_PlayerJetpack", 0);
  397. SetPVarInt(playerid, "FP_LastPositionSet", tickcount());
  398. SetPVarInt(playerid, "FP_PlayerAlive", 1);
  399. return (funcidx("FP_OnPlayerSpawn") == -1) ? 1 : CallLocalFunction("FP_OnPlayerSpawn", "d", playerid);
  400. }
  401.  
  402. #if defined _ALS_OnPlayerSpawn
  403. #undef OnPlayerSpawn
  404. #else
  405. #define _ALS_OnPlayerSpawn
  406. #endif
  407.  
  408. #define OnPlayerSpawn FP_OnPlayerSpawn
  409.  
  410. public OnPlayerStateChange(playerid, newstate, oldstate)
  411. {
  412. if(!GetPVarInt(playerid, "FP_Immune"))
  413. {
  414. #if defined FP_DRIVER_DRIVEBY
  415. if(newstate == PLAYER_STATE_DRIVER)
  416. {
  417. SetPlayerArmedWeapon(playerid, 0);
  418. }
  419. #endif
  420.  
  421. #if defined FP_DRIVEBY_WEAPONS_RESTRICT
  422. if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  423. {
  424. new playersWeapon = GetPlayerWeapon(playerid), allowedWeapons[15], bool: playerValidWeapon;
  425. sscanf(FP_DRIVEBY_WEAPONS, "a<i>[15]", allowedWeapons);
  426.  
  427. for(new weaponIndex; weaponIndex < sizeof(allowedWeapons); weaponIndex++)
  428. {
  429. if((allowedWeapons[weaponIndex] && playersWeapon == allowedWeapons[weaponIndex]) || !playersWeapon)
  430. {
  431. playerValidWeapon = true;
  432. break;
  433. }
  434. }
  435.  
  436. if(!playerValidWeapon)
  437. {
  438. SetPlayerArmedWeapon(playerid, 0);
  439. }
  440. }
  441. #endif
  442.  
  443. #if defined FP_NINJA_JACK
  444. if(newstate == PLAYER_STATE_DRIVER)
  445. {
  446. for(new playerIndex; playerIndex < MAX_PLAYERS; playerIndex++)
  447. {
  448. if(GetPVarInt(playerIndex, "FP_VehicleJacker") == playerid)
  449. {
  450. SetTimerEx("FP_VehicleJackCheck", 1000, 0, "i", playerIndex);
  451.  
  452. KillTimer(GetPVarInt(playerIndex, "FP_VehicleJackTimer"));
  453. SetPVarInt(playerIndex, "FP_VehicleJackTimer", -1);
  454. break;
  455. }
  456. }
  457. }
  458. #endif
  459. }
  460.  
  461. return (funcidx("FP_OnPlayerStateChange") == -1) ? 1 : CallLocalFunction("FP_OnPlayerStateChange", "ddd", playerid, newstate, oldstate);
  462. }
  463.  
  464. #if defined _ALS_OnPlayerStateChange
  465. #undef OnPlayerStateChange
  466. #else
  467. #define _ALS_OnPlayerStateChange
  468. #endif
  469.  
  470. #define OnPlayerStateChange FP_OnPlayerStateChange
  471.  
  472. public OnPlayerText(playerid, text[])
  473. {
  474. if(!GetPVarInt(playerid, "FP_Immune"))
  475. {
  476. #if defined FP_SWEARING
  477. new wordLocation, bool: playerSwearing;
  478.  
  479. for(new wordIndex; wordIndex < sizeof(FP_CurseWords); wordIndex++)
  480. {
  481. wordLocation = strfind(text, FP_CurseWords[wordIndex], true);
  482.  
  483. while(wordLocation > -1)
  484. {
  485. playerSwearing = true;
  486.  
  487. for(new textIndex = wordLocation; textIndex < wordLocation + strlen(FP_CurseWords[wordIndex]); textIndex++)
  488. {
  489. text[textIndex] = '*';
  490. }
  491.  
  492. wordLocation = strfind(text, FP_CurseWords[wordIndex], true, wordLocation);
  493. }
  494. }
  495.  
  496. if(playerSwearing)
  497. {
  498. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_SWEARING);
  499. }
  500. #endif
  501.  
  502. #if defined FP_CHAT_SPAM
  503. SetPVarInt(playerid, "FP_ChatCounter", GetPVarInt(playerid, "FP_ChatCounter") + 1);
  504.  
  505. if(GetPVarInt(playerid, "FP_ChatCounter") >= 4)
  506. {
  507. SetPVarInt(playerid, "FP_ChatCounter", 0);
  508. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_CHAT_SPAM);
  509. }
  510. else
  511. {
  512. SetTimerEx("FP_ReduceChatCounter", 850, 0, "d", playerid);
  513. }
  514. #endif
  515.  
  516. #if defined FP_SERVER_AD
  517. new dotCount, colonCount, portCount;
  518.  
  519. for(new stringIndex, stringLength = strlen(text); stringIndex < stringLength; stringIndex++)
  520. {
  521. if(text[stringIndex] == '.')
  522. {
  523. dotCount++;
  524. }
  525. else if(text[stringIndex] == ':')
  526. {
  527. colonCount++;
  528. }
  529. else if(stringIndex + 3 < stringLength)
  530. {
  531. if('0' <= text[stringIndex] <= '9' && '0' <= text[stringIndex + 1] <= '9' && '0' <= text[stringIndex + 2] <= '9' && '0' <= text[stringIndex + 3] <= '9')
  532. {
  533. portCount++;
  534. }
  535. }
  536. }
  537.  
  538. if(dotCount >= 2 && (colonCount || portCount) && strfind(text, FP_SERVER_IP) == -1 && strfind(text, FP_SERVER_DOMAIN, true) == -1)
  539. {
  540. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_SERVER_AD);
  541. return 0;
  542. }
  543. #endif
  544. }
  545.  
  546. SetPVarInt(playerid, "FP_LastUpdate", tickcount());
  547. return (funcidx("FP_OnPlayerText") == -1) ? 1 : CallLocalFunction("FP_OnPlayerText", "ds", playerid, text);
  548. }
  549.  
  550. #if defined _ALS_OnPlayerText
  551. #undef OnPlayerText
  552. #else
  553. #define _ALS_OnPlayerText
  554. #endif
  555.  
  556. #define OnPlayerText FP_OnPlayerText
  557.  
  558. public OnPlayerCommandText(playerid, cmdtext[])
  559. {
  560. if(!GetPVarInt(playerid, "FP_Immune"))
  561. {
  562. #if defined FP_SWEARING
  563. new wordLocation, bool: playerSwearing;
  564.  
  565. for(new wordIndex; wordIndex < sizeof(FP_CurseWords); wordIndex++)
  566. {
  567. wordLocation = strfind(cmdtext, FP_CurseWords[wordIndex], true);
  568.  
  569. while(wordLocation > -1)
  570. {
  571. playerSwearing = true;
  572.  
  573. for(new textIndex = wordLocation; textIndex < wordLocation + strlen(FP_CurseWords[wordIndex]); textIndex++)
  574. {
  575. cmdtext[textIndex] = '*';
  576. }
  577.  
  578. wordLocation = strfind(cmdtext, FP_CurseWords[wordIndex], true, wordLocation);
  579. }
  580. }
  581.  
  582. if(playerSwearing)
  583. {
  584. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_SWEARING);
  585. }
  586. #endif
  587.  
  588. #if defined FP_CHAT_SPAM
  589. SetPVarInt(playerid, "FP_ChatCounter", GetPVarInt(playerid, "FP_ChatCounter") + 1);
  590.  
  591. if(GetPVarInt(playerid, "FP_ChatCounter") >= 4)
  592. {
  593. SetPVarInt(playerid, "FP_ChatCounter", 0);
  594. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_CHAT_SPAM);
  595. }
  596. else
  597. {
  598. SetTimerEx("FP_ReduceChatCounter", 850, 0, "d", playerid);
  599. }
  600. #endif
  601.  
  602. #if defined FP_SERVER_AD
  603. new dotCount, colonCount, portCount;
  604.  
  605. for(new stringIndex, stringLength = strlen(cmdtext); stringIndex < stringLength; stringIndex++)
  606. {
  607. if(cmdtext[stringIndex] == '.')
  608. {
  609. dotCount++;
  610. }
  611. else if(cmdtext[stringIndex] == ':')
  612. {
  613. colonCount++;
  614. }
  615. else if(stringIndex + 3 < stringLength)
  616. {
  617. if('0' <= cmdtext[stringIndex] <= '9' && '0' <= cmdtext[stringIndex + 1] <= '9' && '0' <= cmdtext[stringIndex + 2] <= '9' && '0' <= cmdtext[stringIndex + 3] <= '9')
  618. {
  619. portCount++;
  620. }
  621. }
  622. }
  623.  
  624. if(dotCount >= 2 && (colonCount || portCount) && strfind(cmdtext, FP_SERVER_IP) == -1 && strfind(cmdtext, FP_SERVER_DOMAIN, true) == -1)
  625. {
  626. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_SERVER_AD);
  627. return 0;
  628. }
  629. #endif
  630. }
  631.  
  632. SetPVarInt(playerid, "FP_LastUpdate", tickcount());
  633. return (funcidx("FP_OnPlayerCommandText") == -1) ? 1 : CallLocalFunction("FP_OnPlayerCommandText", "ds", playerid, cmdtext);
  634. }
  635.  
  636. #if defined _ALS_OnPlayerCommandText
  637. #undef OnPlayerCommandText
  638. #else
  639. #define _ALS_OnPlayerCommandText
  640. #endif
  641.  
  642. #define OnPlayerCommandText FP_OnPlayerCommandText
  643.  
  644. public OnPlayerUpdate(playerid)
  645. {
  646. SetPVarInt(playerid, "FP_TabbedUpdates", 0);
  647. return (funcidx("FP_OnPlayerUpdate") == -1) ? 1 : CallLocalFunction("FP_OnPlayerUpdate", "d", playerid);
  648. }
  649.  
  650. #if defined _ALS_OnPlayerUpdate
  651. #undef OnPlayerUpdate
  652. #else
  653. #define _ALS_OnPlayerUpdate
  654. #endif
  655.  
  656. #define OnPlayerUpdate FP_OnPlayerUpdate
  657.  
  658. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
  659. {
  660. if(!GetPVarInt(issuerid, "FP_Immune"))
  661. {
  662. #if defined FP_CAR_RAM
  663. if(weaponid == 49)
  664. {
  665. CallLocalFunction("OnPlayerUnfairPlay", "dd", issuerid, FP_CAR_RAM);
  666. }
  667. #endif
  668.  
  669. #if defined FP_HELIBLADE
  670. if(weaponid == 50)
  671. {
  672. CallLocalFunction("OnPlayerUnfairPlay", "dd", issuerid, FP_HELIBLADE);
  673. }
  674. #endif
  675. }
  676.  
  677. return (funcidx("FP_OnPlayerTakeDamage") == -1) ? 1 : CallLocalFunction("FP_OnPlayerTakeDamage", "ddfd", playerid, issuerid, amount, weaponid);
  678. }
  679.  
  680. #if defined _ALS_OnPlayerTakeDamage
  681. #undef OnPlayerTakeDamage
  682. #else
  683. #define _ALS_OnPlayerTakeDamage
  684. #endif
  685.  
  686. #define OnPlayerTakeDamage FP_OnPlayerTakeDamage
  687.  
  688. public OnVehicleMod(playerid, vehicleid, componentid)
  689. {
  690. if(!GetPVarInt(playerid, "FP_Immune"))
  691. {
  692. #if defined FP_VEHICLE_MOD_HACK
  693. if(!GetPlayerInterior(playerid))
  694. {
  695. CallLocalFunction("OnPlayerUnfairPlay", "dd", playerid, FP_VEHICLE_MOD_HACK);
  696. return 0;
  697. }
  698. #endif
  699. }
  700.  
  701. return (funcidx("FP_OnVehicleMod") == -1) ? 1 : CallLocalFunction("FP_OnVehicleMod", "ddd", playerid, vehicleid, componentid);
  702. }
  703.  
  704. #if defined _ALS_OnVehicleMod
  705. #undef OnVehicleMod
  706. #else
  707. #define _ALS_OnVehicleMod
  708. #endif
  709.  
  710. #define OnVehicleMod FP_OnVehicleMod
  711.  
  712. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  713. {
  714. if(!GetPVarInt(playerid, "FP_Immune"))
  715. {
  716. #if defined FP_NINJA_JACK
  717. if(!ispassenger)
  718. {
  719. for(new playerIndex; playerIndex < MAX_PLAYERS; playerIndex++)
  720. {
  721. if(IsPlayerInVehicle(playerIndex, vehicleid) && !GetPlayerVehicleSeat(playerIndex))
  722. {
  723. SetPVarInt(playerIndex, "FP_VehicleJacker", playerid);
  724. SetPVarInt(playerIndex, "FP_VehicleJackTimer", SetTimerEx("FP_VehicleJackCheck", 10000, 0, "d", playerIndex));
  725. break;
  726. }
  727. }
  728. }
  729. #endif
  730. }
  731.  
  732. return (funcidx("FP_OnPlayerEnterVehicle") == -1) ? 1 : CallLocalFunction("FP_OnPlayerEnterVehicle", "ddd", playerid, vehicleid, ispassenger);
  733. }
  734.  
  735. #if defined _ALS_OnPlayerEnterVehicle
  736. #undef OnPlayerEnterVehicle
  737. #else
  738. #define _ALS_OnPlayerEnterVehicle
  739. #endif
  740.  
  741. #define OnPlayerEnterVehicle FP_OnPlayerEnterVehicle
  742. #endif
  743.  
  744. stock FP_GivePlayerWeapon(playerid, weaponid, ammo)
  745. {
  746. new variableName[20];
  747. format(variableName, sizeof(variableName), "FP_PlayerWeapon%d", FP_WeaponSlots[weaponid]);
  748. SetPVarInt(playerid, variableName, weaponid);
  749. return GivePlayerWeapon(playerid, weaponid, ammo);
  750. }
  751.  
  752. #if defined _ALS_GivePlayerWeapon
  753. #undef GivePlayerWeapon
  754. #else
  755. #define _ALS_GivePlayerWeapon
  756. #endif
  757.  
  758. #define GivePlayerWeapon FP_GivePlayerWeapon
  759.  
  760. stock FP_ResetPlayerWeapons(playerid)
  761. {
  762. for(new weaponIndex, variableName[20]; weaponIndex < 13; weaponIndex++)
  763. {
  764. format(variableName, sizeof(variableName), "FP_PlayerWeapon%d", weaponIndex);
  765. SetPVarInt(playerid, variableName, 0);
  766. }
  767.  
  768. return ResetPlayerWeapons(playerid);
  769. }
  770.  
  771. #if defined _ALS_ResetPlayerWeapons
  772. #undef ResetPlayerWeapons
  773. #else
  774. #define _ALS_ResetPlayerWeapons
  775. #endif
  776.  
  777. #define ResetPlayerWeapons FP_ResetPlayerWeapons
  778.  
  779. stock FP_SetPlayerAmmo(playerid, weapon, ammo)
  780. {
  781. if(!ammo)
  782. {
  783. new variableName[20];
  784. format(variableName, sizeof(variableName), "FP_PlayerWeapon%d", FP_WeaponSlots[weapon]);
  785. SetPVarInt(playerid, variableName, 0);
  786. }
  787.  
  788. return SetPlayerAmmo(playerid, weapon, ammo);
  789. }
  790.  
  791. #if defined _ALS_SetPlayerAmmo
  792. #undef SetPlayerAmmo
  793. #else
  794. #define _ALS_SetPlayerAmmo
  795. #endif
  796.  
  797. #define SetPlayerAmmo FP_SetPlayerAmmo
  798.  
  799. stock FP_SetPlayerSpecialAction(playerid, actionid)
  800. {
  801. if(actionid == SPECIAL_ACTION_USEJETPACK)
  802. {
  803. SetPVarInt(playerid, "FP_PlayerJetpack", 1);
  804. }
  805. else if(actionid == SPECIAL_ACTION_NONE)
  806. {
  807. SetPVarInt(playerid, "FP_PlayerJetpack", 0);
  808. }
  809.  
  810. return SetPlayerSpecialAction(playerid, actionid);
  811. }
  812.  
  813. #if defined _ALS_SetPlayerSpecialAction
  814. #undef SetPlayerSpecialAction
  815. #else
  816. #define _ALS_SetPlayerSpecialAction
  817. #endif
  818.  
  819. #define SetPlayerSpecialAction FP_SetPlayerSpecialAction
  820.  
  821. stock FP_ClearAnimations(playerid, forcesync)
  822. {
  823. SetPVarInt(playerid, "FP_PlayerJetpack", 0);
  824. return ClearAnimations(playerid, forcesync);
  825. }
  826.  
  827. #if defined _ALS_ClearAnimations
  828. #undef ClearAnimations
  829. #else
  830. #define _ALS_ClearAnimations
  831. #endif
  832.  
  833. #define ClearAnimations FP_ClearAnimations
  834.  
  835. stock FP_SetPlayerPos(playerid, Float: x, Float: y, Float: z)
  836. {
  837. SetPVarInt(playerid, "FP_LastPositionSet", tickcount());
  838. return SetPlayerPos(playerid, x, y, z);
  839. }
  840.  
  841. #if defined _ALS_SetPlayerPos
  842. #undef SetPlayerPos
  843. #else
  844. #define _ALS_SetPlayerPos
  845. #endif
  846.  
  847. #define SetPlayerPos FP_SetPlayerPos
  848.  
  849. stock FP_SetPlayerPosFindZ(playerid, Float: x, Float: y, Float: z)
  850. {
  851. SetPVarInt(playerid, "FP_LastPositionSet", tickcount());
  852. return SetPlayerPosFindZ(playerid, x, y, z);
  853. }
  854.  
  855. #if defined _ALS_SetPlayerPosFindZ
  856. #undef SetPlayerPosFindZ
  857. #else
  858. #define _ALS_SetPlayerPosFindZ
  859. #endif
  860.  
  861. #define SetPlayerPosFindZ FP_SetPlayerPosFindZ
  862.  
  863. stock FP_SetPlayerVelocity(playerid, Float: x, Float: y, Float: z)
  864. {
  865. SetPVarInt(playerid, "FP_LastPositionSet", tickcount());
  866. return SetPlayerVelocity(playerid, x, y, z);
  867. }
  868.  
  869. #if defined _ALS_SetPlayerVelocity
  870. #undef SetPlayerVelocity
  871. #else
  872. #define _ALS_SetPlayerVelocity
  873. #endif
  874.  
  875. #define SetPlayerVelocity FP_SetPlayerVelocity
Advertisement
Add Comment
Please, Sign In to add comment