(New to lua) Invisible Noclip function

What I’m trying to do is copy a thing that was in a roleplay mod so that it is stand-alone, and works seperately.

What the feature was is that you could type a command, and you’d go invisible, and in noclip.

I copied out the two functions and renamed the convar.

I know this is probably massively wrong, but I’d really like to get this working.



function meta:Observe( bool )
 
        self:GetTable().ObserveMode = bool;
        self:SetNoDraw( bool );
       
        if( self:GetActiveWeapon() and self:GetActiveWeapon():IsValid() ) then
                self:GetActiveWeapon():SetNoDraw( bool );
        end
       
        self:SetNotSolid( bool );
       
        if ( bool ) then
                self:SetMoveType( 8 )
                self:GodEnable();
        else
                self:SetMoveType( 2 );
                self:GodDisable();
                end
               
end
 
function AdminObserve( ply, cmd, arg )
 
        if( ply:EntIndex() ~= 0 and not ply:IsSuperAdmin() ) then return; end
       
        if( ply:GetTable().ObserveMode ) then
       
                ply:Observe( false );
               
        else
       
                ply:Observe( true );
               
        end
       
end
concommand.Add( "admin_observe", AdminObserve );


You could just set their movetype to NOCLIP and their color to 255, 255, 255, 0.

[lua]
function AdClip(ply)
if not ply:IsAdmin() then return end – Checks if player is an admin
if ply.noclip == true then – Checks if noclip is already enabled if it is then do
ply:SetNoDraw(false) – Makes the player visible
ply:SetMoveType(MOVETYPE_WALK) – Removes noclip from the player
ply.noclip = false – Tell the script noclip was not disabled
return – Stop executing any more code
end – Stop the if statement
ply:SetNoDraw(true) – Make the player invisible
ply:SetMoveType(MOVETYPE_NOCLIP) – Put the player in noclip
ply.noclip = true – Tell the script noclip is enabled
end – End the function
concommand.Add(“adclip”,AdClip) – Add a console command to enable the script
[/lua]

Untested.

You never defined meta.

facepalm you can’t set the alpha on players, use ply:SetNoDraw( true ), it’s hacky, but it works :stuck_out_tongue:

I have personally done it. So fuck off.

lol reichscript

Here’s what I have, it works, but how would I get rid of a players name?



function AdClip(ply)
    if not ply:IsSuperAdmin() then return end -- Checks if player is an admin
    if ply.noclip == true then -- Checks if noclip is already enabled if it is then do
        ply:GetActiveWeapon():SetNoDraw( false )
        ply:SetColor( 255, 255, 255, 255 ) -- Makes the player visible
        ply:SetMoveType(MOVETYPE_WALK) -- Removes noclip from the player
        ply.noclip = false -- Tell the script noclip was not disabled
        return -- Stop executing any more code
    end -- Stop the if statement
	ply:GetActiveWeapon():SetNoDraw( true )
    ply:SetColor( 255, 255, 255, 0 ) -- Make the player invisible
    ply:SetMoveType(MOVETYPE_NOCLIP) -- Put the player in noclip
    ply.noclip = true -- Tell the script noclip is enabled
end -- End the function
concommand.Add("watch",AdClip) -- Add a console command to enable the script"


If you point at the player, you can see their name.

Also, they collide with other players!

Are you using DarkRP?

Not to test it, it may end up on a DarkRP server though.

Then you cannot remove the players name from being visible without editing the core of the gamemode or object that is setting it.

Also use ply:SetNoDraw(true) instead of setting the players color.

Sounds to me like this is what you want
**[Player.Spectate

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.Spectate)**
Use OBS_MODE_ROAMING to fly around invible and OBS_MODE_NONE to go back to normal.

I tried using that method once but OBS_MODE_NONE never worked. Ended up having to respawn the player… :confused:

Sorry I lied:saddowns: Use this to go back to normal **[Player.UnSpectate

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.UnSpectate)**