SetPlayerInvisible
Makes a player invisible to every other player, or seen again.
Nothing of the player shows on another screen: no body, no clothes, no name plate, no horse they ride, nothing carried in their hands. Their voice is not heard and their party has no compass mark for them. Their own game is unchanged - they see and hear everyone as before, and can move, ride, chat and use commands. Server animals leave an invisible player alone, a carry they are part of ends, and nobody can carry them or be carried by them while they are hidden.
Made for admins who watch unseen, but it is the mode’s to use however it likes - nothing limits it to admins. Combine it with
SetPlayerFlying for a spectator, SetPlayerInvisibleFor to let some players (the other admins) still see them. The
name in the Tab list and their chat lines stay; hide those yourself if you want. A reload of the mode shows everyone again.
Syntax
Section titled “Syntax”SetPlayerInvisible(pid, invisible)| Parameter | Type | |
|---|---|---|
pid |
number | the player |
invisible |
boolean | true hides the player, false shows them again |
Returns
Section titled “Returns”boolean - false when not connected
Example
Section titled “Example”-- /spectate: an admin flies around unseen; the other admins still see themfunction OnPlayerCommandText(pid, cmd, args) if cmd == "spectate" and IsPlayerAdmin(pid) then local on = not IsPlayerInvisible(pid) SetPlayerInvisible(pid, on) SetPlayerFlying(pid, on) for _, other in ipairs(GetPlayers()) do if other ~= pid and IsPlayerAdmin(other) then SetPlayerInvisibleFor(pid, other, false) end end SendClientMessage(pid, COLOR_GOLD, on and "You are invisible." or "You are visible again.") return true end return falseendSee also
Section titled “See also”IsPlayerInvisible · SetPlayerInvisibleFor · IsPlayerVisibleTo · SetPlayerFlying · SetPlayerNameplateHidden · SetPlayerVirtualWorld · the Players group of the index
