Page 1 of 1
player_spawn event, does it fire more than once?
Posted: Thu Oct 10, 2013 10:57 am
by BackRaw
Hi,
in EventScripts (CSS), we had to check if the team index was above 1 on player_spawn because it fired even before player_activate fired (or something like that, can't exactly remember).
Code: Select all
import es
def player_spawn(ev):
if int(ev["es_userteam"]) > 1:
# only after this if, the player actually spawned "physically", so to speak
Do we still need this check?
Btw: why doesn't [syntax="python"] .... [/syntax] work any more? Or is it just on my machine? lol
Posted: Thu Oct 10, 2013 5:10 pm
by Ayuto
Yep, but remember that es_userteam is a variable defined by EventScripts. This might be more effective:
Code: Select all
from events import Event
players = set()
@Event
def player_spawn(ev):
userid = ev.get_int('userid')
if userid not in players:
players.add(userid)
return
# Your code here...
@Event
def player_disconnect(ev):
players.discard(ev.get_int('userid'))
The syntax higlighter is broken and unfortunately La Muerte does not have the required permissions to fix that.
Posted: Fri Oct 11, 2013 3:48 am
by sicman_adrian
Can also check life state to see if there physically alive
Posted: Sat Oct 12, 2013 10:16 am
by BackRaw
sicman_adrian wrote:Can also check life state to see if there physically alive
Good point, thanks!
Posted: Tue Oct 15, 2013 10:13 am
by BackRaw
Ayuto wrote:Yep, but remember that es_userteam is a variable defined by EventScripts. This might be more effective:
Code: Select all
from events import Event
players = set()
@Event
def player_spawn(ev):
userid = ev.get_int('userid')
if userid not in players:
players.add(userid)
return
# Your code here...
@Event
def player_disconnect(ev):
players.discard(ev.get_int('userid'))
The syntax higlighter is broken and unfortunately La Muerte does not have the required permissions to fix that.
That does the half lol, I want to execute code when the player phisically spawns (the last time player_spawn fires for that player) you know? I guess the alive or team index check are the two best.
Thanks for the info on the syntax highlighter =)
Posted: Tue Oct 15, 2013 3:29 pm
by Ayuto
It actually does that. The first time a player spawns he isn't in our set. So, we add him to the set and return. After that everything after "# Your code here..." will be executed.
Posted: Thu Oct 17, 2013 8:22 am
by BackRaw
Yes but what if player_spawn fires 3 times? the first time the index gets added to the set, the second time (maybe player_activate hasn't fired yet) the code gets executed which is what I don't want lol

Posted: Thu Oct 17, 2013 5:32 pm
by Ayuto
I have never seen player_spawn firing 3 times.
Posted: Thu Oct 17, 2013 8:02 pm
by Omega_K2
Ayuto wrote:I have never seen player_spawn firing 3 times.
Might be a bug with the engine/game (or caused by other mods that force spawn people..)
Posted: Sat Oct 19, 2013 7:20 pm
by BackRaw
lol, help me on this: how many times does player_spawn fire?? twice?

Posted: Sun Oct 27, 2013 10:43 am
by XKillerBoy
Depends on how many rounds, and if you respawn players.
But just do a check if player_activate has been run first.