Hey, i'm having a problem with this set of code:
[lua]
if self.NextHit then
owner:SetColor(20, 20, 20, 200)
else
owner:SetColor(20, 20, 20, math.min(owner:GetVelocity():Length(), 200))
return
end
[/lua]
This set of code is used in the init think fucntion for a weapon. it's supposed to make the player invisible while standing still, and visible when moving. trouble is, is that when people are/arent moving, the color flickers from visible to invisible. almost like a short-circuited lamp. it's not steady, it's random. What am i doing wrong here? Should i be running this code in the gamemode and not the weapon?
What does the "self.NextHit" variable provide?
"init think function", Do you mean the think function?
SetColor accepts a Color table, not 4 arguments. Color(20,20,20,200)
[QUOTE=Donkie;30605266]What does the "self.NextHit" variable provide?
"init think function", Do you mean the think function?
SetColor accepts a Color table, not 4 arguments. Color(20,20,20,200)[/QUOTE]
Self.NextHit determines when the next hit is, since the SWEP is a melee weapon. it's function is to make the player visible while self.NextHit is valid.
Yes, i mean the think function.
What do you mean by it accepts a color table and not 4 arguments? those 4 arguments have proven to work on many other things i've made
[QUOTE=techtuts0;30614717]Try [lua]owner:SetColor(20, 20, 20, (owner:GetVelocity():Length()>0)*200)[/lua][/QUOTE]
You can't multiply a bool by an integer without doing some debug.setmetatable magic.
[QUOTE=Kruel Kramer;30614373]
What do you mean by it accepts a color table and not 4 arguments? those 4 arguments have proven to work on many other things i've made[/QUOTE]
Ah yeah, you're right, just a personal preference. I don't think it works on draw stuff however.
Sorry, you need to Log In to post a reply to this thread.