Alright, 1 week, NO LUCK… the only thing i got was to get the script to spawn in only 1 vehicle by using
if NetworkIsHost() then
However, the host loses control of the veh once they leave the area and another client gets close to the veh… thus, the script thinks the entity no longer exists which is resulting in me having issues with setting the blip!
im using:
veh = CreateVehicle(vehmodel, posx, posy, posz, vehheading, true, true)
VehToNet(veh)
N_0x06faacd625d80caa(veh)
Im then sending this to the server
TriggerServerEvent("sendtoserver:vehnetid", NetworkGetNetworkIdFromEntity(veh), true)
This is what my server.lua looks like:
RegisterServerEvent("sendtoserver:vehnetid")
AddEventHandler("sendtoserver:vehnetid", function(vehid, enable)
if enable then
TriggerClientEvent("sendtoclient:vehnetid", -1, vehid, true)
end
end)
and last but not least… my client:
local vehblip = {}
RegisterNetEvent("sendtoclient:vehnetid")
AddEventHandler("sendtoclient:vehnetid", function(vehid, enable)
if enable then
Citizen.Trace(vehid)
vehblip[vehid] = AddBlipForEntity(NetworkGetEntityFromNetworkId(vehid))
end
end)
While i am able to send the NetID from the host to the server, then back to any connected client… None of the clients recognize the vehicle exists… *i double checked by using:
if NetworkDoesEntityExistWithNetworkId(NetworkGetNetworkIdFromEntity(veh)) then
Citizen.Trace("entity exists")
end
*I also tried the above method while sending the entity veh to the server and not the id, *same issues… (other clients wont recognize the veh exists)
**Also, (even if i had each client have their own vehicle spawn in… or not…) if another client gets near the veh. The closest client apparently takes control over the veh and then the host will re-spawn the vehicle as the script/host(client) thinks the veh is no longer in game… as the only way i have figured out how to check if the entity exists is by using:
if not DoesEntityExist(veh) then