07.09.2009, 09:37
Just an update to that other velocity function I released but this one is quicker and easier to understand or use I think.
I made this post seperate as it's just about the function, the other thread is for the filterscript and commands etc. This is also better for people who just want the function to put into their own scripts and not have to figure out the other script (not that it's tough, just a task I mean).
Function -> Pastebin
The arguments are:
id = the id of the player or vehicle you wish to add the velocity to (the function will fail on invalids)
type = the type of element you are going to be adding it to (player/vehicle, default is player (0))
axis = which axis do you want to add the velocity to (x,y,z, default is y (north/south))
power = how much acceleration to add to that axis (default is 1.0 (quite quick still))
Usage:
So the first line:
The arguments are:
id = the players vehicle id
type = vehicle (1)
axis = y (0)
power = gPower is currently at 1.0 so add 1.0 (positive = forward, negative is backwards on y)
A few usefull defines incase you want them also:
Example:
@Mods:
If you think this should be part of this thread and not seperate then please move it, cheers.
I made this post seperate as it's just about the function, the other thread is for the filterscript and commands etc. This is also better for people who just want the function to put into their own scripts and not have to figure out the other script (not that it's tough, just a task I mean).
Function -> Pastebin
The arguments are:
id = the id of the player or vehicle you wish to add the velocity to (the function will fail on invalids)
type = the type of element you are going to be adding it to (player/vehicle, default is player (0))
axis = which axis do you want to add the velocity to (x,y,z, default is y (north/south))
power = how much acceleration to add to that axis (default is 1.0 (quite quick still))
Usage:
pawn Код:
//ripped from my current script, the vehicle keypress
case 0: AddVelocity( GetPlayerVehicleID( playerid ), 1, 0, gPower[ playerid ] ); //forwards
case 1: AddVelocity( GetPlayerVehicleID( playerid ), 1, 0, -gPower[ playerid ] ); //backwards
case 2: AddVelocity( GetPlayerVehicleID( playerid ), 1, 1, -gPower[ playerid ] ); //left
case 3: AddVelocity( GetPlayerVehicleID( playerid ), 1, 1, gPower[ playerid ] ); //right
case 4: AddVelocity( GetPlayerVehicleID( playerid ), 1, 2, gPower[ playerid ] ); //up
case 5: AddVelocity( GetPlayerVehicleID( playerid ), 1, 2, -gPower[ playerid ] ); //down
default: AddVelocity( GetPlayerVehicleID( playerid ), 1, 0, gPower[ playerid ] ); //forwards
pawn Код:
AddVelocity( GetPlayerVehicleID( playerid ), 1, 0, gPower[ playerid ] ); //forwards
id = the players vehicle id
type = vehicle (1)
axis = y (0)
power = gPower is currently at 1.0 so add 1.0 (positive = forward, negative is backwards on y)
A few usefull defines incase you want them also:
pawn Код:
#define Y 0
#define X 1
#define Z 2
#define PLAYER 0
#define VEHICLE 1
pawn Код:
AddVelocity( GetPlayerVehicleID( playerid ), VEHICLE, Y, gPower[ playerid ] ); //forwards
If you think this should be part of this thread and not seperate then please move it, cheers.