I've searched around but I can't seem to find anything.
If anyone could make an addon that causes the player to become invisible while noclipping, that'd be great.
[lua]
hook.Add("PlayerNoclip","derp",function(p)
if p:IsEffectActive(EF_NODRAW) then
p:RemoveEffects(EF_NODRAW)
else
p:AddEffects(EF_NODRAW)
end
end)
[/lua]
ralle105 is 100% right, but...
[lua]
hook.Add("PlayerNoClip", "InvisibleNoClip", function(player)
if (self.IsNoDrawn == nil) then
self.IsNoDrawn = player:IsEffectActive(EF_NODRAW);
end;
if (player:GetMoveType() == MOVETYPE_NOCLIP) then
player:AddEffects(EF_NODRAW);
elseif (!self.IsNoDrawn) then
player:RemoveEffects(self.IsNoDrawn);
else
self.IsNoDrawn = nil;
end;
end);
[/lua]
For compatability amongst other things.
Thanks guys.
Hi kuro :3:
[editline]13th November 2010[/editline]
Err, neither of these seem to work. A friend told me to put it in an addon folder he had made, so I put it in the autorun part of lua:
"Hook 'InvisibleNoClip' Failed: [addons\addon_pack\lua\autorun\noclip.lua:2] attempt to index global 'self' (a nil value)"
I also put it in lua\autorun and it gave me the same error.
[QUOTE=Spacewolf;26043598]Err, neither of these seem to work. A friend told me to put it in an addon folder he had made, so I put it in the autorun part of lua:
[code]"Hook 'InvisibleNoClip' Failed: [addons\addon_pack\lua\autorun\noclip.lua:2] attempt to index global 'self' (a nil value)"[/code]
I also put it in lua\autorun and it gave me the same error.[/QUOTE]
[lua]
hook.Add("PlayerNoClip", "InvisibleNoClip", function(ply)
if (ply.IsNoDrawn == nil) then
ply.IsNoDrawn = ply:IsEffectActive(EF_NODRAW);
end
if (ply:GetMoveType() == MOVETYPE_NOCLIP) then
ply:AddEffects(EF_NODRAW);
elseif (!self.IsNoDrawn) then
ply:RemoveEffects(EF_NODRAW);
else
ply.IsNoDrawn = nil;
end
end);
[/lua]
kuro,you used a different variable name when fixing that :colbert:,also,please,don't call the variable "player"
[QUOTE=Jvs;26051293][lua]
hook.Add("PlayerNoClip", "InvisibleNoClip", function(ply)
if (ply.IsNoDrawn == nil) then
ply.IsNoDrawn = ply:IsEffectActive(EF_NODRAW);
end
if (ply:GetMoveType() == MOVETYPE_NOCLIP) then
ply:AddEffects(EF_NODRAW);
elseif (!self.IsNoDrawn) then
ply:RemoveEffects(EF_NODRAW);
else
ply.IsNoDrawn = nil;
end
end);
[/lua]
kuro,you used a different variable name when fixing that :colbert:,also,please,don't call the variable "player"[/QUOTE]
Sorry, written in browser.
And I always call the variable "player", I never have problems. Just my coding style and naming convention :(
If you need to call player.GetAll in the same function, then you will have problems.
:psyduck:...
[editline]3[/editline]
Lol how is this informative
[QUOTE=DarKSunrise;26055314]If you need to call player.GetAll in the same function, then you will have problems.[/QUOTE]
I never do need to do that, because I define local _player = player at the top of my script. Don't mind me, I just have a very strict naming convention and obsessive compulsive disorder :(
[QUOTE=.kurozael;26057028]I never do need to do that, because I define local _player = player at the top of my script. Don't mind me, I just have a very strict naming convention and obsessive compulsive disorder :([/QUOTE]
Pretty odd way to do it. More efficient though, not that it matters much at that level.
[lua]hook.Add("PlayerNoClip", "InvisibleNoClip", function(player)
if (player.IsNoDrawn == nil) then
player.IsNoDrawn = player:IsEffectActive(EF_NODRAW);
end;
if (player:GetMoveType() != MOVETYPE_NOCLIP) then
player:AddEffects(EF_NODRAW);
elseif (!player.IsNoDrawn) then
player:RemoveEffects(player.IsNoDrawn);
else
player.IsNoDrawn = nil;
end;
end);[/lua]
Using that, I no longer get a lua error, but instead of being invisible, my playermodel loses its animations and its shadow disappears. Wtf lua
Any other ideas fellas? :(
[editline]14th November 2010[/editline]
Oh damn, I didn't mean to double post.
Clientside
[lua]
hook.Add("PrePlayerDraw","invis",function(p)
if p:GetMoveType() == MOVETYPE_NOCLIP then
render.SetBlend(0)
end
end)
hook.Add("PostPlayerDraw","invis",function(p)
if p:GetMoveType() == MOVETYPE_NOCLIP then
render.SetBlend(1)
end
end)
[/lua]
What ralle105 said is the best and most efficient way.
Thanks I'll try that.
Sheesh, how can you tell by just looking at it?
[editline]15th November 2010[/editline]
Steam's not loading for me, I'll see in a bit.
[editline]15th November 2010[/editline]
It works! Hallelujah! Thanks for doing this :3:
One thing though, because it's clientside, if I send this to a friend, will it work for both of us if the other noclips or will it only work for one person?
Sorry, you need to Log In to post a reply to this thread.