Hi guys,
I remember using EventScripts it was possible to spawn smoke on the map (either an entity or the smokegrenade's smoke somehow) and change its color, I guess it was some kind of a toxic gas addon.
Can we do some type of this using SP yet?
Colored Smoke
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
The following code seems to work on Counter-Strike: Source. However, you cannot change the color of this entity. If you want a green colored smoke, you will have to reproduce the entire effect using env_smokestack or either simulate the color using a env_spotlight.
Syntax: Select all
from events import Event
from players.helpers import playerinfo_from_userid
from tools import server_tools
from mathlib import Vector
from entities.entity import BaseEntity
from listeners.tick import tick_delays
def create_smoke(origin, fade_start=15, duration=20):
entity = BaseEntity(
server_tools.create_entity('env_particlesmokegrenade'))
entity.set_key_value_vector('origin', origin)
entity.set_prop_float('m_FadeStartTime', fade_start)
entity.set_prop_float('m_FadeEndTime', duration)
server_tools.spawn_entity(entity.index)
# The game is setting this to 0 the time to play the detonating sound and
# then, set it to 1 to render the smoke effect...
entity.set_prop_int('m_CurrentStage', 1)
# Here we should take care to store the delay and cancel it when the
# current round is ending to avoid removing an invalid entity...
tick_delays.delay(duration, server_tools.remove_entity, entity.index)
@Event
def player_jump(game_event):
origin = playerinfo_from_userid(
game_event.get_int('userid')).get_abs_origin()
# Create a smoke effect that start fading after 1 second and get removed
# after 5 seconds...
create_smoke(origin, 1, 5)
Instead of server_tools.remove_entity you should use
because it's more stable (at least n CS:S).
Syntax: Select all
entity.Kill()
because it's more stable (at least n CS:S).
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Interesting. Could you please test the following and let me know if that fixes the crashes?qazuar wrote:server_tools.remove_entity seems to crash on CSGO, atleast in my case it does.
Syntax: Select all
entity.set_key_value_int('hammerid', entity.index)
server_tools.remove_entity(entity.index)
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
It is not fully right. It was, on EventScripts cause it was relying on a client executing the cheat command ent_fire on a valid target name (which means no entity was killed if the name was not matching any entity while looking for it). But on SP, we are parsing the datamap of the entity and call the CBaseEntity::InputKill function dynamically and if you check that function, you will see that it does nothing else than noticing owner and calling UTIL_Remove (which is wrapped by IServerTools::RemoveEntity) on the given pointer.Hedgehog wrote:Instead of server_tools.remove_entity you should useSyntax: Select all
entity.Kill()
because it's more stable (at least n CS:S).
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
L'In20Cible wrote:The following code seems to work on Counter-Strike: Source.However, you cannot change the color of this entity. If you want a green colored smoke, you will have to reproduce the entire effect using env_smokestack or either simulate the color using a env_spotlight.Syntax: Select all
from events import Event
from players.helpers import playerinfo_from_userid
from tools import server_tools
from mathlib import Vector
from entities.entity import BaseEntity
from listeners.tick import tick_delays
def create_smoke(origin, fade_start=15, duration=20):
entity = BaseEntity(
server_tools.create_entity('env_particlesmokegrenade'))
entity.set_key_value_vector('origin', origin)
entity.set_prop_float('m_FadeStartTime', fade_start)
entity.set_prop_float('m_FadeEndTime', duration)
server_tools.spawn_entity(entity.index)
# The game is setting this to 0 the time to play the detonating sound and
# then, set it to 1 to render the smoke effect...
entity.set_prop_int('m_CurrentStage', 1)
# Here we should take care to store the delay and cancel it when the
# current round is ending to avoid removing an invalid entity...
tick_delays.delay(duration, server_tools.remove_entity, entity.index)
@Event
def player_jump(game_event):
origin = playerinfo_from_userid(
game_event.get_int('userid')).get_abs_origin()
# Create a smoke effect that start fading after 1 second and get removed
# after 5 seconds...
create_smoke(origin, 1, 5)
Awesome! I'll look into it.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 130 guests