Velocity Tutorial
From SA-MP Wiki
How to use Velocity Functions
Creating a script to Jump 10ft in a car or drive at the speed of light without hacks is easy with SetPlayerVelocity(); and OnPlayerKeyStateChange()
First, let's start off by adding the Defines and a timer.
#include <a_samp> #define PRESSED(%0) \ (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) new Tick[MAX_PLAYERS]; public OnPlayerUpdate(playerid) { Tick[playerid]++; if(Tick[playerid] != 3) return 1; Tick[playerid] = 0; new Keys,up,down; GetPlayerKeys(playerid,Keys,up,down); new Float:x,Float:y,Float:z; if(Keys &= 1024) { if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { GetPlayerVelocity(playerid,x,y,z); SetPlayerVelocity(playerid,x*1.2,y*1.2,z*1.2); } } else if(Keys &= 4) { if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z); SetVehicleVelocity(GetPlayerVehicleID(playerid),x*1.2,y*1.2,z*1.2); } } return 1; }
This next part will show you how you can use another key to make your car jump 10ft in the air.
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if (PRESSED(KEY_HANDBRAKE)) // Change KEY_HANDBRAKE to your choice of PlayerKeys { new Float:x, Float:y, Float:z; GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z); SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3); } return 1; }
With that all added all you need to do is hold down Left Alt while in a car to use the Speedboost, players can use this on foot but cannot be touching the ground while doing so. Press you Handbrake key(mostlikely Spacebar) to jump in your car.