Advertisement
Guest User

FairPlay.inc

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