Possibly simple lua but I can't work it out?

Currently writing a gamemode. Without going into too much detail, a gun will spawn a prop, however I want a delay before it is spawned.

I was thinking of grabbing the pos that the gun is looking at, storing it values then I want a spark effect to appear for 3 seconds, then the spark can dissapear and the prop will replace it.

Question is : Is storing the player looking position the best way (I need the looking position for the initial spark and then the prop, Or could i set the props pos to the spark pos)??

&&

How on earth do I create a spark effect in lua? Can you produce hammer mapping env_sparks or would I have to code a particle system effect thing?

Also (Not sure if this is possible), can I cause every player death, regardless of dying method to create a rag doll and vaporize(like that when hit with a combine ball?)

(PS. Sorry this is poorly written, just about to go out and wrote it in a rush! Hell yeah I know, a gamer, going outside!! Wish me luck!)

Thanks in advance!

You could make a seperate entity that will spawn at the place and use a timer within the entity to spawn the weapon, for sparks you can use util.Effect().

Thanks for that, also

Also (Not sure if this is possible), can I cause every player death, regardless of dying method to create a rag doll and vaporize(like that when hit with a combine ball?)

You can find some way to deal damage to him, then in ScalePlayerDamage, (or any other hook that’s called on player taking damage and features CTakeDamageInfo as an arg,) change the damage type to DMG_DISSOLVE. If I’m correct, it’ll have to be enough damage to kill the player. Otherwise, it will just deal the damage and not dissolve him. A player should only dissolve if the damage that deals the killing blow on him is of type DMG_DISSOLVE.

**[Gamemode.ScalePlayerDamage

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.ScalePlayerDamage)**
**[CTakeDamageInfo.SetDamageType

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

EDIT: I misread your post. Sorry about that.

[lua]
hook.Add(“DoPlayerDeath”, “Dissolve On Player Death”, function(pl, attacker, dmginfo)
dmginfo:SetDamageType(DMG_DISSOLVE)
end)
[/lua]

If it’s doing things you don’t like, then you may need to override your base gamemode’s DoPlayerDeath. Remember to add a death for the player, and give the attacker frags and shit. You can also use that hook to make gibs, or really do anything on player death.

**[Gamemode.DoPlayerDeath

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