<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lordeveider+da+Silva</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lordeveider+da+Silva"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Lordeveider_da_Silva"/>
	<updated>2026-04-28T16:08:29Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetElementVelocity&amp;diff=25087</id>
		<title>GetElementVelocity</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetElementVelocity&amp;diff=25087"/>
		<updated>2011-01-13T14:47:01Z</updated>

		<summary type="html">&lt;p&gt;Lordeveider da Silva: Clarification of units used&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function returns three floats containing the velocity (movement speeds) along the X, Y, and Z axis respectively. This means that velocity values can be positive and negative for each axis. &lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;float float float getElementVelocity ( element theElement )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''theElement''': The [[element]] you wish to retrieve the velocity of.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
If succesful, returns three ''float''s that represent the element's current velocity along the ''x'', ''y'', and ''z'' axis respectively. This function can fail if the element is a player in a car. Use the vehicle element in this case. It will also fail if the element specified does not have a velocity, or does not exist. In case of failure, the first return value will be ''false''.&lt;br /&gt;
&lt;br /&gt;
The returned values are expressed in GTA units per 1/50th of a second[http://forum.mtasa.com/viewtopic.php?f=91&amp;amp;t=31225]. A GTA Unit is equal to one metre[http://gta.wikia.com/Unit#GTA3.2C_GTAVC_.26_GTASA].&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example retrieves, calculates, and displays the speed of a player named ''someguy''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- find a player named &amp;quot;someguy&amp;quot; and get his velocity.&lt;br /&gt;
speedx, speedy, speedz = getElementVelocity ( getPlayerFromNick ( &amp;quot;someguy&amp;quot; ) )&lt;br /&gt;
&lt;br /&gt;
-- use pythagorean theorem to get actual velocity&lt;br /&gt;
-- raising something to the exponent of 0.5 is the same thing as taking a square root.&lt;br /&gt;
actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) &lt;br /&gt;
&lt;br /&gt;
-- multiply by 50 to obtain the speed in metres per second&lt;br /&gt;
mps = actualspeed * 50&lt;br /&gt;
&lt;br /&gt;
-- other useful conversions&lt;br /&gt;
-- kilometres per hour&lt;br /&gt;
kmh = actualspeed * 180&lt;br /&gt;
-- miles per hour&lt;br /&gt;
mph = actualspeed * 111.847&lt;br /&gt;
&lt;br /&gt;
-- report the results.&lt;br /&gt;
outputChatBox ( &amp;quot;Someguy's current velocity: &amp;quot; .. mps .. &amp;quot; metres per second.&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{element functions}}&lt;/div&gt;</summary>
		<author><name>Lordeveider da Silva</name></author>
	</entry>
</feed>