1 round every 10 minutes.
#1

EDIT2: Tested my code. I made a CMD that called my public RoundTime. It sets my camera and everything, but it doesn't force me to choose a class after 10 seconds (That's my public NewRound). Any help appriciated!

So I'm scripting a TDM, and I want it so players can play 1 round every 10 minutes. After this 10 minutes, the server will tell who has won the round, and then spawn the players again for another round. I've tried to code some things, and I would like your opinion on this. If you see any mistakes, or how I can make it better/more efficient, please tell me!

My code.

forwards
pawn Код:
forward RoundTime();
forward NewRound();
my public for RoundTime
pawn Код:
public RoundTime()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetPlayerPos(i, 2025.5854,-1414.0774,16.9922);
            SetPlayerFacingAngle(i, 1132131889);
            SetPlayerCameraPos(i, -19.4675, -97.0874, 73.4148);
            SetPlayerCameraLookAt(i, -56.1921, -3.2654, 15.4479);
   
            SetTimer("NewRound", 10000, 0);
           
            if(GovKills > FarmKills)
            {
                SendClientMessageToAll(COLOR_LIGHTGREEN, "[INFO] Team Government has won this round!");
                if(gTeam[i] == TEAM_GOV)
                {
                    SendClientMessage(i, COLOR_YELLOW, "Your team won this round! (+100XP) (+500$)");
                    new score = GetPlayerScore(i) + 100;
                    SetPlayerScore(i, score);
                    GivePlayerMoney(i, 500);
                }
            }
            else if(FarmKills > GovKills)
            {
                SendClientMessageToAll(COLOR_LIGHTGREEN, "[INFO] Team Farmers has won this round!");
                if(gTeam[i] == TEAM_FARMERS)
                {
                    SendClientMessage(i, COLOR_YELLOW, "Your team won this round! (+100XP) (+500$)");
                    new score = GetPlayerScore(i) + 100;
                    SetPlayerScore(i, score);
                    GivePlayerMoney(i, 500);
                }
            }
        }
    }
    return 1;
}
my public for newround
pawn Код:
public NewRound()
{
    SetTimer("RoundTime",60000*10, 0);
   
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            ForceClassSelection(i);
        }
    }
    return 1;
}
Under OnGameModeInit
pawn Код:
SetTimer("RoundTime",60000*10, 0);
NOTE: Don't mind GovKills & FarmKills. I've already made them global variables and I tested them. (They work!)

Post here everything that needs improvement or if you see any errors.

Thanks in advance.
Reply
#2

In my eyes it's good enough to use
Reply
#3

Other than using foreach, this post was just to show off your code.
Reply
#4

Umm, no. I've just tested it and it doesn't work. I made a command that called my public RoundTime. It sets the camera pos and all, but it doesn't force me to choose a class after 10seconds. Every help appreciated!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)