CreateVehicle: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
<syntaxhighlight lang="Lua"> | <syntaxhighlight lang="Lua"> | ||
int CreateVehicle(modelid, x, y, z [, heading]) | int CreateVehicle(int modelid, float x, float y, float z [, heading]) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 10:27, 23 February 2019
Syntax
int CreateVehicle(int modelid, float x, float y, float z [, heading])
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
if (PlayerData[player].vehicle ~= 0) then
DestroyVehicle(PlayerData[player].vehicle)
PlayerData[player].vehicle = 0
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
PlayerData[player].vehicle = vehicle
-- Do not change color of the taxi or police car
if (model ~= 2 and model ~= 3) then
--local color = RGB(math.random(1, 220), math.random(1, 220), math.random(1, 220))
--SetVehicleColor(vehicle, NiceColors[ math.random( #NiceColors ) ])
end
SetVehicleLicensePlate(vehicle, "HORIZON")
AttachVehicleNitro(vehicle, true)
if (model == 8) then
-- Ambulance
SetVehicleColor(vehicle, RGB(0.0, 60.0, 240.0))
SetVehicleLicensePlate(vehicle, "EMS-02")
end
SetPlayerInVehicle(player, vehicle)
AddPlayerChat(player, "Vehicle spawned! (New ID: "..vehicle..")")
end
AddCommand("v", cmd_v)