JoinBestTeam(this, false); // if the team number is valid, keep it
this.playerid = playerid_save;
- if (autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0) {
- TRANSMUTE(Observer, this);
- } else {
- if (!teamplay || autocvar_g_balance_teams) {
- TRANSMUTE(Player, this);
- campaign_bots_may_start = true;
- } else {
- TRANSMUTE(Observer, this); // do it anyway
- }
- }
+ TRANSMUTE(Observer, this);
PlayerStats_GameReport_AddEvent(sprintf("kills-%d", this.playerid));
if (IS_REAL_CLIENT(this))
PrintWelcomeMessage(this);
+ #define MIN_SPEC_TIME 1
if (IS_PLAYER(this)) {
+ if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME)
+ error("Client can't be spawned as player on connection!");
if(!PlayerThink(this))
return;
}
IntermissionThink(this);
return;
}
+ else if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME + 1)
+ {
+ // don't do this in ClientConnect
+ // many things can go wrong if a client is spawned as player on connection
+ if (time > CS(this).jointime + MIN_SPEC_TIME)
+ {
+ if (MUTATOR_CALLHOOK(AutoJoinOnConnection, this)
+ || (!(autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0)
+ && (!teamplay || autocvar_g_balance_teams)))
+ {
+ campaign_bots_may_start = true;
+ Join(this);
+ return;
+ }
+ }
+ }
else if (IS_OBSERVER(this)) {
ObserverThink(this);
}
/**/
MUTATOR_HOOKABLE(ForbidSpawn, EV_ForbidSpawn);
+/** returns true if client should be put as player on connection */
+#define EV_AutoJoinOnConnection(i, o) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /**/
+MUTATOR_HOOKABLE(AutoJoinOnConnection, EV_AutoJoinOnConnection);
+
/** called when player spawns to determine whether to give them random start weapons. Return true to forbid giving them. */
#define EV_ForbidRandomStartWeapons(i, o) \
/** player */ i(entity, MUTATOR_ARGV_0_entity) \
MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver)
{
- entity player = M_ARGV(0, entity);
+ entity player = M_ARGV(0, entity);
+
+ if (!IS_PLAYER(player))
+ return true;
lms_RemovePlayer(player);
return true; // prevent team reset
{
entity player = M_ARGV(0, entity);
- TRANSMUTE(Player, player);
- campaign_bots_may_start = true;
-
if(GameRules_scoring_add(player, LMS_LIVES, LMS_NewPlayerLives()) <= 0)
{
GameRules_scoring_add(player, LMS_RANK, 666); // mark as forced spectator for the hud code
}
}
+MUTATOR_HOOKFUNCTION(lms, AutoJoinOnConnection)
+{
+ return true;
+}
+
MUTATOR_HOOKFUNCTION(lms, PlayerPreThink)
{
entity player = M_ARGV(0, entity);
MUTATOR_HOOKFUNCTION(lms, ClientCommand_Spectate)
{
- entity player = M_ARGV(0, entity);
+ entity player = M_ARGV(0, entity);
if(warmup_stage || player.lms_spectate_warning)
{