Results 1 to 9 of 9

Thread: Help with counting players!!!

  1. #1
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post

    Help with counting players!!!

    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" )

    }
    }

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    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.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. #3
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    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?

  4. #4
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    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;
    }
    }

  5. #5
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    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.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  6. #6
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    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?

  7. #7
    Private Paho's Avatar
    Join Date
    Feb 2014
    Location
    Russia
    Posts
    101
    Thanks
    43
    Thanked 48 Times in 37 Posts
    IW:
    Code:
    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);

  8. #8
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    when i insert this function and every person join axis and allies
    i dont get the texst
    PHP Code:
    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 && level.allies 0)
        {    
    wait 1;
        
    IPrintLnBold"Round IS going to start" );
        
        } 

  9. #9
    Private Paho's Avatar
    Join Date
    Feb 2014
    Location
    Russia
    Posts
    101
    Thanks
    43
    Thanked 48 Times in 37 Posts
    use: spawnPlayer() or Callback_PlayerConnect()
    not use:
    Quote Originally Posted by xulikav View Post
    Callback_StartGameType()
    Last edited by Paho; 23rd July 2016 at 14:04.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •