Hello everyone, I just started studying FiveM myself and I can not understand why my script does not work. The message displays, but does not create a transport. I need an answer to this question, and then I’ll figure it out myself.
Script:
AddEventHandler(“playerSpawned”, function(spawn)
TriggerEvent(“chatMessage”, “”, { 0, 0, 0 }, “hello”)
vehicle CREATE_VEHICLE(Hash 1131912276, float x = -802.311, float y = 175.056, float z = 72.8446 )
float heading, BOOL isNetwork, BOOL thisScriptCheck)
end)
to use Natives, you translate them like so CREATE_VEHICLE
= CreateVehicle
Also, enter only the parameters, not the type. There’s actually no static typing at all so even for defining a function you wouldn’t do it in LUA
This site is not for LUA?
http://www.dev-c.com/nativedb/
That site is not LUA specific. Those are decompiled GTA natives.
Luckily, the FiveM devs made it easy for you to use them. CREATE_VEHICLE
becomes CreateVehicle
.
Please have a look here at example scripts and learn from them
1 Like
but this is how the transport will be created when the server is launched? I just do not understand logic at all
AddEventHandler("playerSpawned", function(spawn)
TriggerEvent("chatMessage", "", { 0, 0, 0 }, "Hi")
end)
local hash = GetHashKey("zentorno")
RequestModel(1131912276)
while not HasModelLoaded(1131912276) do
RequestModel(1131912276)
Citizen.Wait(0)
end
local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), false))
local vehicle = CreateVehicle(hash, x + -802.311, y + 175.056, z + 72.8446, 0.0, true, false)
AddEventHandler("playerSpawned", function(spawn)
TriggerEvent("chatMessage", "", { 0, 0, 0 }, "Hi")
local hash = GetHashKey("zentorno")
local plyCoords = GetEntityCoords(GetPlayerPed(-1))
while not HasModelLoaded(hash) do
RequestModel(hash)
Citizen.Wait(100)
end
local vehicle = CreateVehicle(hash, plyCoords.x, plyCoords.y, plyCoords.z, 0.0, true, false)
end)
1 Like