Is there a way to handle map entities from the server?
I’m currently working on a “Dumpster Diver” script/job.
My idea was to pass the entity (the trashcan) though the ‘TriggerServerEvent’ function.
The entity on serverside is always 0 no matter what, have tried the ‘NetworkGetNetworkIdFromEntity’ and ‘NetworkGetEntityFromNetworkId’ but still doesn’t work.
Is it even possible to use map entities like trashcans on the server?
CLIENT
-- [ CLIENT ] --
Citizen.CreateThread( function()
Citizen.Wait( 10 )
if findDumpster() and not isSearching then
-- findDumpster() is my own function that returns dumpsterEnt if near an dumpster.
ESX.ShowHelpNotification( "Tryk ~INPUT_CONTEXT~ for at gennemsøge skraldespanden", false, true, 5000 )
if IsControlJustReleased( 0, 38 ) and IsPedOnFoot( PlayerPedId() ) then
TriggerServerEvent( "dumpsterdiver:startSearch", dumpsterEnt ) -- dumpsterEnt is the dumpster im standing near.
end
end
end)
SERVER
-- [ SERVER ] --
RegisterServerEvent( "dumpsterdiver:startSearch" )
AddEventHandler( "dumpsterdiver:startSearch", function( dumpsterEnt )
if DoesEntityExist( dumpsterEnt ) then
print( "Dumpster entity exists" )
end
end)