Add Player To Co-Host List

TooTypicalHD

Veteran
Messages
11
Reaction score
7
Points
783
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!");
}
 

The Dark Side

Former Staff Member
Messages
1,007
Reaction score
784
Points
993
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:

TheNiceUb3r

Veteran
Messages
45
Reaction score
46
Points
793
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.


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

The Dark Side

Former Staff Member
Messages
1,007
Reaction score
784
Points
993
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
Post it here for everyone! :grinning: i mean come on the list has been released for awhile now. :tonguewink: Besides im interested!
 
Last edited:

TheNiceUb3r

Veteran
Messages
45
Reaction score
46
Points
793
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:
 

zOlymP

Well-Known Member
Messages
55
Reaction score
28
Points
228
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:






I think its not work fine for me :smile:
 

aRay

Known Member
Messages
2
Reaction score
1
Points
103
the function give the player the verified status in my menu but doesnt actually give them the menu :/
 

BullyWiiPlaza

Modder
Messages
214
Reaction score
174
Points
818
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:

ezz up

New Member
Messages
4
Reaction score
1
Points
1
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
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
 

ezz up

New Member
Messages
4
Reaction score
1
Points
1
The "list" method sticks the verification between rounds and games.


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
 

BOSSAM BEMASS

Member
Messages
2
Reaction score
0
Points
11
So Anywere In The Main.gsc


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.
 
Top