Thread: Useful Snippets
View Single Post
Old 23/06/2012, 10:41 AM   #712
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 4,120
Reputation: 901
Default Re: Useful Snippets

ANTI-CAR WARP

Fags be car warping, I just copied this out of my gamemode, change it how you like. Just make sure you don't use PutPlayerInVehicle too fast, or you can even simply just hook: p_CarWarpTime[ playerid ] = gettime( ) + 1; to those functions

The average car jack per vehicle is around 400ms (0.4 seconds), the highest I've caught to was 634ms. It's good to be safe than sorry, so I've now set it to 1 second. It's barely possible to enter more than two vehicles in under two seconds anyway, as previously with two seconds. It was possible to enter two cars within 2 seconds.

Version 0.3 - NEW
pawn Code:
new p_CarWarpTime[ MAX_PLAYERS ];
new p_CarWarpVehicleID[ MAX_PLAYERS ];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if( newstate == PLAYER_STATE_DRIVER && p_AdminLevel[ playerid ] <= 0 )
    {
        if( GetPlayerVehicleID( playerid ) != p_CarWarpVehicleID[ playerid ] )
        {
            if( p_CarWarpTime[ playerid ] > gettime( ) )
            {
                SendClientMessageToAllFormatted( -1, ""COL_AC"[ANTI-CHEAT]{FFFFFF} %s(%d) has been banned for car warping.", ReturnPlayerName( playerid ), playerid );
                BanEx( playerid, "Car Warp" );
                return 1;
            }
            p_CarWarpTime[ playerid ] = gettime( ) + 1;
            p_CarWarpVehicleID[ playerid ] = GetPlayerVehicleID( playerid );
        }
    }
    return 1;
}
__________________

192.169.82.202:7777 - An awesome CnR server consisting of doozy features! Come, we have players!



Last edited by Lorenc_; 26/06/2012 at 09:23 AM.
Lorenc_ is offline   Reply With Quote