SetKeyValue not working on an env_flare? Help!

[lua]
local burnFX = ents.Create( “env_flare” )
burnFX:SetPos( self:LocalToWorld( Vector( 0, 0, 5 ) ) )
burnFX:SetParent( self )
burnFX:SetKeyValue( “scale”, 3 )
burnFX:SetKeyValue( “duration”, 600.0 )
burnFX:Spawn()
[/lua]
No matter what key value I set for Duration, it does not work. It always defaults to the 30 second life…

You need to set the key values as strings, if the scale or duration is a variable use **[G.tostring

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

scale and duration are the actual key values themselves. I have no variables. Scale works fine. Duration seems to want to give me trouble.

Just try this:


burnFX:SetKeyValue("scale", "3")
burnFX:SetKeyValue("duration", "600")

I tried that after seeing your first response. I figured that’s what you meant originaly. Sadly, no change in the duration.

Probably not gonna matter, but try uppercasing it “Duration”.

Nope. Ive tried all of the following

[lua]
burnFX:SetKeyValue( “Duration”, “600.0” )
burnFX:SetKeyValue( “Duration”, 600.0 )
burnFX:SetKeyValue( “duration”, “600.0” )
burnFX:SetKeyValue( “duration”, 600.0 )
burnFX:SetKeyValue( “Duration”, tostring(600.0) )
burnFX:SetKeyValue( “duration”, tostring(600.0) )
[/lua]
and not ONE works. I think we have an actual issue here.

just to clarify:
[lua]
burnFX:SetKeyValue( “scale”, “300” )
burnFX:SetKeyValue( “scale”, 300 )
burnFX:SetKeyValue( “scale”, tostring(300) )
[/lua]
all of those work. (Quite hilarious too…)

It seems to be just the Duration that does not want to cooperate.

[editline]13th March 2011[/editline]

Alright, I’m re-installing GarrysMod right now, My entire gamemode is fucked up, models are missing when they shouldnt be, other methods are not calling, etc. Ill let you know if this is the issue that was causing this whole ordeal once I finish re-downloading Gmod.

Ok. Reinstalled. Still fucked up. Any ideas anyone?

Are you sure that the infinite spawnflag is not set?

[lua]burnFX:Activate()[/lua]

Try adding this right after burnFX:Spawn().
It seems to be needed for some Source entities.

If that doesn’t work, the duration keyvalue might simply be broken. In this case, you can simply set the infinite spawnflag (burnFX:SetKeyValue(“spawnflags”, 4)), and then do something like this after it has spawned:

[lua]SafeRemoveEntityDelayed(burnFX, 600)[/lua]

That will remove the flare after 600 seconds.

It goes out after 30 seconds. If I had the spawnflag checked, it would never go out. Although you just gave me an idea for a temporary fix. Ill just set the “infinite” flag to true and just remove the entity after 60 seconds… Ugh. not what I wanted to do but I don’t have any other choice at the moment.

Numbers are automatically converted into strings when needed as far as I know, it really doesn’t make a difference in this situation.

Ninja >:(

-snip-

Oh well. Thanks for all the help anyway guys.