Page 1 of 5 123 ... LastLast
Results 1 to 10 of 46

Thread: name , client id in menu

  1. #1
    Private First Class
    Join Date
    Feb 2013
    Posts
    201
    Thanks
    4
    Thanked 10 Times in 7 Posts

    name , client id in menu

    Click image for larger version. 

Name:	shot0062.jpg 
Views:	183 
Size:	127.5 KB 
ID:	254
    how add client id and name on red territory?

  2. #2
    Private
    Join Date
    Dec 2012
    Posts
    20
    Thanks
    0
    Thanked 14 Times in 7 Posts
    it is too hard for your level

  3. #3
    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
    You can prepare 64 scriptMenuResponse-Buttons and 64 Textfields, which display 64 DVar's.

    Thats the basic idea, I guess you can already do it know, since you made that menu already.
    timescale 0.01

  4. #4
    Private First Class
    Join Date
    Feb 2013
    Posts
    201
    Thanks
    4
    Thanked 10 Times in 7 Posts
    how to do to read a player id and name?

    dvar

    self setClientCvar("id0", ID : ** , NAME : ** );

    getEntityNumber();
    player.name
    Last edited by malyczolg; 30th April 2013 at 15:50.

  5. #5
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    The only way to show any variable on a menu is through text. And the usual way to do that is with the use of a dvar. And as Kung says, you would need as many dvars as there are players. So, if you have 64 players on your server, you need 64 dvars for the name, and 64 dvars for the client entity number. And of course, you will need 128 itemDef{} to show them all (64 for the names, and 64 for the client entity number).

    Now, once you've got all that set up, to show the player's name and his entity number, you have to save the values to a dvar. Then set the dvar in the menu itemDef{}:

    Example:

    Set the Dvars:

    PHP Code:
        players getEntArray"player""classname" );
        for( 
    i=0players.sizei++ )
        {
            
    player players[i];
            
            if( 
    player getEntityNumber() == )
            {
                
    player setClientCvar"ui_player_name_" iplayer.name );
                
    player setClientCvar"ui_player_entNum_" i);
            }
        } 
    Set the itemDef{}:

    PHP Code:
    itemDef 
    {
        
    name            "player_name_1"
        
    visible        1
        rect            0 0 128 24
        origin            ORIGIN_POSITION1
        forecolor        1.000 0.647 0.290 1
        type            ITEM_TYPE_BUTTON
        dvar            
    "ui_player_name_1"
        
    textfont        UI_FONT_NORMAL
        textscale        COUNT_SIZE
        textstyle        ITEM_TEXTSTYLE_SHADOWED
        textaligny        20
        textalignx        20
        decoration

    [php]
    PHP Code:
    itemDef 
    {
        
    name            "player_entNum_1"
        
    visible        1
        rect            0 0 128 24
        origin            ORIGIN_POSITION1
        forecolor        1.000 0.647 0.290 1
        type            ITEM_TYPE_BUTTON
        dvar            
    "ui_player_entNum_1"
        
    textfont        UI_FONT_NORMAL
        textscale        COUNT_SIZE
        textstyle        ITEM_TEXTSTYLE_SHADOWED
        textaligny        20
        textalignx        20
        decoration

    Last edited by Tally; 1st May 2013 at 06:20.

  6. #6
    Private First Class
    Join Date
    Feb 2013
    Posts
    201
    Thanks
    4
    Thanked 10 Times in 7 Posts
    PHP Code:
    itemDef
    {
        
    name        p0
        type        ITEM_TYPE_BUTTON
        style        WINDOW_STYLE_FILLED
        dvar            
    "ui_player_name_1"
        
    rect        195 76 190 11
        visible        1
        mouseEnter
        
    {
            
    play "mouse_over";
            
    setitemcolor p0 backcolor 1 0 0 0.3
        
    }
        
    mouseExit
        
    {
            
    setitemcolor p0 backcolor 0 0 0 0
        
    }
        
    action
        
    {
            
    play "mouse_click";
            
    scriptmenuresponse "0"
        
    }

    PHP Code:
    Callback_PlayerConnect()
    {
        
    players getEntArray"player""classname" );
        for( 
    i=0players.sizei++ )
        {
            
    player players[i];
            
            if( 
    player getEntityNumber() == )
            {
                
    player setClientCvar"ui_player_name_" iplayer.name );
                
    player setClientCvar"ui_player_entNum_" i);
            }
        } 
    ... 
    why not work ?

  7. #7
    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
    Any error message?
    timescale 0.01

  8. #8
    Private First Class
    Join Date
    Feb 2013
    Posts
    201
    Thanks
    4
    Thanked 10 Times in 7 Posts
    no , but if i add
    PHP Code:
    player setClientCvar"ui_player_name_" i"name :" player.name ); 
    i dont have msg : name : **

  9. #9
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by malyczolg View Post
    PHP Code:
    itemDef
    {
        
    name        p0
        type        ITEM_TYPE_BUTTON
        style        WINDOW_STYLE_FILLED
        dvar            
    "ui_player_name_1"
        
    rect        195 76 190 11
        visible        1
        mouseEnter
        
    {
            
    play "mouse_over";
            
    setitemcolor p0 backcolor 1 0 0 0.3
        
    }
        
    mouseExit
        
    {
            
    setitemcolor p0 backcolor 0 0 0 0
        
    }
        
    action
        
    {
            
    play "mouse_click";
            
    scriptmenuresponse "0"
        
    }

    PHP Code:
    Callback_PlayerConnect()
    {
        
    players getEntArray"player""classname" );
        for( 
    i=0players.sizei++ )
        {
            
    player players[i];
            
            if( 
    player getEntityNumber() == )
            {
                
    player setClientCvar"ui_player_name_" iplayer.name );
                
    player setClientCvar"ui_player_entNum_" i);
            }
        } 
    ... 
    why not work ?
    You wont be able to show the result of a dvar if you use the action{} element in an itemDef{}. Also, you aren't defining the font and fontstyle and size. It wont show unless you do that.

    So, you will have to make 2 itemDef{} and use them as one. What I usually do is use the one with the action{} element to show the other, like this:

    PHP Code:
        itemDef
        
    {
            
    name            p0
            type            ITEM_TYPE_BUTTON
            dvar            
    "ui_player_name_1"
            
    rect            195 76 190 11
            type            ITEM_TYPE_BUTTON
            dvar            
    "ui_allies_assault_total"
            
    textfont        UI_FONT_NORMAL
            textscale        COUNT_SIZE
            textstyle        ITEM_TEXTSTYLE_SHADOWED
            textaligny        10
            textalignx        10
            visible            0
            decoration
        
    }
        
        
    itemDef
        
    {
            
    name            p0
            type            ITEM_TYPE_BUTTON
            rect
            visible            1
            decoration
            mouseEnter
            
    {
                
    show p0;
                
    play "mouse_over";
                
    setitemcolor p0 backcolor 1 0 0 0.3;
            }
            
    mouseExit
            
    {
                
    setitemcolor p0 backcolor 0 0 0 0;
                
    hide p0;
            }
            
    action
            
    {
                
    play "mouse_click";
                
    scriptmenuresponse "0";
            }
        } 

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

    kung foo man (1st May 2013)

  11. #10
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by malyczolg View Post
    no , but if i add
    PHP Code:
    player setClientCvar"ui_player_name_" i"name :" player.name ); 
    i dont have msg : name : **
    developer 1

    Would have crashed the server for the lack of the + between "name :" and player.name

    Even so, it is quite useless to write your OWN name to a cvar multiple times.

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

    kung foo man (1st May 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
  •