09.02.2013, 20:26
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
my public for RoundTime
my public for newround
Under OnGameModeInit
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.
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();
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;
}
pawn Код:
public NewRound()
{
SetTimer("RoundTime",60000*10, 0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
ForceClassSelection(i);
}
}
return 1;
}
pawn Код:
SetTimer("RoundTime",60000*10, 0);
Post here everything that needs improvement or if you see any errors.
Thanks in advance.