car hijack snippet

Started by ℛḝξ☂, Mar 01, 2018, 05:16 AM

Previous topic - Next topic

ℛḝξ☂

I'm trying to add that hijack feature to 0.4, here is the code.

LOC: onScriptLoad
EnteringVehicle <- array( 100, -1 );
Carjack_J <- BindKey( true, 0x4A, 0, 0 );

LOC: onPlayerEnteringVehicle(player, vehicle, ...)
if ( EnteringVehicle[ player.ID ] != -1 ) return 1;
EnteringVehicle[ player.ID ] = vehicle.ID;

LOC: onPlayerEnterVehicle(player, vehicle, ...)
EnteringVehicle[ player.ID ] = -1;

LOC: onKeyDown(player, key)
if ( key == Carjack_J )  //
{
if ( EnteringVehicle[ player.ID ] != -1 )
{
local veh = FindVehicle( EnteringVehicle[ player.ID ] );
if ( veh )
{
if ( veh.Driver && veh.Driver.ID != player.ID ) PrivMessage( veh.Driver, player.Name + " hijacked your vehicle!" );
player.PutInVehicleSlot( veh, 0 );
    EnteringVehicle[ player.ID ] = -1;
}
}
       }
Press J when you are entering vehicle as a passenger.
If you have a better idea or something, reply here so that i can improve it. :)
I may be a slow walker but I am always walking.

Mohamed Boubekri

| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].