}
}
+.int team_selected;
void LeaveSpectatorMode(entity this)
{
if(nJoinAllowed(this, this))
{
- if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (this.wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0)
+ if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || this.team_selected || (this.wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0)
{
TRANSMUTE(Player, this);
Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN);
PutClientInServer(this);
+ PlayerScore_Clear(this);
if(IS_PLAYER(this)) { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), this.netname); }
+ this.team_selected = false;
}
else
stuffcmd(this, "menu_showteamselect\n");
}
}
+bool spawnAllowed(entity this)
+{
+ if (this.version_mismatch) return false;
+ if (teamplay && lockteams) return false;
+ if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false;
+ return true;
+}
+
void ObserverThink(entity this)
{
if ( this.impulse )
}
if (this.flags & FL_JUMPRELEASED) {
- if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch && !MUTATOR_CALLHOOK(ForbidSpawn, this)) {
+ if (PHYS_INPUT_BUTTON_JUMP(this) && spawnAllowed(this)) {
this.flags &= ~FL_JUMPRELEASED;
this.flags |= FL_SPAWNING;
} else if(PHYS_INPUT_BUTTON_ATCK(this) && !this.version_mismatch) {
}
if (this.flags & FL_JUMPRELEASED) {
- if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch && !MUTATOR_CALLHOOK(ForbidSpawn, this)) {
+ if (PHYS_INPUT_BUTTON_JUMP(this) && spawnAllowed(this)) {
this.flags &= ~FL_JUMPRELEASED;
this.flags |= FL_SPAWNING;
} else if(PHYS_INPUT_BUTTON_ATCK(this) || this.impulse == 10 || this.impulse == 15 || this.impulse == 18 || (this.impulse >= 200 && this.impulse <= 209)) {
}
}
+bool spawnAllowed(entity this);
+void LeaveSpectatorMode(entity this);
void ClientCommand_join(entity caller, float request)
{
switch (request)
{
case CMD_REQUEST_COMMAND:
{
- if (IS_CLIENT(caller))
- {
- if (!IS_PLAYER(caller) && !lockteams && !gameover)
- {
- if (caller.caplayer) return;
- if (nJoinAllowed(caller, caller))
- {
- if (autocvar_g_campaign) campaign_bots_may_start = true;
- TRANSMUTE(Player, caller);
- PlayerScore_Clear(caller);
- Kill_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CPID_PREVENT_JOIN);
- Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && caller.team != -1) ? APP_TEAM_ENT(caller, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), caller.netname);
- PutClientInServer(caller);
- }
- else
- {
- // player may not join because of g_maxplayers is set
- Send_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CENTER_JOIN_PREVENT);
- }
- }
- }
+ if (!gameover)
+ if (IS_CLIENT(caller) && !IS_PLAYER(caller))
+ if (spawnAllowed(caller))
+ LeaveSpectatorMode(caller);
+
return; // never fall through to usage
}
}
}
+.int selectedteam;
void ClientCommand_selectteam(entity caller, float request, float argc)
{
switch (request)
if (selection)
{
- if (caller.team == selection && !IS_DEAD(caller))
+ if (caller.team == selection && selection != -1 && !IS_DEAD(caller))
{
sprint(caller, "^7You already are on that team.\n");
}
}
ClientKill_TeamChange(caller, selection);
}
+ if(!IS_PLAYER(caller))
+ caller.team_selected = true; // avoids asking again for team selection on join
}
}
else