Some useful 0.3 functions.
#1

These function can also be used for players. Just change the functions to the ones that belong to players. GetVehicleVelocity will be GetPlayerVelocity... so on.

BoostVehicle
You can increase/decrease vehicle speed with this function. It's recommended to not go higher than 2.0 or lower than -2.0. Using 0.25 as speed is fine.
Code:
stock BoostVehicle(vehicleid, Float:speed){
	new Float:X, Float:Y, Float:Z, Float:A;
	GetVehicleZAngle(vehicleid, A);
	GetVehicleVelocity(vehicleid, X, Y, Z);
	X += (speed * floatsin(-A, degrees));
	Y += (speed * floatcos(-A, degrees));
	SetVehicleVelocity(vehicleid, X, Y, Z);
}
VehicleJump
You can make a vehicle go up or down. I usually set height to 1.0.
Code:
stock VehicleJump(vehicleid, Float:height){
	new Float:X, Float:Y, Float:Z;
	GetVehicleVelocity(vehicleid, X, Y, Z);
	SetVehicleVelocity(vehicleid, X, Y, Z+height);
}
StopVehicle
This surprisingly stops the vehicle... :P
Code:
stock StopVehicle(vehicleid){
	SetVehicleVelocity(vehicleid, 0.0, 0.0, 0.0);
}
Reply
#2

Quote:
Originally Posted by [MOB
Tr1viUm ]
It's recommended to not go higher than 2.0 or lower than 2.0. Using 0.25 as speed is fine.
hmm? that a typo?
Reply
#3

Quote:
Originally Posted by Lenny.
Quote:
Originally Posted by [MOB
Tr1viUm ]
It's recommended to not go higher than 2.0 or lower than 2.0. Using 0.25 as speed is fine.
hmm? that a typo?
Yeah, should be lower than -2.0. :P
Reply
#4

It's funny if you go over +/- 50. But if you go too much you can get bugged.
Reply
#5

Quote:
Originally Posted by [MOB
Tr1viUm ]
BoostVehicle
You can increase/decrease vehicle speed with this function. It's recommended to not go higher than 2.0 or lower than -2.0. Using 0.25 as speed is fine.
Code:
stock BoostVehicle(vehicleid, Float:speed){
	new Float:X, Float:Y, Float:Z, Float:A;
	GetVehicleZAngle(vehicleid, A);
	GetVehicleVelocity(vehicleid, X, Y, Z);
	X += (speed * floatsin(-A, degrees));
	Y += (speed * floatcos(-A, degrees));
	SetVehicleVelocity(vehicleid, X, Y, Z);
}
A modified version of this:

pawn Code:
AddVelocityDirection( vehicleid, Float:power = 1.0, bool:updown = true )
{
    new
      Float:x,
      Float:y,
      Float:z,
      Float:angle;

    GetVehicleVelocity( vehicleid, x, y, z );
    GetVehicleZAngle( vehicleid, angle );

    switch ( updown )
    {
        case false : //left or right (use negative power for left)
        {
            x += ( power * floatcos( angle, degrees ) );
            y += ( power * floatsin( angle, degrees ) );
        }
        case true : //front or back (use negative power for backwards)
        {
            x += ( power * floatsin( -angle, degrees ) );
            y += ( power * floatcos( -angle, degrees ) );
        }
    }

    SetVehicleVelocity( vehicleid, x, y, z );
    return true;
}
Usage:

pawn Code:
AddVelocityDirection( GetPlayerVehicleID( playerid ), 1.0 ); //forwards
AddVelocityDirection( GetPlayerVehicleID( playerid ), -1.0 ); //backwards
AddVelocityDirection( GetPlayerVehicleID( playerid ), -1.0, false ); //left strafe
AddVelocityDirection( GetPlayerVehicleID( playerid ), 1.0, false ); //right strafe
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)