I’m making a script that spawns PEDs, and want to keep control of them ( to know where are they, if they are alive, etc.)
Steps:
Server select random player and make him check / spawn PEDs
Client spawns the NPCs and send to server the NETWORK ID
Again server select random player, and sending the NETWORK ID too, to handle the PEDs.
Result:
It seems to work when close to the spawn point.
The problem:
If the client tries to find the PED by NETWORK ID when it’s too far from it, it seems imposible to get it.
Things tried:
CREATE_PED ( the last two parameters set to true true and true false)
NETWORK_GET_ENTITY_FROM_NETWORK_ID and NETWORK_GET_NETWORK_ID_FROM_ENTITY
NET_TO_PED and PED_TO_NET
DECOR_REGISTER and DECOR_SET_INT and DECOR_GET_INT and ESX.GetAllPeds ( I don’t remember the name exactly)
NETWORK_REGISTER_ENTITY_AS_NETWORKED
SET_NETWORK_ID_CAN_MIGRATE (to false or true )
SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES ( to true)
_NETWORK_SET_NETWORK_ID_DYNAMIC (to false)
…
The strange thing is that it seems posible to spawn a ped from distance, but not to get it ( even by network ID, ESX enumerate, etc…). I’ve spent lot of hours before posting here so please I need help xD
Any tip to control PED from the distance, selecting it by NETWORK ID or something similar???
R* code uses
SetEntitySomething
and
SetNetworkIdExistsOnAllMachines
the spawned entities are almost immediately available on every machine connected (no matter which distance).
But in some recent network test I was in, entities were culled for at least the host (when he spawned them) and just disappeared for both of us, while the ones I spawned were persistant for me and him.
local exists = false
local ped = nil
if config.NetId ~= nil then
NetworkRequestControlOfNetworkId(config.NetId)
NetworkRequestControlOfEntity(NetToPed(config.NetId))
if NetworkDoesNetworkIdExist(config.NetId) or DoesEntityExist(NetToPed(config.NetId)) then
local EntityCheck = NetToPed(config.NetId)
if DoesEntityExist(EntityCheck) then
ped = EntityCheck
end
exists = true
else
print( "Couldn't find NETWORK ID: " .. config.NetId)
end
end