hook.Add('PlayerNoClip', 'ba.PlayerNoClip', function(pl, state)
if SERVER and pl:HasAccess('a') then
local bool = ba.canAdmin(pl) and (pl:GetBVar('CanNoclip') ~= false) or false
if bool then hook.Run("OnPlayerNoclip", pl, state) end
return bool
elseif CLIENT then
if pl:HasAccess('a') and pl:GetBVar('CanNoclip') ~= false then
local oldMove = pl:GetMoveType()
timer.Simple(0.1, function()
if IsValid(pl) then
local newMove = pl:GetMoveType()
if (oldMove == MOVETYPE_NOCLIP or newMove == MOVETYPE_NOCLIP) and oldMove ~= newMove then
hook.Run("OnPlayerNoclip", pl, state)
end
end
end)
end
return false
end
end)
if SERVER then
hook.Add('OnPlayerNoclip', 'HandleNoclipInvisibility', function(pl, state)
if state then
pl.WasNotDrawing = pl:GetNoDraw()
pl:SetNoDraw(true)
pl:SetRenderMode(RENDERMODE_TRANSALPHA)
pl:SetMaterial("models/dog/eyeglass")
pl:SetColor(Color(255, 255, 150))
else
if not pl.WasNotDrawing then
pl:SetNoDraw(false)
pl:SetMaterial("")
pl:SetColor(Color(255, 255, 255))
end
pl.WasNotDrawing = nil
end
end)
end