Advertisement
Guest User

FairPlay.inc

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