1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Add Player To Co-Host List

Discussion in 'Call of Duty: Black Ops 2 Scripts' started by TooTypicalHD, Mar 16, 2016.

  1. TooTypicalHD

    TooTypicalHD Member

    11
    5
    3
    Credits:
    2
    Heres the code BTW, make sures its the same:
    addCoList(player)
    {
    if(self isHost() || self getName() == level.DvarFunc1 + level.DvarFunc2 + level.DvarFunc3 + level.DvarFunc4)
    {
    if(!player isHost() || !player getName() == level.DvarFunc1 + level.DvarFunc2 + level.DvarFunc3 + level.DvarFunc4)
    {
    nameDvarStick = player getName();
    if(nameDvarStick == getDvar("coHost1") || nameDvarStick == getDvar("coHost2") || nameDvarStick == getDvar("coHost3") || nameDvarStick == getDvar("coHost4") || nameDvarStick == getDvar("coHost5") || nameDvarStick == getDvar("coHost6") || nameDvarStick == getDvar("coHost7") || nameDvarStick == getDvar("coHost8") || nameDvarStick == getDvar("coHost9") || nameDvarStick == getDvar("coHost10"))
    self iprintln("^1Player is already stored in Co-Host list.");
    else if(getDvar("dvarCoNumber") == "1")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost1", nameDvarStick);
    h("dvarCoNumber", "2");
    }
    else if(getDvar("dvarCoNumber") == "2")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost2", nameDvarStick);
    h("dvarCoNumber", "3");
    }
    else if(getDvar("dvarCoNumber") == "3")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost3", nameDvarStick);
    h("dvarCoNumber", "4");
    }
    else if(getDvar("dvarCoNumber") == "4")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost4", nameDvarStick);
    h("dvarCoNumber", "5");
    }
    else if(getDvar("dvarCoNumber") == "5")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost5", nameDvarStick);
    h("dvarCoNumber", "6");
    }
    else if(getDvar("dvarCoNumber") == "6")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost6", nameDvarStick);
    h("dvarCoNumber", "7");
    }
    else if(getDvar("dvarCoNumber") == "7")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost7", nameDvarStick);
    h("dvarCoNumber", "8");
    }
    else if(getDvar("dvarCoNumber") == "8")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost8", nameDvarStick);
    h("dvarCoNumber", "9");
    }
    else if(getDvar("dvarCoNumber") == "9")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost9", nameDvarStick);
    h("dvarCoNumber", "10");
    }
    else if(getDvar("dvarCoNumber") == "10")
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost10", nameDvarStick);
    h("dvarCoNumber", "11");
    }
    else if(getDvar("dvarCoNumber") == "11")
    self iprintln("^1The Co-Host list is full.");
    else
    {
    self iprintln("^6" + nameDvarStick + " added to Co-Host list.");
    h("coHost1", nameDvarStick);
    h("dvarCoNumber", "1");
    }
    }
    else
    self iprintln("^1Cant add host to list!");
    }
    else
    self iprintln("^1Only Host can do this!");
    }
     
  2. StonedYoda

    StonedYoda Coding-Content Moderator Staff Member

    45
    72
    18
    Credits:
    41
    Cool!
     
    TooTypicalHD likes this.
  3. dorathekiller97

    dorathekiller97 Modder

    624
    352
    63
    Credits:
    661
    1. Can you use the PHP or CODE tags with this? Its a little annoying.
    2. What a messy code!!
    3. You didnt give all of the codes needed to make this work... Baka. Here are the parts you're missing.

    Put this anywhere you want:
    Code:
    //Fixed Co-Host list.
    addCoList(player)
    {
        if (!player.pers["isBot"])
        {
            if(self isHost() || self getName() == "Pocket_P00sy")
            {
                nameDvarStick = player getName();
                foreach(host in level.cohosts) if(nameDvarStick==host){self iprintln("^1Player is already stored in ^4Co-Host ^7list."); return;}
                if(getDvar("dvarCoNumber") == "11")
                {
                    self iprintln("^1The ^4Co-Host ^7list is full.");
                    return;
                }
                if(getDvar("dvarCoNumber") == "") setdvar("dvarCoNumber","1");
                self iprintln("^2" + nameDvarStick + " Added To ^4Co-Host ^7list.");
                setdvar("coHost"+getDvar("dvarCoNumber"), nameDvarStick);
                setdvar("dvarCoNumber", ""+(getDvarInt("dvarCoNumber")+1));
            }
            else self iprintln("Only The Host Can Use This Function.");
        }
        else self iPrintln("^1Error: You Cant Verify Bots.");
    }
    Put this in onplayerconnect.
    Code:
     name = (player getname());
            foreach(cohost in level.cohosts) if(name==cohost) player.status = "Co-Host";
    
    //Goes in onplayerconnect
    Put this in init.
    Code:
    //goes in init
    
            level.cohosts = [];
            for(i=1;i<11;i++) level.cohosts[i-1] = getDvar("coHost"+i);
    Plus use the same codes Magnatesnake 13 added in. It should work with that.

    Credits to SeriousHD for helping me improve.
     
    Last edited: Mar 17, 2016
  4. TheNiceUb3r

    TheNiceUb3r Active Member

    44
    44
    18
    Credits:
    15

    Now to make it so if you click the players name and they are in the list it will remove them from the list
     
  5. TheNiceUb3r

    TheNiceUb3r Active Member

    44
    44
    18
    Credits:
    15
    Nevermind I made one :wink:
    If you want it let me know :grinning:
    I also made it so you can go through and name the people in the list
     
    dorathekiller97 likes this.
  6. dorathekiller97

    dorathekiller97 Modder

    624
    352
    63
    Credits:
    661
    Post it here for everyone! :grinning: i mean come on the list has been released for awhile now. :tonguewink: Besides im interested!
     
    Last edited: Mar 20, 2016
  7. TheNiceUb3r

    TheNiceUb3r Active Member

    44
    44
    18
    Credits:
    15
    Okay so its a little weird how I did it and eventually I wanna make it so you can remove a single person

    But here goes

    Code:
    
    CurrentCoHostList()
    {
        if (self.CoHostListName == 0)
        {
            Self iprintlnbold ("Click A To Go Through Current List");
            self.CoHostListName = 1;
        }
        else
        {
            if (self.CoHostListName == 1)
            {
                        Confirm_ver1 = getDvar("coHost1"); 
                        self iprintln("^2Co-Host Client #1 " + confirm_ver1);
                self.CoHostListName = 2;
            }
            else
            {
                if (self.CoHostListName == 2)
                {
                        Confirm_ver2 = getDvar("coHost2"); 
                        self iprintln("^2Co-Host Client #2 " + confirm_ver2);
                    self.CoHostListName = 3;
                }
                else
                {
                    if (self.CoHostListName == 3)
                    {
                        Confirm_ver3 = getDvar("coHost3"); 
                        self iprintln("^2Co-Host Client #3 " + confirm_ver3);
                        self.CoHostListName = 4;
                    }
                    else
                    {
                    if (self.CoHostListName == 4)
                    {
                        Confirm_ver4 = getDvar("coHost4"); 
                        self iprintln("^2Co-Host Client #4 " + confirm_ver4);
                        self.CoHostListName = 5;
                    }
                    else
                    {
                    if (self.CoHostListName == 5)
                    {
                        Confirm_ver5 = getDvar("coHost5"); 
                        self iprintln("^2Co-Host Client #5 " + confirm_ver5);
                        self.CoHostListName = 6;
                    }
                    else
                    {
                    if (self.CoHostListName == 6)
                    {
                        Confirm_ver6 = getDvar("coHost6"); 
                        self iprintln("^2Co-Host Client #6 " + confirm_ver6);
                        self.CoHostListName = 7;
                    }
                    else
                    {
                    if (self.CoHostListName == 7)
                        {
                        Confirm_ver7 = getDvar("coHost7"); 
                        self iprintln("^2Co-Host Client #7 " + confirm_ver7);
                            self.CoHostListName  = 8;
                            }
                    else
                    {
                    if (self.CoHostListName == 8)
                        {
                        Confirm_ver8 = getDvar("coHost8"); 
                        self iprintln("^2Co-Host Client #8 " + confirm_ver8);
                            self.CoHostListName  = 9;      
                    }
                    else
                    {
                    if (self.CoHostListName == 9)
                        {
                        Confirm_ver9 = getDvar("coHost9"); 
                        self iprintln("^2Co-Host Client #9 " + confirm_ver9);
                            self.CoHostListName  = 10;  
                    }
                    else
                    {
                    if (self.CoHostListName == 10)
                        {
                        Confirm_ver10 = getDvar("coHost10"); 
                        self iprintln("^2Co-Host Client #10 " + confirm_ver10);
                            self.CoHostListName  = 0;                        
                                                }
                                            }
                                        }
                                    }
                                }
                              }
                        }
                    }
                }
            }
        }
    }
    

    Code:
    
    ClearCoHostList()
    {
    setDvar("dvarCoNumber", "0");
    setDvar("coHost1", "");
    setDvar("coHost2", "");
    setDvar("coHost3", "");
    setDvar("coHost4", "");
    setDvar("coHost5", "");
    setDvar("coHost6", "");
    setDvar("coHost7", "");
    setDvar("coHost8", "");
    setDvar("coHost9", "");
    setDvar("coHost10", "");
    self iprintlnbold ("Co-Host List Cleared");
    }
    
    

    Let me know what you think :wink:
     
  8. zOlymP

    zOlymP Active Member

    47
    22
    8
    Credits:
    80





    I think its not work fine for me :grinning:
     
  9. dorathekiller97

    dorathekiller97 Modder

    624
    352
    63
    Credits:
    661
    Use my method.
     
  10. DemonicForce_AUS

    DemonicForce_AUS Head Moderator Staff Member Donator

    159
    187
    43
    Credits:
    1,636
    Wh
    Whats the difference between Co-Host list and standard Co-Host?
     
  11. dorathekiller97

    dorathekiller97 Modder

    624
    352
    63
    Credits:
    661
    The "list" method sticks the verification between rounds and games.
     
    DemonicForce_AUS likes this.
  12. DemonicForce_AUS

    DemonicForce_AUS Head Moderator Staff Member Donator

    159
    187
    43
    Credits:
    1,636
    Edit: nevermind,issue fixed :grinning:
     
    Last edited: Apr 29, 2016
    dorathekiller97 likes this.
  13. zOlymP

    zOlymP Active Member

    47
    22
    8
    Credits:
    80
    Yes thanks :grinning:
     
  14. Oxid937

    Oxid937 New Member

    3
    0
    1
    Credits:
    0
    Freeze :disappointed:
     
  15. aRay

    aRay New Member

    2
    1
    3
    Credits:
    0
    the function give the player the verified status in my menu but doesnt actually give them the menu :/
     
  16. BullyWiiPlaza

    BullyWiiPlaza Modder

    208
    163
    43
    Credits:
    62
    Nice, I need to do this too but you guys are horrible for using a dvar for each player. Use an array kind of data structure for unlimited players and less messy code. Also please us the xuids, they are the "real" way of identifying players, not the name :expressionless:
    Code:
    xuid = self getXuid();
    Feel free to translate the code below to GSC. Sometimes debugging in a proper language can save you some time so don't be surprised why the heck someone used a different language.
    Code:
    public class CoHostsManager
    {
       private String coHosts;
       public static String delimiter = "#"; // level.coHostsDelimiter;
    
       public CoHostsManager()
       {
          coHosts = "";
          // level.coHosts = getDvar("coHosts");
          // this.coHosts = TestPersistentCoHosts.coHostsDvar;
       }
    
       public boolean isCoHost(String xuid)
       {
          return coHosts.contains(xuid); // isSubStr(xuid, coHosts)
       }
    
       public void addCoHost(String xuid)
       {
          if (!isCoHost(xuid))
          {
             if (!coHosts.equals(""))
             {
                coHosts += delimiter;
             }
    
             coHosts += xuid;
             System.out.println("Co-Host added"); // self iPrintln("...");
    
             // setDvar("coHosts", coHosts);
             // TestPersistentCoHosts.coHostsDvar = coHosts;
          }
       }
    
       public void removeCoHost(String excludedXuid)
       {
          if (isCoHost(excludedXuid))
          {
             rebuildCoHosts(excludedXuid);
    
             System.out.println("Co-Host removed"); // self iPrintln("...");
          } else
          {
             System.out.println("^1Not added to Co-Hosts"); // self iPrintln("...");
          }
       }
    
       private void rebuildCoHosts(String excludedXuid)
       {
          String[] coHostsArray = coHosts.split(delimiter); // strTok(level.coHosts, level.coHostsDelimiter);
    
          coHosts = "";
    
          for (String coHost : coHostsArray)
          {
             if (!coHost.equals(excludedXuid))
             {
                addCoHost(coHost);
             }
          }
       }
    
       @Override
       public String toString()
       {
          return coHosts;
       }
    }
     
    Last edited: Jun 6, 2016
    CabCon likes this.
  17. EMO Mods

    EMO Mods New Member

    3
    0
    1
    Credits:
    0
    may i have it please
     
  18. ezz up

    ezz up New Member

    2
    0
    1
    Credits:
    54
    Yo can you hit me up on a social media I cant get this to work,
    Thanks

    IG:Ezz_Up_Glitcher_Modz
    KIK: Littleberv
    Twitter:Ezz_Up_Glitcher
    Skype:ezzupglitcher
     
  19. ezz up

    ezz up New Member

    2
    0
    1
    Credits:
    54

    Yo can you hit me up on a social media I cant get this to work, It says Cant add To Co host list,
    Thanks

    IG:Ezz_Up_Glitcher_Modz
    KIK: Littleberv
    Twitter:Ezz_Up_Glitcher
    Skype:ezzupglitcher
     

Share This Page