Advertisement
ZumeZero

Fuckcleo.inc

Dec 26th, 2014
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.08 KB | None | 0 0
  1. /*
  2.  *
  3.  *          "fuckCleo.inc" - #1 Anti-cleo mod include
  4.  *              Created/Debugged most by Lorenc_
  5.  *
  6.  *      Thanks to:
  7.  *          Cessil, Infamous and [FeK]Drakins, JernejL
  8.  *
  9. */
  10.  
  11. /* ** Stop Duplicating Code! ** */
  12. #if defined _fcleo_included
  13.     #endinput
  14. #endif
  15. #define _fcleo_included
  16.  
  17. /* ** Includes ** */
  18. #include                            < a_samp >
  19.  
  20. /* ** Configuration ** */
  21. #define FC_FILE_VERSION             "0.3.5" // Added the FC_
  22.  
  23. #define CLEO_FAKEKILL               ( 1 )
  24. #define CLEO_CARWARP                ( 2 )
  25. #define CLEO_PLAYERBUGGER           ( 3 ) // This number will never be called from OnPlayerCleoDetected
  26. #define CLEO_CARSWING               ( 4 )
  27. #define CLEO_CAR_PARTICLE_SPAM      ( 5 )
  28.  
  29. /* ** Variables ** */
  30. enum E_CLEO_DATA
  31. {
  32.     E_FK_LASTDEATH,                 E_FK_DEATHSPAM,
  33.     E_CW_TIME,                      E_CW_VEHID,
  34.     Float: E_PB_X,                  Float: E_PB_Y,              Float: E_PB_Z,
  35.     E_CPS_SPAMCOUNT,                E_CPS_TICK
  36. };
  37.  
  38. static stock
  39.     g_cleoData                      [ MAX_PLAYERS ] [ E_CLEO_DATA ],
  40.  
  41.     bool: FC_OPU,
  42.     bool: FC_OPD,
  43.     bool: FC_OPSC,
  44.     bool: FC_OVDSU,
  45.     bool: FC_OPDC
  46. ;
  47.  
  48. /* ** Forwards ** */
  49. forward OnPlayerCleoDetected        ( playerid, cleoid );
  50. forward fc_RepairVehicle            ( vehicleid );
  51.  
  52. public fc_RepairVehicle( vehicleid )
  53. {
  54.     #if defined _FOREACH_LOCAL_VERSION // I guess this is always defined in foreach.inc
  55.         foreach(Player, playerid)
  56.         {
  57.             if( GetPlayerVehicleID( playerid ) == vehicleid )  {
  58.                 g_cleoData[ playerid ] [ E_CPS_SPAMCOUNT ]  = 0;
  59.                 g_cleoData[ playerid ] [ E_CPS_TICK ]       = 0;
  60.             }
  61.         }
  62.     #else
  63.         for( new playerid; playerid < MAX_PLAYERS; playerid++ )
  64.         {
  65.             if( IsPlayerConnected( playerid ) )
  66.             {
  67.                 if( GetPlayerVehicleID( playerid ) == vehicleid )  {
  68.                     g_cleoData[ playerid ] [ E_CPS_SPAMCOUNT ]  = 0;
  69.                     g_cleoData[ playerid ] [ E_CPS_TICK ]       = 0;
  70.                 }
  71.             }
  72.         }
  73.     #endif
  74.     return RepairVehicle( vehicleid );
  75. }
  76. #define RepairVehicle fc_RepairVehicle
  77.  
  78. public OnVehicleDamageStatusUpdate( vehicleid, playerid )
  79. {
  80.     static fc_tires, fc_lights;
  81.     GetVehicleDamageStatus( vehicleid, fc_lights, fc_tires, fc_lights, fc_tires );
  82.     if( GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
  83.     {
  84.         if( fc_lights || fc_tires )
  85.             return 1;
  86.  
  87.         new time = GetTickCount( );
  88.         switch( time - g_cleoData[ playerid ] [ E_CPS_TICK ] )
  89.         {
  90.             case 0 .. 500:
  91.             {
  92.                 g_cleoData[ playerid ] [ E_CPS_SPAMCOUNT ] ++;
  93.                 if( g_cleoData[ playerid ] [ E_CPS_SPAMCOUNT ] >= 10 )
  94.                 {
  95.                     CallLocalFunction( "OnPlayerCleoDetected", "dd", playerid, CLEO_CAR_PARTICLE_SPAM );
  96.                     return 1;
  97.                 }
  98.             }
  99.             default: g_cleoData[ playerid ] [ E_CPS_SPAMCOUNT ] = 0;
  100.         }
  101.         g_cleoData[ playerid ] [ E_CPS_TICK ] = time;
  102.     }
  103.     return ( FC_OVDSU ) ? CallLocalFunction( "FC_OnVehicleDamageStatusUpdate", "dd", vehicleid, playerid ) : 1;
  104. }
  105.  
  106. #if defined ALS_OnVehicleDamageStatusUpdate
  107.     #undef OnVehicleDamageStatusUpdate
  108. #else
  109.     #define ALS_OnVehicleDamageStatusUpdate
  110. #endif
  111. #define OnVehicleDamageStatusUpdate FC_OnVehicleDamageStatusUpdate
  112. forward FC_OnVehicleDamageStatusUpdate( vehicleid, playerid );
  113.  
  114. public OnPlayerStateChange( playerid, newstate, oldstate )
  115. {
  116.     if( newstate == PLAYER_STATE_DRIVER )
  117.     {
  118.         if( GetPlayerVehicleID( playerid ) != g_cleoData[ playerid ] [ E_CW_VEHID ] )
  119.         {
  120.             if( g_cleoData[ playerid ] [ E_CW_TIME ] > gettime( ) )
  121.             {
  122.                 CallLocalFunction( "OnPlayerCleoDetected", "dd", playerid, CLEO_CARWARP );
  123.                 return 1;
  124.             }
  125.             g_cleoData[ playerid ] [ E_CW_TIME ] = gettime( ) + 1;
  126.             g_cleoData[ playerid ] [ E_CW_VEHID ] = GetPlayerVehicleID( playerid );
  127.         }
  128.     }
  129.     return ( FC_OPSC ) ? CallLocalFunction( "FC_OnPlayerStateChange", "ddd", playerid, newstate, oldstate ) : 1;
  130. }
  131.  
  132. #if defined _ALS_OnPlayerStateChange
  133.     #undef OnPlayerStateChange
  134. #else
  135.     #define _ALS_OnPlayerStateChange
  136. #endif
  137. #define OnPlayerStateChange FC_OnPlayerStateChange
  138. forward FC_OnPlayerStateChange( playerid, newstate, oldstate );
  139.  
  140. public OnPlayerDeath( playerid, killerid, reason )
  141. {
  142.     new time = gettime( );
  143.     switch( time - g_cleoData[ playerid ] [ E_FK_LASTDEATH ] )
  144.     {
  145.         case 0 .. 3:
  146.         {
  147.             g_cleoData[ playerid ] [ E_FK_DEATHSPAM ] ++;
  148.             if( g_cleoData[ playerid ] [ E_FK_DEATHSPAM ] >= 3 )
  149.             {
  150.                 CallLocalFunction( "OnPlayerCleoDetected", "dd", playerid, CLEO_FAKEKILL );
  151.                 return 1;
  152.             }
  153.         }
  154.         default: g_cleoData[ playerid ] [ E_FK_DEATHSPAM ] = 0;
  155.     }
  156.     g_cleoData[ playerid ] [ E_FK_LASTDEATH ] = time;
  157.     return ( FC_OPD ) ? CallLocalFunction( "FC_OnPlayerDeath", "ddd", playerid, killerid, reason ) : 1;
  158. }
  159.  
  160. #if defined _ALS_OnPlayerDeath
  161.     #undef OnPlayerDeath
  162. #else
  163.     #define _ALS_OnPlayerDeath
  164. #endif
  165. #define OnPlayerDeath FC_OnPlayerDeath
  166. forward FC_OnPlayerDeath( playerid, killerid, reason );
  167.  
  168. public OnPlayerUpdate( playerid )
  169. {
  170.     static
  171.         Float: X,   Float: Y,   Float: Z,
  172.         Float: vX,  Float: vY,  Float: vZ
  173.     ;
  174.     GetPlayerPos( playerid, X, Y, Z );
  175.  
  176.     if( X >= 99999.0 || Y >= 99999.0 || Z >= 99999.0 || X <= -99999.0 || Y <= -99999.0 || Z <= -99999.0 ) {
  177.         SendClientMessage( playerid, 0xa9c4e4ff, "Warning: Excessive X, Y, Z has been breached thus last location set." );
  178.         SetPlayerPos( playerid, g_cleoData[ playerid ] [ E_PB_X ], g_cleoData[ playerid ] [ E_PB_Y ], g_cleoData[ playerid ] [ E_PB_Z ] );
  179.     }
  180.     else
  181.     {
  182.         g_cleoData[ playerid ] [ E_PB_X ] = X;
  183.         g_cleoData[ playerid ] [ E_PB_Y ] = Y;
  184.         g_cleoData[ playerid ] [ E_PB_Z ] = Z;
  185.     }
  186.  
  187.     if( IsPlayerInAnyVehicle( playerid ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
  188.     {
  189.         GetPlayerPos( playerid, X, Y, Z );
  190.         GetVehicleVelocity( GetPlayerVehicleID( playerid ), vX, vY, vZ );
  191.         if( ( vX > 3.0 || vY > 3.0 || vZ > 3.0 || vX < -3.0 || vY < -3.0 || vZ < -3.0 ) && ( vX != X && vY != Y && vZ != Z ) )
  192.         {
  193.             CallLocalFunction( "OnPlayerCleoDetected", "dd", playerid, CLEO_CARSWING );
  194.         }
  195.     }
  196.     return ( FC_OPU ) ? CallLocalFunction( "FC_OnPlayerUpdate", "d", playerid ) : 1;
  197. }
  198.  
  199. #if defined _ALS_OnPlayerUpdate
  200.     #undef OnPlayerUpdate
  201. #else
  202.     #define _ALS_OnPlayerUpdate
  203. #endif
  204. #define OnPlayerUpdate FC_OnPlayerUpdate
  205. forward FC_OnPlayerUpdate( playerid );
  206.  
  207. public OnPlayerDisconnect(playerid, reason)
  208. {
  209.     // Pointless reseting, but just incase!
  210.     g_cleoData[ playerid ] [ E_FK_LASTDEATH ] = 0;
  211.     g_cleoData[ playerid ] [ E_FK_DEATHSPAM ] = 0;
  212.     g_cleoData[ playerid ] [ E_CW_TIME ] = 0;
  213.     g_cleoData[ playerid ] [ E_CW_VEHID ] = INVALID_VEHICLE_ID;
  214.     g_cleoData[ playerid ] [ E_PB_X ] = -1;
  215.     g_cleoData[ playerid ] [ E_PB_Y ] = -1;
  216.     g_cleoData[ playerid ] [ E_PB_Z ] = -1;
  217.     g_cleoData[ playerid ] [ E_CPS_SPAMCOUNT ] = 0;
  218.     g_cleoData[ playerid ] [ E_CPS_TICK ] = 0;
  219.     return ( FC_OPDC ) ? CallLocalFunction( "FC_OnPlayerDisconnect", "dd", playerid, reason ) : 1;
  220. }
  221.  
  222. #if defined _ALS_OnPlayerDisconnect
  223.     #undef OnPlayerDisconnect
  224. #else
  225.     #define _ALS_OnPlayerDisconnect
  226. #endif
  227. #define OnPlayerDisconnect FC_OnPlayerDisconnect
  228. forward FC_OnPlayerDisconnect( playerid, reason );
  229.  
  230. #if !defined FILTERSCRIPT
  231.     public OnGameModeInit()
  232.     {
  233.         FC_OPU = ( funcidx( "FC_OnPlayerUpdate" ) != -1 );
  234.         FC_OPD = ( funcidx( "FC_OnPlayerDeath" ) != -1 );
  235.         FC_OPSC = ( funcidx( "FC_OnPlayerStateChange" ) != -1 );
  236.         FC_OPDC = ( funcidx( "FC_OnPlayerDisconnect" ) != -1 );
  237.         FC_OVDSU = ( funcidx( "FC_OnVehicleDamageStatusUpdate" ) != -1 );
  238.         return ( funcidx( "FC_OnGameModeInit" ) != -1 ) ? CallLocalFunction( "FC_OnGameModeInit", "" ) : 1;
  239.     }
  240.     #if defined _ALS_OnGameModeInit
  241.         #undef OnGameModeInit
  242.     #else
  243.         #define _ALS_OnGameModeInit
  244.     #endif
  245.     #define OnGameModeInit FC_OnGameModeInit
  246.     forward FC_OnGameModeInit();
  247. #else
  248.     public OnFilterScriptInit()
  249.     {
  250.         FC_OPU = ( funcidx( "FC_OnPlayerUpdate" ) != -1 );
  251.         FC_OPD = ( funcidx( "FC_OnPlayerDeath" ) != -1 );
  252.         FC_OPSC = ( funcidx( "FC_OnPlayerStateChange" ) != -1 );
  253.         FC_OPDC = ( funcidx( "FC_OnPlayerDisconnect" ) != -1 );
  254.         FC_OVDSU = ( funcidx( "FC_OnVehicleDamageStatusUpdate" ) != -1 );
  255.         return ( funcidx( "FC_OnFilterScriptInit" ) != -1 ) ? CallLocalFunction( "FC_OnFilterScriptInit", "" ) : 1;
  256.     }
  257.     #if defined _ALS_OnFilterScriptInit
  258.         #undef OnFilterScriptInit
  259.     #else
  260.         #define _ALS_OnFilterScriptInit
  261.     #endif
  262.     #define OnFilterScriptInit FC_OnFilterScriptInit
  263.     forward FC_OnFilterScriptInit();
  264. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement