How to make noclip allowed for admins.

I’m trying to code it so only admins can noclip. I’m thinking I have to use the PlayerNoclip hook, but I’m not sure how to use it. Any help is appreciated.

[lua]local function DisableNoclip( ply )
return ply:IsAdmin()
hook.Add(“PlayerNoClip”, “DisableNoclip”, DisableNoclip)[/lua]

I’d figure it would be that easy. Thanks a lot man, I really appreciate it.

[editline]7th April 2012[/editline]

How would I also code it so that when non-admins try to noclip, a message shows in their chat box< “You must be admin in order to noclip?”

local function DisableNoclip( ply )
if( IsValid(ply) and ply:IsPlayer() )then
if( ply:IsAdmin() )then
return true;
ply:ChatPrint(“You must be admin in order to noclip?”);
return false;

hook.Add(“PlayerNoClip”, “DisableNoclip”, DisableNoclip)

Although you might want to tinker with returning false for that hook as if you are using another admin mod, it might use another method for determining if someone is an admin.

Thanks man, you’re awesome.


edit: nvm… I was looking for rust xd

Why aren’t you using ulx or something, it would save you a lot of effort :confused: