Make player invisible for others

Hey guys,

I want to make players invisible when entering a certain area.
like in esx_property they use instace, but i dont want to use it. I cant find a ‘direct’ answer on the forums…

Is there like a function of the forum that makes a player go invisible for others BUT NOT for himself, so its like not “no-clip”. Using instance is just not doing it for me and takes to much time.

I tried to use the native SetPlayerInvincible(PlayerId(), false) it works fine, but it also makes you invisible for yourself.

Is there a way to make the Player go invisible but only for others, when entering a certain building and when you go out it makes you visible again.

Kind Regards,

Hello,

What you could do is use the SetEntityVisible native to hide the player ped from everyone, and then use the SetPlayerVisibleLocally to show it again for the player.

Here is a small example:

RegisterCommand('invisible', function(source, args, rawCommand)
    SetEntityVisible(PlayerPedId(), false, 0)
    Citizen.CreateThread(function()
        while true do
            SetPlayerVisibleLocally(PlayerId(), true)
            Citizen.Wait(0)
        end
    end)
end, false)

Hope that helps,
Mads