Variable not resetting after a round.
#1

I even try to reset it several times. Under ongamemodeinit, and after a player dies and there's 1 player remaining. I also have a timer which attempts to reset it after the round ends. This is the problem:

When two+ players ready a timer till detect it, and begin a game. Once the game starts i have a message saying "Total players: amount" which displays the players in game. The first number for the player count is correct. But after starting a second round it says the total players is 4 when there's only 2 in the game.

As I've said, I've attempted resetting the variables multiple times, no solution. The variable is "players"

pawn Код:
CMD:ready(playerid, params[])
{
    if(IsPlayerReady[playerid] == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You're already ready.");
    }
    if(GameProgress == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You can't /ready when a game is in progress.");
    }
    if(intro[playerid] == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You can't /ready when in the introduction.");
    }
    players++;
    IsPlayerReady[playerid] = 1;
    LobbyCount++;
    if(LobbyCount > 1 )
    {
        SendClientMessageToAll(COLOR_GREEN, "Round starting in 10 seconds. Get ready. (/ready to enter the tournament)");
        SetTimer("RoundStartTimer", 10000, false);
    }
    new name[MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, name, sizeof(name));
    new string[128];
    format(string,sizeof(string), "%s is ready to enter the Hunger Games Tournament.",name);
    SendClientMessageToAll(COLOR_GREEN, string);
    return 1;
}
//

stock EndRound(playerid)
{
    for(new i; i != GetMaxPlayers(); i++)
    {
        GameProgress = 0;
        SetPlayerPos(playerid, -858.8223,506.0542,1511.6312);
        SetPlayerFacingAngle(playerid, 249.7519);
        SetCameraBehindPlayer(playerid);
        SetPlayerVirtualWorld(i, 0);
        SetPlayerInterior(i, 0);
        SetPlayerTeam(i, 1);
        LobbyCount = 0;
        IsPlayerReady[i] = 0;
        players = 0;
        ResetPlayerWeapons(i);
    }
    ShowNameTags(1);
    players = GetPlayerCount();
    SendClientMessage(playerid,COLOR_GREY, "Placing all players back in the lobby, please wait... (Name Tags enabled)");
    SendClientMessage(playerid,COLOR_GREY, "NOTICE: You'll need to use /ready to begin a new round. (Requires 2 people)");
    return 1;
}
//

public OnPlayerDeath(playerid, killerid, reason)
{
    ClearAnimations(playerid);
    if(GameProgress == 1) //isplayerready[playerid] == 1)
    {
        players--;
        new string[128];
        format(string,sizeof(string), "%s has been eliminated from the tournament.",GetName(playerid));
        SendClientMessageToAll(COLOR_GREY, string);
        new sstring[55];
        format(sstring,sizeof(sstring), "Total Players remaining: %d",players);
        SendClientMessageToAll(COLOR_GREY, sstring);
        IsPlayerReady[playerid] = 0;
        SetPlayerPos(playerid, -858.8223,506.0542,1511.6312);
    }
    if(players < 2)
    {
        IsPlayerReady[killerid] = 0;
        new string[128];
        format(string,sizeof(string), "%s has won the Hunger Games Tournament. They have received 10,000$.",GetName(killerid));
        SendClientMessageToAll(COLOR_GREEN, string);
        roundover = 1;
        ForceClassSelection(killerid);
        Kill(killerid);
        SetPlayerHealth(killerid, 0.0);
        GivePlayerMoney(killerid, 10000);
        players = 0;
    }
    return 1;
}
Reply
#2

Try this one if it doesnt work then show me the command that shows all of the players ingame
pawn Код:
CMD:ready(playerid, params[])
{
    if(IsPlayerReady[playerid] == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You're already ready.");
    }
    if(GameProgress == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You can't /ready when a game is in progress.");
    }
    if(intro[playerid] == 1)
    {
        return SendClientMessage(playerid,COLOR_GREY, "Error: You can't /ready when in the introduction.");
    }
    players++;
    IsPlayerReady[playerid] = 1;
    LobbyCount++;
    if(LobbyCount > 1 )
    {
        SendClientMessageToAll(COLOR_GREEN, "Round starting in 10 seconds. Get ready. (/ready to enter the tournament)");
        SetTimer("RoundStartTimer", 10000, false);
    }
    new name[MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, name, sizeof(name));
    new string[128];
    format(string,sizeof(string), "%s is ready to enter the Hunger Games Tournament.",name);
    SendClientMessageToAll(COLOR_GREEN, string);
    return 1;
}
//

stock EndRound(playerid)
{
    for(new i; i != GetMaxPlayers(); i++)
    {
        GameProgress = 0;
        SetPlayerPos(playerid, -858.8223,506.0542,1511.6312);
        SetPlayerFacingAngle(playerid, 249.7519);
        SetCameraBehindPlayer(playerid);
        SetPlayerVirtualWorld(i, 0);
        SetPlayerInterior(i, 0);
        SetPlayerTeam(i, 1);
        LobbyCount = 0;
        IsPlayerReady[i] = 0;
        players = 0;
        ResetPlayerWeapons(i);
    }
    ShowNameTags(1);
    players = GetPlayerCount();
    SendClientMessage(playerid,COLOR_GREY, "Placing all players back in the lobby, please wait... (Name Tags enabled)");
    SendClientMessage(playerid,COLOR_GREY, "NOTICE: You'll need to use /ready to begin a new round. (Requires 2 people)");
    return 1;
}
//

public OnPlayerDeath(playerid, killerid, reason)
{
    ClearAnimations(playerid);
    if(GameProgress == 1) //isplayerready[playerid] == 1)
    {
        players--;
        LobbyCount--;
        new string[128];
        format(string,sizeof(string), "%s has been eliminated from the tournament.",GetName(playerid));
        SendClientMessageToAll(COLOR_GREY, string);
        new sstring[55];
        format(sstring,sizeof(sstring), "Total Players remaining: %d",players);
        SendClientMessageToAll(COLOR_GREY, sstring);
        IsPlayerReady[playerid] = 0;
        SetPlayerPos(playerid, -858.8223,506.0542,1511.6312);
    }
    if(players < 2)
    {
        IsPlayerReady[killerid] = 0;
        new string[128];
        format(string,sizeof(string), "%s has won the Hunger Games Tournament. They have received 10,000$.",GetName(killerid));
        SendClientMessageToAll(COLOR_GREEN, string);
        roundover = 1;
        ForceClassSelection(killerid);
        Kill(killerid);
        SetPlayerHealth(killerid, 0.0);
        GivePlayerMoney(killerid, 10000);
        players = 0;
        LobbyCount = 0;
    }
    return 1;
}
Reply
#3

What'd you even do?

And there is no timer. It's all under OnPlayerDeath, as shown.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)