03.05.2016, 13:11
It is a little bit hard to explain, but here we go:
I have created a team balancer that, of course, balances the teams. I have four teams in all.
So, after I start my server, and I am of course prompted to select a team. I will select Team 0 as my team, and use /count. Team 0's count will not increase. If I select another team, for example, Team 1/2/3, its count will increase. I do not understand why. Help me.
UPDATE: tInfo[pInfo[playerid][PreviousTeam]][Count]--; // ======= THIS IS NOW THE PROBLEM LINE, I AM SETTING THE PreviousTeam VARIABLE AS 99 AT ONPLAYERCONNECT BUT IT RETURNS 0!
I have created a team balancer that, of course, balances the teams. I have four teams in all.
So, after I start my server, and I am of course prompted to select a team. I will select Team 0 as my team, and use /count. Team 0's count will not increase. If I select another team, for example, Team 1/2/3, its count will increase. I do not understand why. Help me.
UPDATE: tInfo[pInfo[playerid][PreviousTeam]][Count]--; // ======= THIS IS NOW THE PROBLEM LINE, I AM SETTING THE PreviousTeam VARIABLE AS 99 AT ONPLAYERCONNECT BUT IT RETURNS 0!
Код:
enum TeamInfo { Count }; new tInfo[][TeamInfo]; public OnGameModeInIt() { for(new i = 0; i < 4; i++) return tInfo[i][Count] = 1; // I made it as 1 because the operators at OnPlayerRequestSpawn won't read 0... } public OnPlayerRequestClass(playerid, classid) { switch(classid) { case 0..2: SetPlayerTeam(playerid, 0); case 3..5: SetPlayerTeam(playerid, 1); case 6..8: SetPlayerTeam(playerid, 2); case 9..11: SetPlayerTeam(playerid, 3); } GameTextForPlayer(playerid, tInfo[GetPlayerTeam(playerid)][Name], 1000, 5); SetPlayerColor(playerid, tInfo[GetPlayerTeam(playerid)][Color]); SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraPos(playerid, 1958.3783, 1343.1572+10, 15.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); return 1; } public OnPlayerRequestSpawn(playerid) { switch(GetPlayerTeam(playerid)) { case 0: { if(tInfo[0][Count] > tInfo[1][Count] && tInfo[2][Count] && tInfo[3][Count]) { SendClientMessage(playerid, -1, ""COL_GRAY"This team is full!"); return 0; } } case 1: { if(tInfo[1][Count] > tInfo[0][Count] && tInfo[2][Count] && tInfo[3][Count]) { SendClientMessage(playerid, -1, ""COL_GRAY"This team is full!"); return 0; } } case 2: { if(tInfo[2][Count] > tInfo[1][Count] && tInfo[0][Count] && tInfo[3][Count]) { SendClientMessage(playerid, -1, ""COL_GRAY"This team is full!"); return 0; } } case 3: { if(tInfo[3][Count] > tInfo[1][Count] && tInfo[2][Count] && tInfo[0][Count]) { SendClientMessage(playerid, -1, ""COL_GRAY"This team is full!"); return 0; } } } tInfo[GetPlayerTeam(playerid)][Count]++; tInfo[pInfo[playerid][PreviousTeam]][Count]--; // ======= THIS IS NOW THE PROBLEM LINE, I AM SETTING THE PreviousTeam VARIABLE AS 99 AT ONPLAYERCONNECT BUT IT RETURNS 0! //if(tInfo[pInfo[playerid][PreviousTeam]][Count] < 1) tInfo[pInfo[playerid][PreviousTeam]][Count] = 1; pInfo[playerid][PreviousTeam] = GetPlayerTeam(playerid); return 1; } CMD:count(playerid, params[]) { new string[128]; for(new i = 0; i < 4; i++) { format(string, sizeof(string), "%s%s:%d",string,tInfo[i][Name],tInfo[i][Count]); } SendClientMessage(playerid, -1, string); return 1; }