SetWindVelocity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Cleaned up the grammar & example.)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
This function changes the wind velocity in San Andreas. This affects just the trees.
This function changes the wind velocity.


==Syntax==
==Syntax==
Line 9: Line 9:


===Required Arguments===
===Required Arguments===
*'''velocityX''': The velocity on the x-coordinate
*'''velocityX''': The velocity of the wind along the x axis
*'''velocityY''': The velocity on the y-coordinate
*'''velocityY''': The velocity of the wind along the y axis
*'''velocityZ''': The velocity on the z-coordinate
*'''velocityZ''': The velocity of the wind along the z axis


===Returns===
===Returns===
Line 17: Line 17:


==Example==
==Example==
This example shows how to make a set wind velocity command.
This example shows how to make a simple /windVelocity command.
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function setVelocity(command, x, y, z)
local function windVelocityCommand(_, x, y, z)
if x and y and z then
-- Ensure all arguments are valid (default to 0 otherwise)
setWindVelocity (x, y, z)
x = tonumber(x) or 0
outputChatBox("You were set wind velocity to x: "..x.." y: "..y.." z: "..z)
y = tonumber(y) or 0
else
z = tonumber(z) or 0
outputChatBox("Syntax is: /setvelocity [x] [y] [z]")
end
-- Set the wind velocity, and inform the user of the change.
setWindVelocity(x, y, z)
outputChatBox("* Wind velocity set to ("..x..", "..y..", "..z..").", 0, 255, 0)
end
end
addCommandHandler("setvelocity", setVelocity)
addCommandHandler("windVelocity", windVelocityCommand)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 20:58, 18 April 2012

This function changes the wind velocity.

Syntax

bool setWindVelocity ( float velocityX, float velocityY, float velocityZ )

Required Arguments

  • velocityX: The velocity of the wind along the x axis
  • velocityY: The velocity of the wind along the y axis
  • velocityZ: The velocity of the wind along the z axis

Returns

Returns true if successful, false otherwise.

Example

This example shows how to make a simple /windVelocity command.

Click to collapse [-]
Client
local function windVelocityCommand(_, x, y, z)
	-- Ensure all arguments are valid (default to 0 otherwise)
	x = tonumber(x) or 0
	y = tonumber(y) or 0
	z = tonumber(z) or 0
	
	-- Set the wind velocity, and inform the user of the change.
	setWindVelocity(x, y, z)
	outputChatBox("* Wind velocity set to ("..x..", "..y..", "..z..").", 0, 255, 0)
end
addCommandHandler("windVelocity", windVelocityCommand)

See Also