Query - RPC Native `CreateVehicle`

Pretext:
I’m away from most of my hardware and using a dicky laptop to tap into my Linux Homebox (Centos8 Stream), running 43xx.

Context:
Can someone explain to me, or at least confirm for me, that if there are no players in a server, and using a rpc native CreateVehicle, as there is no one in the server, it would return the entity and NetID’s as zero?

Code I dun be test’n
Using via TxAdmin Console, so server command to server, source id as 0.

function DoTheThing(name, x, y, z, h)
    local hash = nil
    if type(name) == "number" then
        hash = name
    else
        hash = GetHashKey(name)
    end
    local vehicle = CreateVehicle(hash, x, y, z, h, true, true)
    local net = NetworkGetNetworkIdFromEntity(vehicle)
    return vehicle, net
end

RegisterCommand('c', function(source, args, rawCommand)
    TriggerEvent('txaLogger:CommandExecuted', rawCommand) -- txAdmin logging Callback
    local src = source
    local net, vehicle = DoTheThing("ADDER", 0, 0, 0, 0)
    print(src, net, vehicle)
end, true)

Returns (Pulled from TxAdmin console)

c
[      script:core] 0   0	0

c
[      script:core] 0   0	0

c
[      script:core] 0   0	0

Now am I just being a potato and forgetting that we need someone in there for the entity and netID to mean something?

Thanks in advance, and Yes, I don’t have the two braincells to clap together tonight.

CreateVehicle is an rpc native. So that tries to redirect that command to any client. However there is non. So that doesnt work.

You can try using the following code to create a vehicle without any players:

local veh = Citizen.InvokeNative(GetHashKey('CREATE_AUTOMOBILE'), modelHash, coords, heading)
1 Like

Almost a year later and another child to deplete my brain. This is again useful. Thank you.