SA-MP Forums Archive
Does 0.3e have protection against the remote controlling issue? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Does 0.3e have protection against the remote controlling issue? (/showthread.php?tid=339920)



Does 0.3e have protection against the remote controlling issue? - Kar - 05.05.2012

Hey, does 0.3e have protection against the remote controlling issue?

This is a little annoying in 0.3d, people remotely jack other vehicle's (which have a driver already) then shoot off there vehicle, add mods, or even change their vehicle health. This is really annoying and I was just wondering if something has been done about it..


Re: Does 0.3e have protection against the remote controlling issue? - Lorenc_ - 06.05.2012

needs to be fixed please


Re: Does 0.3e have protection against the remote controlling issue? - Kar - 06.05.2012

JernejL has been remote jacking patch, but it's not exactly 100%..


Re: Does 0.3e have protection against the remote controlling issue? - Virtual1ty - 06.05.2012

Umm, I really shouldn't be saying this, but I have made some sort of a AntiCheat for that.
You can even make one yourself as 0.3d has a function called GetPlayerAnimationIndex() and GetAnimationName().

Now, on the efficient side, I'm not entirely sure whether it will cause lags or not because I put that checking code under OnPlayerUpdate.
It bases of getting the player's animation index (at first it was animation name with strcmp checks, but then I understood how inefficient that really was) when you're onfoot, as it seems that GetPlayerAnimationIndex doesn't work when you're in vehicle, so.. that's perfect.

Here's only how I made it and you can make something very similiar (however I don't suggest using it for passengers entering the vehicle,
because of the SA-MP G-Glitch), but beware that this way of checking can also be flawed.
And here's a rough example taken straight from my gamemode:
pawn Код:
// Somewhere ontop:

new
    bool:VehicleEnterAnimPortrayed[ MAX_PLAYERS ],
    bool:InVehicle                [ MAX_PLAYERS ];

public OnPlayerUpdate( playerid )
{
    static index;
   
    if ( GetPlayerState( playerid ) == PLAYER_STATE_ONFOOT )
    {
        index = GetPlayerAnimationIndex( playerid );
       
        if ( index )
        {
            if ( VehicleEnterAnimPortrayed[ playerid ] == false )
            { // FINAL STAGE IN CHECKING IF A PLAYER ENTERING THE VEHICLE IS PERFORMING THE REQUIRED ANIMATION=
                switch ( index )
                { // Optimizing a little; Constant expressions instead of a loop
                    case 53, 54, 66, 67, 68, 112, 113, 114, 132, 133, 226, 227,
                         354, 438, 439, 726, 727, 916, 1024, 1025, 1026, 1027,
                         1035, 1389, 1421, 1558, 1632, 1633, 1650, 1651, 1663:
                    // Please note how this list isn't complete, you must find all other vehicle
                    // entering animation indexes if you don't want your players to get
                    // kicked/banned or possibly warned.
                    {
                        VehicleEnterAnimPortrayed[ playerid ] = true;
                        InVehicle[ playerid ] = true;
                    }
                }
            }
        }
    }
   
    return true;
}

public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if ( newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER && VehicleEnterAnimPortrayed[ playerid ] )
    {
        // Reset the variable, player is now in vehicle.
        VehicleEnterAnimPortrayed[ playerid ] = false;
    }
   
    if ( newstate == PLAYER_STATE_DRIVER && !InVehicle[ playerid ] )
    {
        // Exclude boats from checking, something really messes up when trying to use
        // OnPlayerUpdate and GetPlayerAnimationIndex with them.
        // Just a note; This is the actual part where the player gets detected !
       
        if ( IsABoat( GetVehicleModel( GetPlayerVehicleID( playerid ) ) ) ) return true;
       
        //BanPlayer( "[SAC]", playerid, "Car-jacking cheats" );
        SendClientMessage(playerid, 0xA51810FF, "Banned for: Car-jacking cheats");
    }
   
    // Passenger check, you can still use this however:
    if ( newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_PASSENGER && !InVehicle[ playerid ] )
    {
        // This is just a left over example, feel free to modify this as you sole see fit
        /*
        new string[83];
        format(string, 83, "Player [%d]%s was detected for vehicle remote-control haxx!", playerid, PlayerInfo[playerid][pName]);
        SendAdminClientMessage( COLOR_ADMIN_RED, string );
        */

        //BanPlayer( "[SAC]", playerid, "veh. remote-control hack" );
        SendClientMessage(playerid, 0xA51810FF, "Banned for: veh. remote-control hack");
    }
   
    if ( oldstate == PLAYER_STATE_DRIVER )
    {
        if ( InVehicle[ playerid ] )
            InVehicle[ playerid ] = false;
    }
   
    if ( oldstate == PLAYER_STATE_PASSENGER )
    {
        if ( InVehicle[ playerid ] )
            InVehicle[ playerid ] = false; 
    }
   
    return true;
}
Edit: Updated the OnPlayerStateChange code, but SendClientMessage chunks of code below the if statements might be misleading.
It's actually the other way around
Edit2: Forgot to add the part which resets InVehicle variable, be sure to also reset it at OnPlayerConnect !
Also, if you use PutPlayerInVehicle anywhere in your code, set the InVehicle variable to true !