SA-MP Forums Archive
Game Mode change Bug help![rep+] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Game Mode change Bug help![rep+] (/showthread.php?tid=304834)



Game Mode change Bug help![rep+] - Ballu Miaa - 20.12.2011

I have a TDM server , My script restart's the server/change's the GM after every 30 mins! It give's BattleWin message's and save score's! Everything use to work well. But now if noone logs into the server when a Round start's of 30 minutes. The server doesnt restart automatically! It works when i go InGame and check everything. But when there is noone in the server it doesnt do anything! I've set lot of timers to Change the game mode after 30 Minutes if one timer doesnt change it. But no helps nothing works if no one in the server.
I've used both SendRconCommand("changemode CWLS") as well as GameModeExit() , I dont know what is wrong. This function use to work well! Please help


pawn Код:
// Under OnGameModeInit()
SetTimer("GameModeChanger", 30 * 60 * 1000, 0);

forward GameModeChanger();
public GameModeChanger()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            DisablePlayerCheckpoint(i);
            OnPlayerDataSave(i);
            BattleWin();
            SendClientMessage(i, 0x66a2ff97,"* The Next Battle will start soon, dont keep your weapons away!");
            TogglePlayerControllable(i, 0);
            new Float:B,Float:C,Float:D;
            GetPlayerCameraPos(i,B,C,D);
            SetPlayerCameraPos(i,B-2,C-1,D+3);
            SetTimer("Changemode", 10 * 1000 , 0);
            dini_IntSet("CW/Scores.txt", "IndiaScore", IndiaScore);
            dini_IntSet("CW/Scores.txt", "USScore", USScore);
            dini_IntSet("CW/Scores.txt", "RusScore", RusScore);
            dini_IntSet("CW/Scores.txt", "PakScore", PakScore);
            dini_IntSet("CW/Scores.txt", "UKScore", UKScore);
        }
    }
}
forward Changemode();
public Changemode()
{
    SendRconCommand("changemode CWLS");
    return 1;
}



Re: Game Mode change Bug help![rep+] - JamesC - 20.12.2011

Take SetTimer("Changemode", 10 * 1000 , 0); out of the loop. If you call it there, it will only work if a player is connected. Also, You don't need to set a timer. Just save all the data, then call the Changemode function.


Re: Game Mode change Bug help![rep+] - suhrab_mujeeb - 20.12.2011

You are using the timer inside the loop. Take it out of the loop to the head of the call back and you are done.