prevent games from being started when started already

This commit is contained in:
Lorenc Pekaj 2019-02-23 18:36:32 +11:00
parent 4ddacb8912
commit 9aab082d92

View File

@ -445,7 +445,9 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
if ( Iter_Count( battleroyaleplayers< lobbyid > ) < 2 ) { if ( Iter_Count( battleroyaleplayers< lobbyid > ) < 2 ) {
SendError( playerid, "You need at least 2 players in your lobby to start this match." ); SendError( playerid, "You need at least 2 players in your lobby to start this match." );
} else { } else {
BattleRoyale_StartGame( lobbyid ); if ( ! BattleRoyale_StartGame( lobbyid ) ) {
SendError( playerid, "This lobby has already started." );
}
} }
return BattleRoyale_EditLobby( playerid, lobbyid ); return BattleRoyale_EditLobby( playerid, lobbyid );
} }
@ -601,10 +603,16 @@ CMD:battleroyale( playerid, params[ ] )
return SendError( playerid, "You need at least 2 players in your lobby to start this match." ); return SendError( playerid, "You need at least 2 players in your lobby to start this match." );
} }
#endif #endif
if ( ! BR_IsHost( playerid, lobbyid ) ) { if ( ! BR_IsHost( playerid, lobbyid ) ) {
return SendError( playerid, "You cannot edit this lobby as you are no longer the host." ); return SendError( playerid, "You cannot edit this lobby as you are no longer the host." );
} }
return BattleRoyale_StartGame( lobbyid );
// attempt to start the game
if ( ! BattleRoyale_StartGame( lobbyid ) ) {
SendError( playerid, "This lobby has already started." );
}
return 1;
} }
else if ( strmatch ( params, "leave" ) ) else if ( strmatch ( params, "leave" ) )
{ {
@ -874,6 +882,10 @@ static stock BattleRoyale_CheckPlayers( lobbyid )
static stock BattleRoyale_StartGame( lobbyid ) static stock BattleRoyale_StartGame( lobbyid )
{ {
if ( br_lobbyData[ lobbyid ] [ E_STATUS ] == E_STATUS_STARTED ) {
return 0;
}
new areaid = br_lobbyData[ lobbyid ] [ E_AREA_ID ]; new areaid = br_lobbyData[ lobbyid ] [ E_AREA_ID ];
br_lobbyData[ lobbyid ] [ E_STATUS ] = E_STATUS_STARTED; br_lobbyData[ lobbyid ] [ E_STATUS ] = E_STATUS_STARTED;