{"hash":"0x6AE51D4B","ns":"CFX","name":"CREATE_VEHICLE_SERVER_SETTER","slug":"CREATE_VEHICLE_SERVER_SETTER","official":true,"named":true,"luaName":"CreateVehicleServerSetter","game":"cfx","apiset":"server","returnType":"Vehicle","params":[{"name":"modelHash","type":"Hash","description":"The model of vehicle to spawn."},{"name":"type","type":"char*","description":"The appropriate vehicle type for the model info. Can be one of `automobile`, `bike`, `boat`, `heli`, `plane`, `submarine`, `trailer`, and (potentially), `train`. This should be the same type as the `type` field in `vehicles.meta`."},{"name":"x","type":"float","description":"Spawn coordinate X component."},{"name":"y","type":"float","description":"Spawn coordinate Y component."},{"name":"z","type":"float","description":"Spawn coordinate Z component."},{"name":"heading","type":"float","description":"Heading to face towards, in degrees."}],"returnsDescription":"A script handle for the vehicle, or 0 if the vehicle failed to be created.","summary":"Equivalent to CREATE_VEHICLE, but it uses 'server setter' logic (like the former CREATE_AUTOMOBILE) as a workaround for reliability concerns regarding entity creation RPC.","descriptions":[{"source":"cfx","format":"md","body":"Equivalent to CREATE_VEHICLE, but it uses 'server setter' logic (like the former CREATE_AUTOMOBILE) as a workaround for\nreliability concerns regarding entity creation RPC.\n\nUnlike CREATE_AUTOMOBILE, this supports other vehicle types as well."}],"examples":[{"lang":"lua","code":"local heli = CreateVehicleServerSetter(`seasparrow`, 'heli', GetEntityCoords(GetPlayerPed(GetPlayers()[1])) + vector3(0, 0, 15), 0.0)\nprint(GetEntityCoords(heli)) -- should return correct coordinates","source":"cfx"}],"aliases":[],"enums":[],"related":[],"sources":["cfx"],"doc":3,"url":"https://natives.borderlinerp.com/natives/CFX/CREATE_VEHICLE_SERVER_SETTER","markdownUrl":"https://natives.borderlinerp.com/natives/CFX/CREATE_VEHICLE_SERVER_SETTER.md","snippets":{"lua":"local retval = CreateVehicleServerSetter(modelHash, type, x, y, z, heading)","luaInvoke":"local retval = Citizen.InvokeNative(0x6ae51d4b, modelHash, type, x, y, z, heading, Citizen.ResultAsInteger())","js":"const retval = CreateVehicleServerSetter(modelHash, type, x, y, z, heading);","jsInvoke":"const retval = Citizen.invokeNative('0x6ae51d4b', modelHash, type, x + 0.0000001, y + 0.0000001, z + 0.0000001, heading + 0.0000001, Citizen.returnResultAnyway(), Citizen.resultAsInteger());","csharp":"int retval = Function.Call<int>((Hash)0x6ae51d4b, modelHash, type, x, y, z, heading);","notes":["Hash parameters: the named function also accepts a string and hashes it for you; `Citizen.InvokeNative` needs the number — pass `joaat(\"name\")` or a backtick literal like `` `name` ``.","Float parameters: Lua integers (`10`, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write `10.0` or `value + 0.0`. The generated JS wrappers add `0.0000001` to non-zero floats for the same reason."]}}