SpawnVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
 
(23 intermediate revisions by 14 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Server function}}
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
__NOTOC__
This fake function is for use with blah & blah and does blahblahblabhalbhl
Spawns a vehicle at any given position and rotation


==Syntax==  
==Syntax==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
returnType functionName ( arguments )
bool spawnVehicle ( vehicle theVehicle, float x, float y, float z [, float rx, float ry, float rz ] )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[vehicle]]:spawn}}
===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''theVehicle:''' The vehicle you wish to spawn
*'''argumentName:''' description
*'''x:''' The x position you wish to spawn the vehicle at
*'''y:''' The x position you wish to spawn the vehicle at
*'''z:''' The x position you wish to spawn the vehicle at


<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
*'''argumentName2:''' description
*'''rx:''' The x rotation you wish to spawn the vehicle at
*'''argumentName3:''' description
*'''ry:''' The y rotation you wish to spawn the vehicle at
*'''rz:''' The z rotation you wish to spawn the vehicle at


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the vehicle spawned successfully, ''false'' if the passed argument does not exist or is not a vehicle.
Returns ''true'' if blah, ''false'' otherwise.


==Example==  
==Example==
<!-- Explain what the example is in a single sentance -->
<section name="Server" class="server" show="true">
This example does...
With this feature, we spawn vehicle
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">function myCommandHandler(thePlayer, command)
<syntaxhighlight lang="lua">
local x, y, z = getElementPosition(thePlayer)
--This line does...
local RaceVehicle = createVehicle ( 411, 0, 0, 0 )
blabhalbalhb --abababa
local spawnVeh = spawnVehicle ( RaceVehicle, x+3, y+3, z )
--This line does this...
if spawnVeh then outputChatBox("Vehicle was spawned", thePlayer) else outputChatBox("Error",thePlayer) end
mooo
end
 
addCommandHandler("spawnvehicle", myCommandHandler)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==Related scripting functions==
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{Vehicle functions}}
{{Vehicle functions}}
[[Category:Incomplete]]

Latest revision as of 01:36, 20 June 2016

Spawns a vehicle at any given position and rotation

Syntax

bool spawnVehicle ( vehicle theVehicle, float x, float y, float z [, float rx, float ry, float rz ] )

OOP Syntax Help! I don't understand this!

Method: vehicle:spawn(...)


Required Arguments

  • theVehicle: The vehicle you wish to spawn
  • x: The x position you wish to spawn the vehicle at
  • y: The x position you wish to spawn the vehicle at
  • z: The x position you wish to spawn the vehicle at

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • rx: The x rotation you wish to spawn the vehicle at
  • ry: The y rotation you wish to spawn the vehicle at
  • rz: The z rotation you wish to spawn the vehicle at

Returns

Returns true if the vehicle spawned successfully, false if the passed argument does not exist or is not a vehicle.

Example

Click to collapse [-]
Server

With this feature, we spawn vehicle

function myCommandHandler(thePlayer, command)
	local x, y, z = getElementPosition(thePlayer)
	local RaceVehicle = createVehicle ( 411, 0, 0, 0 ) 
	local spawnVeh = spawnVehicle ( RaceVehicle, x+3, y+3, z )	
	if spawnVeh	then	outputChatBox("Vehicle was spawned", thePlayer)	else	outputChatBox("Error",thePlayer)	end
end

addCommandHandler("spawnvehicle", myCommandHandler)

Related scripting functions

Shared