PDA

View Full Version : Help with counting players!!!



xulikav
23rd July 2016, 09:31
i want to make if one player on axis and ther are one player on allies round will start ca somone help because this didnt work
i put this inside Callback_StartGameType() and didnt workk any suggestions?


while(!game["matchstarted"])
{
if(level.exist["axis"] > 0 && level.exist["allies"] > 0)
{
IPrintLnBold( "Round IS going to start" )

}
}

IzNoGoD
23rd July 2016, 10:18
You should enable developer, then see that this throws an "infinite loop error", use common sense and add a wait. Probably want to thread this as well.

xulikav
23rd July 2016, 10:54
it doesnt give me loop error since its not working XD i put it but its not working or even give me an error
how to
level.exist["axis"] > 0 its right ? it will give me how many players in axis or this is wrong shit i made?

if someone join axis it will give me 1 ? or true?

xulikav
23rd July 2016, 11:04
is this function correct?
checkMatchStart()
{
oldvalue["teams"] = level.exist["teams"];
level.exist["teams"] = false;

if(level.exist["allies"] && level.exist["axis"])
level.exist["teams"] = true;

if(!oldvalue["teams"] && level.exist["teams"])
{
if(!game["matchstarted"])
{
level notify("kill_endround");
level.roundended = false;
level thread endRound("reset");
}
else
{
level notify("kill_endround");
level.roundended = false;
level thread getTeamWinHUD("draw");
level thread endRound("draw");
}
return;
}
}

IzNoGoD
23rd July 2016, 11:16
level.exists is a custom variable which is being written to by a custom function. It could be that your code is being called before that function is started.

Saying that you're getting "an error" does NOT help at all.

xulikav
23rd July 2016, 11:56
im not getting any error i made this to find if the code doesnt work or not IPrintLnBold( "Round IS going to start" )

but its not working how to make function to check if there are players from the both sides?

Paho
23rd July 2016, 12:51
IW:

level.axis=0;
level.allies=0;
players = getentarray("player", "classname");
for(i=0;i<players.size;i++)
{
if(players[i].pers["team"]=="axis")
{
level.axis+=1;
}
if(players[i].pers["team"]=="allies")
{
level.allies+=1;
}
}
Libcod:
GetTeamPlayersAlive(<team>)
Summary:
Returns the number of players still alive on a given team
GetAssignedTeam(<player>)
Summary:
returns the player's team as assigned by matchmaking. 0 = No Team, 1 = OpFor, 2 = Allies, 3 = Spectator.
Example:
team = GetAssignedTeam(player);

xulikav
23rd July 2016, 13:57
when i insert this function and every person join axis and allies
i dont get the texst
while(1)
{
players = getentarray("player", "classname");

for(i=0;i<players.size;i++)

{
if(players[i].pers["team"]=="axis")
{
level.axis+=1;
}
if(players[i].pers["team"]=="allies")
{
level.allies+=1;
}
}

if(level.axis > 0 && level.allies > 0)
{
wait 1;
IPrintLnBold( "Round IS going to start" );

}

Paho
23rd July 2016, 14:01
use: spawnPlayer() or Callback_PlayerConnect()
not use:
Callback_StartGameType()