vehicle boost
#1

how to make vehicle boost system same as gamerX?
Reply
#2

Any one?
Reply
#3

https://sampwiki.blast.hk/wiki/GetVehicleVelocity
https://sampwiki.blast.hk/wiki/SetVehicleVelocity

Not sure what gamerX is.
Reply
#4

pawn Код:
#include <a_samp>

#define VEL_AM  1.8 //Set this to what you want, have a play with it to set the speeds.

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE){ //Check to see if the player has clicked the shooting button (Left mouse / Left CTRL as default)
        switch(GetPlayerState(playerid)) //Get the state of the player and check below.
        {
            case PLAYER_STATE_DRIVER: //Check to see if the player is the driver.
            {
                new Float:vPos[3];
                GetVehicleVelocity(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]); //Get the current velocity (speed / direction / height etc...)
                SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * VEL_AM, vy * VEL_AM, vz); //Set the vehicles velocity (EG: Add the boost!)
            }
        }
    }
    return 1;
}
If you need any help, let me know.
Reply
#5

i want rise up my speed only for front vector of car.
Reply
#6

You'll have to tetrieve the Angle of the Vehicle and based on that, a Vector pointing to the same direction.
To make the boost effective at all times you also have to calculate the current total velocity (X/Y) and make the new vector length longer than the current (else you will not speed up).

Код:
#define VELOCITY_BOOST 1.6

new Float:vx, Float:vy, Float:vz, Float:a, Float:vl;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz); // Get current Velocity
vl = floatsqroot(vx*vx + vy*vy); // Calculate X/Y Vector length to be able to calculate a Vector which is definitely higher than this
GetVehicleZAngle(GetPlayerVehicleID(playerid), a); // Get Angle
        
vx = vl * VELOCITY_BOOST * floatsin(-a, degrees); // This calculates a new Vector, pointing in the direction of a and multiplied by VELOCITY_BOOST
vy = vl * VELOCITY_BOOST * floatcos(-a, degrees);
        
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
Make sure to also limit vx, vy, vz by an absolute value, you'll be able to boost yourself out of existance very easily otherwise.

vz remains untouched but you can also multiply it by VELOCITY_BOOST if you want to.
You can also leave away the vl calculation but that will make the speed boost always have the same strength. I personally prefer stronger boosts at higher speeds.
Reply
#7

use those
https://sampwiki.blast.hk/wiki/GetVehicleVelocity
https://sampwiki.blast.hk/wiki/SetVehicleVelocity
Reply
#8

Quote:
Originally Posted by NaS
Посмотреть сообщение
You'll have to tetrieve the Angle of the Vehicle and based on that, a Vector pointing to the same direction.
To make the boost effective at all times you also have to calculate the current total velocity (X/Y) and make the new vector length longer than the current (else you will not speed up).

Код:
#define VELOCITY_BOOST 1.6

new Float:vx, Float:vy, Float:vz, Float:a, Float:vl;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz); // Get current Velocity
vl = floatsqroot(vx*vx + vy*vy); // Calculate X/Y Vector length to be able to calculate a Vector which is definitely higher than this
GetVehicleZAngle(GetPlayerVehicleID(playerid), a); // Get Angle
        
vx = vl * VELOCITY_BOOST * floatsin(-a, degrees); // This calculates a new Vector, pointing in the direction of a and multiplied by VELOCITY_BOOST
vy = vl * VELOCITY_BOOST * floatcos(-a, degrees);
        
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
Make sure to also limit vx, vy, vz by an absolute value, you'll be able to boost yourself out of existance very easily otherwise.

vz remains untouched but you can also multiply it by VELOCITY_BOOST if you want to.
You can also leave away the vl calculation but that will make the speed boost always have the same strength. I personally prefer stronger boosts at higher speeds.
ty sir but its not working perfectly like gamerX server.
Reply
#9

any one?
Reply
#10

Quote:
Originally Posted by sams90
Посмотреть сообщение
any one?
How's about instead of saying "it's not working properly", you actually say HOW it's not working properly...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)