Results 1 to 5 of 5

Thread: Some questions about Allies and Axis

  1. #1
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts

    Some questions about Allies and Axis

    Hi Guys, i want to make a zombie server.
    I have got some questions:

    How i can check that there is only one player on my server / on team axis? ( In Script )
    How i can make that the axis will be allies switched? / and the allies to axis? ( In script )

    If you can help me, please then write as coment. Thank you!

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    1)

    PHP Code:

    getDeadPlayers
    ()
    {
        
    players getentarray("player""classname");
        
    tmp = [];
        for (
    i=0i<players.sizei++)
        {
            if (
    players[i].pers["team"] == "axis" || players[i].pers["team"] == "allies")
            if (
    players[i].sessionstate != "playing")
                
    tmp[tmp.size] = players[i];
        }
        return 
    tmp;
    }



    // in your function you write:

    if (getDeadPlayers().size == 1)
        
    iprintlnbold("only one zombie roaming!"); 
    2)

    When a player dies, DON'T respawn any player. The respawn-logic needs to be handled by a gametype-thread, which is an endless loop.

    The loop is like:

    PHP Code:
    getAliveHunters()
    {
        
    players getentarray("player""classname");
        
    tmp = [];
        for (
    i=0i<players.sizei++)
        {
            if (
    players[i].pers["team"] == "allies")
            if (
    players[i].sessionstate == "playing")
                
    tmp[tmp.size] = players[i];
        }
        return 
    tmp;
    }

    while (
    1)
    {
        
    wait 0.05;
        if (
    getAliveHunters().size == 0)
        {
            
    iprintlnbold("all hunters died, round restart... or server is just empty ;D");

            
    newZombie level.lastKilled// set that always in playerkilled-callback
            // iterate over player now and respawn them as axis or allies... work for you!

        
    }
       

    You can also set game["state"] == "roundrestart" etc. to handle new connected players e.g., but I just want you to understand the basic idea. Now you should be able to work the rest out.
    timescale 0.01

  3. The Following User Says Thank You to kung foo man For This Useful Post:

    Loveboy (14th June 2013)

  4. #3
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Loveboy View Post
    Hi Guys, i want to make a zombie server.
    I have got some questions:

    How i can check that there is only one player on my server / on team axis? ( In Script )
    How i can make that the axis will be allies switched? / and the allies to axis? ( In script )

    If you can help me, please then write as coment. Thank you!
    When you say you want allies to become axis, and axis to become allies, do you mean you want the players to switch teams? Or do you mean you want attackers to become defenders, and defenders to become attackers?

    One is a team change;
    the other other is a role change.

    You need to tell us clearly what you want. You can't do both, because you will end up undoing what you set out to do: if defenders change team, and the new team they switch to are the attackers, you just made them attackers all over again. Which is kind of pointless.

  5. The Following User Says Thank You to Tally For This Useful Post:

    Loveboy (14th June 2013)

  6. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    It's a team switch on death (typical zombie mod)
    timescale 0.01

  7. The Following User Says Thank You to kung foo man For This Useful Post:

    Loveboy (14th June 2013)

  8. #5
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    This is a general method to swap players to a new team:

    PHP Code:
    swapTeams()
    {
        
    level endon"gameover" );

        
    players getentarray"player""classname" );
        for( 
    0players.sizei++ )
        {
            
    // don't do anything with spectators
            
    if( !isDefinedplayers[i].pers["team"] ) || players[i].pers["team"] == "spectator" ) continue;

            
    newTeam undefined;

            if( 
    players[i].pers["team"] == "axis" 
                
    newTeam "allies";
            else if( 
    players[i].pers["team"] == "allies" 
                
    newTeam "axis";

            
    players[i].pers["team"] = newTeam;
            
    players[i].pers["savedmodel"] = undefined;
            
    players[ithread clearWeapons();

            if( 
    newTeam == "allies" )
                
    player thread switchteams"allies" );
            else
                
    player thread switchteams"axis" );
            
        }

        
    tempscore =  game["alliedscore"];
        
    game["alliedscore"] = game["axisscore"];
        
    game["axisscore"] = tempscore;
        
    setTeamScore"allies"game["alliedscore"] );
        
    setTeamScore"axis"game["axisscore"] );
    }

    switchteamsTeam )
    {
        if( 
    self.sessionstate != "dead" )
        {
            
    self.switching_teams true;
            
    self.joining_team Team;
            
    self.leaving_team self.pers["team"];
            
    self suicide();
        }
        
        
    self.pers["team"] = Team;
        
    self.team Team;
        
    self.pers["teamTime"] = undefined;
        
    self.sessionteam self.pers["team"];
        
        
    // update spectator permissions immediately on change of team
        
    self maps\mp\gametypes\_spectating::setSpectatePermissions();
        
        
    self notify"end_respawn" );

    }

    clearWeapons()
    {
        
    self endon("disconnect");

        
    // clear standard weapons
        
    self.pers["weapon"] = undefined;
        
    self.pers["weapon1"] = undefined;
        
    self.pers["weapon2"] = undefined;
        
    self.pers["spawnweapon"] = undefined;

        
    // clear saved roundbased weapons
        
    if( isDefinedgame[self.name] ) )
        {
            if( 
    isDefinedgame[self.name]["weapon1"] ) ) 
                
    game[self.name]["weapon1"] = undefined;
            if( 
    isDefinedgame[self.name]["weapon2"] ) ) 
                
    game[self.name]["weapon2"] = undefined;
        }

    It can be easily modified if you know who the player is, because you wont have to search all players. Just pass the known player through the method, and that will switch them to a new team.

  9. The Following User Says Thank You to Tally For This Useful Post:

    kung foo man (14th June 2013)

Posting Permissions

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