Network and car

Hello,
I have a small script to spawn vehicle but he the client’s log, This is the one that spam in continu the client console

SpawnVehicle

vehiclePlayer = CreateVehicle(model, coords.x, coords.y, coords.z, heading, visible)
TaskWarpPedIntoVehicle(GetPlayerPed(-1), vehiclePlayer, -1)
SetVehicleHasBeenOwnedByPlayer(vehiclePlayer, true)
local id = VehToNet(vehiclePlayer)
SetNetworkIdExistsOnAllMachines(id, true)
SetNetworkIdCanMigrate(id, true)
SetEntityAsMissionEntity(vehiclePlayer,true,true)

Log

NETWORK_GET_NETWORK_ID_FROM_ENTITY: no net object for entity
no script guid for vehicle 0 in SET_VEHICLE_HANDLING_FIELD
[   1118703] GetNetworkObject: no object by ID 4610
[   1118703] GetNetworkObject: no object by ID 4354
[   1118703] GetNetworkObject: no object by ID 4098
[   1320906] GetNetworkObject: no object by ID 354
[   1320906] GetNetworkObject: no object by ID 350
1 Like

what you after looking for script to spawn 1 car or different?

It’s for spawn several cars (script to do a custom garage)

you making a script to store cars in a garage?

not sure what u mean but hes some u can try

Where are these defined? I might be wrong but, these need to be defined.

This might not work, but you need you just need to define the model, then when you type /test it will spawn in the car and they should be warped into it, im using your natives to idk

RegisterCommand("test", function(source, args, rawCommand)
   local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(-1),true))
   local vehiclePlayer = CreateVehicle(model, x + 2, y + 2, z + 1, 0.0, true, false)
   local id = VehToNet(vehiclePlayer)

   TaskWarpPedIntoVehicle(GetPlayerPed(-1), vehiclePlayer, -1)

   SetVehicleHasBeenOwnedByPlayer(vehiclePlayer, true)
   SetNetworkIdExistsOnAllMachines(id, true)
   SetNetworkIdCanMigrate(id, true)
   SetEntityAsMissionEntity(vehiclePlayer,true,true)
end, false)

NOTE THIS WONT WORK BECAUSE YOU HAVE NOT DEFINED THE MODEL!!

this one if you just do /car default adder spawns

if do /car (NAME of car) then that car spawns - can change /cmd and default car

Summary

function ShowNotification( text )
SetNotificationTextEntry(“STRING”)
AddTextComponentSubstringPlayerName(text)
DrawNotification(false, false)
end

RegisterCommand(‘car’, function(source, args, rawCommand)
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 8.0, 0.5))
local veh = args[1]
if veh == nil then veh = “adder” end
vehiclehash = GetHashKey(veh)
RequestModel(vehiclehash)

Citizen.CreateThread(function() 
    local waiting = 0
    while not HasModelLoaded(vehiclehash) do
        waiting = waiting + 100
        Citizen.Wait(100)
        if waiting > 5000 then
            ShowNotification("~r~No such Vehicle.")
            break
        end
    end
    CreateVehicle(vehiclehash, x, y, z, GetEntityHeading(PlayerPedId())+90, 1, 0)
end)

end)

1 Like

Ok I found the probleme, It’s not a probleme with my script.
This comes from another script (noCarJack) when I make spawn a vehicle with the isNetwork parameter in false

Hey bro howd u fix it ?

Make the vehicle networked using the 5th argument in CreateVehicle (Put the 5th argument as true)