CreateVehicle: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server|1.0}}


{{FuncDescription|This function creates a vehicle at a desired location.}}
{{FuncDescription|__EDIT_ME__}}


{{FuncSyntax|CreateVehicle(modelid, x, y, z [, heading])}}
{{FuncSyntax|CreateVehicle(modelid, x, y, z [, h])}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|modelid|The [[Vehicles|model identifier]] for which vehicle to spawn.}}
{{FuncParam|modelid|__EDIT_ME__}}
{{FuncParam|x, y, z|The location/coordinates of where this vehicle is going to spawn.}}
{{FuncParam|x|__EDIT_ME__}}
{{FuncParamOptional|heading|The direction in which this vehicle is going to be positioned.}}
{{FuncParam|y|__EDIT_ME__}}
{{FuncParam|z |__EDIT_ME__}}
{{FuncParamOptional|h|__EDIT_ME__}}


{{FuncReturnValue|Returns an identifier to the new vehicle. '''false''' on error.}}
{{FuncReturnValue|__EDIT_ME__}}


== Example ==
== Example ==
<syntaxhighlight lang="Lua">
__EDIT_ME__
function cmd_v(player, model)
if (model == nil) then
return AddPlayerChat(player, "Usage: /v <model>")
end
 
model = tonumber(model)
 
if (model < 1 or model > 12) then
return AddPlayerChat(player, "Vehicle model "..model.." does not exist.")
end
 
local x, y, z = GetPlayerLocation(player)
local h = GetPlayerHeading(player)
 
local vehicle = CreateVehicle(model, x, y, z, h)
if (vehicle == false) then
return AddPlayerChat(player, "Failed to spawn your vehicle")
end
 
SetVehicleLicensePlate(vehicle, "HORIZON")
AttachVehicleNitro(vehicle, true)
 
if (model == 8) then
-- Set Ambulance blue color and license plate text
SetVehicleColor(vehicle, RGB(0.0, 60.0, 240.0))
SetVehicleLicensePlate(vehicle, "EMS-02")
end
 
    -- Set us in the driver seat
SetPlayerInVehicle(player, vehicle)
 
AddPlayerChat(player, "Vehicle spawned! (New ID: "..vehicle..")")
end
AddCommand("v", cmd_v)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{VehicleFunctions}}
__EDIT_ME__

Revision as of 20:13, 25 February 2019

CreateVehicle

Type: Function
Context: Server
Introduced: v1.0

Description

__EDIT_ME__

Syntax

CreateVehicle(modelid, x, y, z [, h])

Parameters

  • modelid
    __EDIT_ME__
  • x
    __EDIT_ME__
  • y
    __EDIT_ME__
  • z
    __EDIT_ME__
  • h (optional)
    __EDIT_ME__

Return Value

  • __EDIT_ME__

Example

__EDIT_ME__

See also

__EDIT_ME__