I am guessing that when you kick a player another event is triggered
that tells that the player was kicked/left the server. You cannot have
two events fire inside each other, I am taking this from the old "net
message" code that was from HL1, you could not have two messages start
before they end.

Instead of kicking the player there, try raising a flag (try storing a
global boolean variable and the player id) and check it on startframe
(or GameFrame () as it is now in HL2 I think) when the flag is true,
kick the stored player id, then set the flag to false. In the event code
replace it with setting the boolean to true and setting the playerid to
the userid.

Mattie Casper wrote:

Hello,

I've found what seems, for me, to be a really annoying bug in CSS (and
probably
mods). The following problem happens regardless of whether you use
IGameEventListener or IGameEventListener2.

My Windows server crashes 98% of the time with the following code in a
listener/plugin:


void CEmptyServerPlugin::FireGameEvent( IGameEvent * event ) { const char * name = event->GetName(); if (FStrEq(name, "player_changename")) { if(tester_cvar.GetInt()==1) { Msg("Kicking ya.\n"); int userid = event->GetInt("userid"); char szMessage[1024]; sprintf(szMessage, "kickid %d Go away.\n", userid); engine->ServerCommand(szMessage); if (tester2_cvar.GetInt()==1) { // Crashes the server engine->ServerExecute(); } } } }

Basically, this silly code causes a player to get kicked immediately
when he
tries to change his name. He certainly does get kicked, but the server
crashes
immediately after.

This is just the sample reproduction code, but the problem shows
itself at a
much deeper point in my EventScripts plugin when users are kicked in
the middle
of an event. It can happen at times regardless of whether the event
handler is
doing the kicking (i.e. another plugin or user could be kicking the
player while
my event handlers are firing). I believe it is a timing or threading
issue
because if I place a Windows Sleep(100) after the above ServerExecute
call, the
crash usually doesn't happen.

Avoiding ServerExecute() is not really an option for me because I
truly need the
command (not necessarily kick) executed immediately (typically an exec
of a cfg
file). Regardless, the documentation places no caveats on when
ServerExecute()
can be called, so I haven't been afraid to do so when needed.

Anyone have any recommendations or thoughts here?

Thanks for your help,
-Mattie



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders





--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.3 - Release Date: 25/03/2005


_______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders



Reply via email to