if (teamkills >= autocvar_g_kick_teamkiller_lower_limit &&
teamkills >= autocvar_g_kick_teamkiller_rate*playtime/60.0)
{
- Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK_TEAMKILL, attacker.netname);
- dropclient(attacker);
+ if (dropclient_schedule(attacker))
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK_TEAMKILL, attacker.netname);
}
}
&& (IS_SPEC(this) || IS_OBSERVER(this)) && !this.caplayer
&& time > (CS(this).spectatortime + autocvar_g_maxplayers_spectator_blocktime))
{
- Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_QUIT_KICK_SPECTATING);
- dropclient(this);
- return;
+ if (dropclient_schedule(this))
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_QUIT_KICK_SPECTATING);
}
}
}
else
{
- Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK_IDLING, this.netname, maxidle_time);
- dropclient(this);
+ if (dropclient_schedule(this))
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK_IDLING, this.netname, maxidle_time);
}
return;
}
#include <server/weapons/csqcprojectile.qh>
#include <server/world.qh>
+void dropclient_do(entity this)
+{
+ if (this.owner)
+ dropclient(this.owner);
+ delete(this);
+}
+/**
+ * Schedules dropclient for a player and returns true;
+ * if dropclient is already scheduled (for that player) it does nothing and returns false.
+ *
+ * NOTE: this function exists only to allow sending a message to the kicked player with
+ * Send_Notification, which doesn't work if called together with dropclient
+ */
+bool dropclient_schedule(entity this)
+{
+ bool scheduled = false;
+ FOREACH_ENTITY_CLASS("dropclient_handler", true,
+ {
+ if(it.owner == this)
+ {
+ scheduled = true;
+ break; // can't use return here, compiler shows a warning
+ }
+ });
+ if (scheduled)
+ return false;
+
+ entity e = new_pure(dropclient_handler);
+ setthink(e, dropclient_do);
+ e.owner = this;
+ e.nextthink = time + 0.1;
+ return true;
+}
+
void CreatureFrame_hotliquids(entity this)
{
if (this.contents_damagetime >= time)
#define autocvar_slowmo cvar("slowmo")
float autocvar_sys_ticrate;
+bool dropclient_schedule(entity this);
+
/** print(), but only print if the server is not local */
void dedicated_print(string input);