Updated velocity function
#1

Adds a feature which allows you to configure and add velocity to your vehicles/players with a single keypress.

The control keys for both player and vehicle are configurable from the top of the script, two defines named PLAYER/VEHICLE_VELOCITY_KEY which you can change to whatever you like.

You can configure the power or direction you want to accelerate in by using the '/dir' & '/pow' commands, if you don't pass a param then they default to forward for direction and 1.0 for power.

Compile it as a filterscript and add it to your server config file as usuall.

Script -> Pastebin.
Requires -> zcmd by Zeex.

Compiled AMX -> Solidfiles (vel.amx, source on Pastebin).

Updated to include Player velocity and up/down directions (4,5) and you can toggle the velocity feature on and off using the '/velocity' command (no params, it toggles).
Reply
#2

Cool
Reply
#3

dose this fire the car in the direction they are faceing?
Reply
#4

Quote:
Originally Posted by V1ceC1ty
Cool
Cheers.

Quote:
Originally Posted by [mad
MLK (sampx-hosting.co.cc) ]
dose this fire the car in the direction they are faceing?
Yes if you have your direction set to forward (default).

Updated, see first post.
Reply
#5

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:

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
So the first line:

pawn Код:
AddVelocity( GetPlayerVehicleID( playerid ), 1, 0, gPower[ playerid ] ); //forwards
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:

pawn Код:
#define Y 0
#define X 1
#define Z 2
#define PLAYER 0
#define VEHICLE 1
Example:

pawn Код:
AddVelocity( GetPlayerVehicleID( playerid ), VEHICLE, Y, gPower[ playerid ] ); //forwards
@Mods:

If you think this should be part of this thread and not seperate then please move it, cheers.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)