Results 1 to 10 of 10

Thread: function send player from allies to axis randomly

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

    function send player from allies to axis randomly

    im looking for function that sends one player randomly from allies to axis

  2. #2
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    i finish it XD

    PHP Code:
    for(;;)
        {
            
    wait 1;
            if (
    calcNumOnTeam("axis") == && calcNumOnTeam("allies") >=2)
            {
                   
    players=getentarray("player","classname");
                   
    players[1moveplayer("axis");
            }  
        } 
    PHP Code:
    calcNumOnTeam(team)
    {
        
    arrayteam = [];
        
    players getentarray("player""classname");

        for(
    0players.sizei++)
        {
            if(
    isDefined(players[i].pers["team"]) && players[i].pers["team"] == team)
                
    arrayteam[arrayteam.size] = players[i];
        }

        return 
    arrayteam.size;


    PHP Code:
    moveplayer(team)
    {
        
    self.pers["team"] = team;
        
    self.sessionteam self.pers["team"];
        
    self.pers["weapon"] = undefined;
        
    self.pers["savedmodel"] = undefined;
        
    self setClientCvar("ui_allow_weaponchange""1");
        if (
    self.sessionstate!="dead"self suicide();     
        
    self notify("joined_team");
        
    self notify("end_respawn");
        
    spawnplayer();


  3. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    That's not random.

    Same amount of "random" as this:
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  4. #4
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by xulikav View Post
    PHP Code:
    for(;;)
        {
            
    wait 1;
            if (
    calcNumOnTeam("axis") == && calcNumOnTeam("allies") >=2)
            {
                   
    players=getentarray("player","classname");
                   
    players[1moveplayer("axis");
            }  
        } 
    [/PHP]
    player = players[ randomInt( players.size ) ]; might be something you want

  5. #5
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    best solution =)

    PHP Code:
    players[randomint(players.size)] moveplayer("axis"); 

  6. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Nope, that moves a random player to axis. This player could be a spectator also.

    This is better:

    PHP Code:
    while(true)
    {
        
    wait 1;
        
    players getPlayers();
        if(
    players["allies"].size >= && players["axis"].size == 0)
            
    players["allies"][randomint(players["allies"].size)] moveplayer("axis");
    }

    getPlayers()
    {
        
    ret = [];
        
    ret["spectator"] = [];
        
    ret["allies"] = [];
        
    ret["axis"] = [];
        
    players getent("player""classname");
        for(
    0players.sizei++)
            
    ret[player.pers["team"]][ret[player.pers["team"]].size] = player;
        return 
    ret;

    Last edited by IzNoGoD; 15th September 2016 at 13:16.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

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

  8. #8
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    uninitialised variable 'player': (file 'maps/mp/gametypes/_hns.gsc', line 850)

    ret[player.pers["team"]][ret[player.pers["team"]].size] = player;

    *

  9. #9
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    replace all occurences of player with players
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  10. #10
    Private
    Join Date
    Jul 2016
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post
    its buggy i made it but everything fucked up my clock in the game i start getting killcam and the function i didnt even test it if it works or not but since its buggy

Posting Permissions

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