Results 1 to 5 of 5

Thread: 2 dvartest for 1 itemdef?

  1. #1
    ... connecting
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2 dvartest for 1 itemdef?

    Hi everyone! I am trying to make some menus and I came up with a situation which an itemdef that has already a dvartest on it, to need another dvartest.

    For example I have this:

    itemDef
    {
    name"item10"
    visible1
    rect0 0 35 22
    originORIGIN_CHOICE10
    forecolorGLOBAL_UNFOCUSED_COLOR
    typeITEM_TYPE_BUTTON
    text"^3Ammo Pack"
    textfontUI_FONT_NORMAL
    textscale.30
    textstyleITEM_TEXTSTYLE_SHADOWED
    textaligny20
    dvartest"items"
    showDvar{ "10" }
    action
    {
    play "mouse_click";
    }
    onFocus
    {
    play "mouse_over";
    }
    }

    So this itemdef appears when the dvartest "items" becomes "10".
    and now I want to add to it 1 more dvartest:
    dvartest"players"
    showDvar{ "3" }

    So the itemdef to appear when both conditions are appropriate ("items" = 10 , "players" = 3). If one of them is different I want it to disappear.

    Is it possible to add 2 dvartests in the same itemdef? I tried some combinations like:
    dvartest"items"
    showDvar{ "10" }
    dvartest"players"
    showDvar{ "3" }
    or
    dvartest"items","players"
    showDvar{ "10" },{ "3" }
    but didn't worked.

    I know it is possible if I add a different menudef, and add the second dvartest into the menudef, but I am trying to find a way t avoid multiple menudefs.

    Thanks in advance!

  2. #2
    ... connecting
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone????

  3. #3
    Private
    Join Date
    Jul 2012
    Posts
    76
    Thanks
    9
    Thanked 56 Times in 38 Posts
    Why not just check in your code if(items == 10 && players == 3) and then set a boolean which you check in the itemDef.

    Some like:
    PHP Code:
    if(items == 10 && players == 3)
    {
        
    player setClientCvar("show_item10"1)
    }
    else
    {
        
    player setClientCvar("show_item10"0)

    PHP Code:
    dvartest "show_item10"
    showDvar"1" //not sure if with or without quotation marks 
    I know you want it to be easier, but I have never seen a double dvar check in menus. And this is the easiest way that by now has popped into my mind.

  4. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    or you could do a check in onopen, downside is that this will only be updated when the menu opens, and is quite hard to implement. Wont require additional cvar pushing to the client though
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. #5
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    2 cvardevs arent possible
    you could do this instead:

    for images:

    PHP Code:
    #define IMAGE_ON_DVAR( _rect , _dvar ) \
        
    itemdef \
        { \
            
    rect              _rect \
            
    dvarTest          _dvar \
            
    style              WINDOW_STYLE_DVAR_SHADER \
            
    decoration \
            
    hideDvar \
            { \
                
    ""; \
            } \
        }

    #define IMG_SIZE 640 480
    #define IMG_RECT 0 0 IMG_SIZE HORZ_ALIGN_FULLSCREEN VERT_ALIGN_FULLSCREEN
    #define IMG_DVARNAME ui_img

    IMAGE_ON_DVARIMG_RECT IMG_DVARNAME 
    or for other stuff:

    PHP Code:
    #define STUFF_ON_DVAR( _rect , _dvar , _showdvarvalues , _hidedvarvalues ) \
        
    itemdef \
        { \
            
    rect              _rect \
            
    dvarTest          _dvar \
            
    showDvar \
            { \
                
    _showdvarvalues; \
            } \
            
    hideDvar \
            { \
                
    _hidedvarvalues; \
            } \
        }

    #define STUFF_RECT 0 0 10 10 HORZALIGN VERTALIGN

    STUFF_ON_DVARSTUFF_RECT ui_stuff "0";"1";"2" "3";"4" )
    STUFF_ON_DVARSTUFF_RECT ui_stuff "3";"4" "0";"1";"2" 

Posting Permissions

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