Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 46

Thread: name , client id in menu

  1. #31
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Yeah, it's the script. This works:

    PHP Code:
    Callback_PlayerConnect()
    {
        
    thread dummy();

        
    self.statusicon "hud_status_connecting";
        
    self waittill"begin" );
        
    self.statusicon "";

        
    level notify"connected"self );

        
    self getEntityNumber();
        
        
    self setClientCvar"player_" iself.name );  
        
    self iprintlnbold"player_" );
        
    self iprintlnboldself.name );

        
    lpselfnum self getEntityNumber();
        
    lpGuid self getGuid();
        
    logPrint("J;" lpGuid ";" lpselfnum ";" self.name "\n");

        if( 
    game["state"] == "intermission" )
        {
            
    spawnIntermission();
            return;
        }
    ----------- 
    snip ---------------- 

  2. #32
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    That wont give your name as clientcvar to all clients, only to yourself

  3. #33
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    That wont give your name as clientcvar to all clients, only to yourself
    So does the other method - it only sets the cvar on a player if their entity number matches their trace in the for() loop. So, that means only to themselves. Not to everyone.

    EDIT -

    If it is truly wanted, this sets the Cvar for all players:

    PHP Code:
    Callback_PlayerConnect()
    {
        
    thread dummy();

        
    self.statusicon "hud_status_connecting";
        
    self waittill"begin" );
        
    self.statusicon "";

        
    level notify"connected"self );

        
    self getEntityNumber();
        
        
    setCvar"player_" iself.name );  

        
    self iprintlnbold"player_" );
        
    self iprintlnboldself.name );

        
    lpselfnum self getEntityNumber();
        
    lpGuid self getGuid();
        
    logPrint("J;" lpGuid ";" lpselfnum ";" self.name "\n");

        if( 
    game["state"] == "intermission" )
        {
            
    spawnIntermission();
            return;
        }

    ----------- 
    snip ---------------- 
    Last edited by Tally; 1st June 2013 at 19:59.

  4. #34
    Private
    Join Date
    Jul 2012
    Posts
    76
    Thanks
    9
    Thanked 56 Times in 38 Posts
    setCvar() will only set a server cvar, not a cvar for all players. Without setting them for every client using setClientCvar(), the names won't show up in the menu.

  5. #35
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Peterlankton View Post
    setCvar() will only set a server cvar, not a cvar for all players. Without setting them for every client using setClientCvar(), the names won't show up in the menu.
    If you mean a player wont see the value of cvar in a menu unless it is set on them as well, I know that. But I was shot down for not setting the cvar for all, so I added the edit as a bit of a joke. I don't believe Niels' original code intended to set the cvar on all players because it limits that action to whichever player has the same entity number as the loop increment. I thought this was backed up by the fact that, if you are going to use onPlayerConnect, you don't try to set a cvar on all players from there. It isn't the place to do it. You do it from some other place.

    Going on the yet unfounded assumption that Niels wanted to set the cvar on all players, if I were doing this, I would probably do something like this:

    PHP Code:
    Callback_PlayerConnect()
    {
        
    thread dummy();

        
    self.statusicon "hud_status_connecting";
        
    self waittill"begin" );
        
    self.statusicon "";

        
    level notify"connected"self );

        
    self getEntityNumber();
        
    dvar "player_" i;
        
    self setClientCvardvarself.name ); 
        
    self thread UpdateAllPLayersdvarselfself.name );

        
    self iprintlnbold"player_" );
        
    self iprintlnboldself.name );

        
    lpselfnum self getEntityNumber();
        
    lpGuid self getGuid();
        
    logPrint("J;" lpGuid ";" lpselfnum ";" self.name "\n");

        if( 
    game["state"] == "intermission" )
        {
            
    spawnIntermission();
            return;
        }

    ----------- 
    snip ---------------- 

    }

    UpdateAllPLayersdvarnewPlayername )
    {

        
    players getEntArray"player""classname" );
        for( 
    i=0players.sizei++ )
        {
            
    players players[i];
            if( 
    players == NewPlayer )
                continue;

            
    players setClientCvardvarname );
        }


    That works because I tested it. Which was the whole point to begin with - Niels' original code did not work because it was trying to set a cvar on players from onPlayerConnect and using a loop trace to find 1 player when the player was already defined. I thought that was pretty redundant, so I posted the easier way of doing that. People then interjected that it wasn't setting the dvar on all players, and that's where the whole thing got side-tracked.

    People really need to start taking notice of the POINT of a thread. Not nit picking at the smallest detail. Really does begin to get on your tits after a while.
    Last edited by Tally; 2nd June 2013 at 11:14.

  6. The Following 2 Users Say Thank You to Tally For This Useful Post:

    kung foo man (2nd June 2013),Ni3ls (2nd June 2013)

  7. #36
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Works perfectly!

  8. #37
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Try to make one player disconnect. It will not empty the string.
    Try to change your name. It will not change with you.

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

    Ni3ls (3rd June 2013)

  10. #38
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Fixed it.Everytime i open the menu I update the cvars

  11. #39
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Oh no, doesnt work. It works for the name check, but when u disconnect it stilll appears in the list

  12. #40
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Ni3ls View Post
    Oh no, doesnt work. It works for the name check, but when u disconnect it stilll appears in the list
    Create a method at Callback_PlayerDisconnect(). When the player leaves, update all players:

    PHP Code:
    Callback_PlayerDisconnect()
    {
        
    self dropFlag();

        if(!
    level.splitscreen)
            
    iprintln(&"MP_DISCONNECTED"self);

        
    dvar "player_" getEntityNumber();
        
    self thread UpdateAllPLayersDisconnectdvar );

        if(
    isdefined(self.pers["team"]))
        {
            if(
    self.pers["team"] == "allies")
                
    setplayerteamrank(self00);
            else if(
    self.pers["team"] == "axis")
                
    setplayerteamrank(self10);
            else if(
    self.pers["team"] == "spectator")
                
    setplayerteamrank(self20);
        }

        
    lpselfnum self getEntityNumber();
        
    lpGuid self getGuid();
        
    logPrint("Q;" lpGuid ";" lpselfnum ";" self.name "\n");
    }

    UpdateAllPLayersDisconnectdvar )
    {
        
    players getEntArray"player""classname" );
        for( 
    i=0players.sizei++ )
        {
            
    players[isetClientCvardvar"" );
        }


    Last edited by Tally; 3rd June 2013 at 14:00.

  13. The Following 2 Users Say Thank You to Tally For This Useful Post:

    kung foo man (3rd June 2013),Ni3ls (3rd 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
  •