Scripting/Squirrel/Functions/Vehicle.AddSpeed: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "Adds vehicle speed. == Syntax == <pre>vehicle.AddSpeed(Vector(x, y, z));</pre> == Arguments == *''float'' '''x''' - float variable in to which to store the vehicle's X vel...")
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 10: Line 10:
*''float'' '''y''' - float variable in to which to store the vehicle's Y velocity.
*''float'' '''y''' - float variable in to which to store the vehicle's Y velocity.


*''float'' '''z''' - float variable in to which to store the vehicle's X velocity.
*''float'' '''z''' - float variable in to which to store the vehicle's Z velocity.


== Example ==
== Example ==
Line 37: Line 37:
* Callbacks [[onScriptLoad]] and [[onKeyDown]] were used in this example. More info about them in the corresponding pages.
* Callbacks [[onScriptLoad]] and [[onKeyDown]] were used in this example. More info about them in the corresponding pages.
* [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx Virtual Key Codes] — a list of keys and their key codes that can be used for keybinds
* [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx Virtual Key Codes] — a list of keys and their key codes that can be used for keybinds
== Related Functions ==
{{Scripting/Squirrel/Functions/Vehicle_Functions}}
[[Category:Scripting/Squirrel/Functions/Vehicle_Functions]]

Latest revision as of 22:01, 30 January 2017

Adds vehicle speed.

Syntax

vehicle.AddSpeed(Vector(x, y, z));

Arguments

  • float x - float variable in to which to store the vehicle's X velocity.
  • float y - float variable in to which to store the vehicle's Y velocity.
  • float z - float variable in to which to store the vehicle's Z velocity.

Example

function onScriptLoad()
{
    LMB <- BindKey(true,0x01,0,0);//Button LMB = 0x01
}

function onKeyDown( player, key )
{
	if(key == LMB )
	{
		local vehicle = player.Vehicle;
		if (vehicle != null) 
		{
			vehicle.AddSpeed(Vector(vehicle.Speed.x *1.0, vehicle.Speed.y *1.0, vehicle.Speed.z *1.0));
		}
	}
	return 1;
}

Notes

  • Callbacks onScriptLoad and onKeyDown were used in this example. More info about them in the corresponding pages.
  • Virtual Key Codes — a list of keys and their key codes that can be used for keybinds

Related Functions