Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: dvar not working after reopening menu

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts

    dvar not working after reopening menu

    Hi all,

    I made a menu where u can select killstreaks (for example)
    When I open the menu the first time, the error is shown in the menu via a dvar
    Code:
    self setClientCvar("warn",warn);
    But when I close the menu and open it again, the warning is not shown in the menu. I first thought it was some script error, but I added an iprint aswell so I could check the console.
    It DOES show the correct warning in the iprintln in the console.

    Code:
    			iprintln("Response: "+response+"/nWarn: "+warn);
    
    			self setClientCvar("warn",warn); 
    			wait 0.5;
    			self setClientCvar("warn","");
    How is it possible that after reopening a menu and not doing anything else, the dvar stops working?

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Show the menu and MORE code
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Code:
    handleperk(response)
    {
    	self setClientCvar("perk_warn","");
    	//showdvars of perks ["0" is for locked perk, "1" is for unlocked perk, "2" is for unlocked + selected perk]
    	warn="";
    	if(response == "perk1")
    	{
    		if(self.rank <5)
    		{	
    			warn=level.rankwarn[int(self.lang)];
    		}
    
    		else if(self.perkselect == 0 && self.perk1 == 0)
    		{
    			self.perk1=1;
    			self.perkselect =1;
    			self setClientCvar("dvar_perk_1","2");
    			warn="Select perk1: "+self.perk1+ " , Selected: "+self.perkselect;
    		}
    		else if(self.perk1 == 1)
    		{
    			self.perk1=0;
    			self.perkselect =0;
    			self setClientCvar("dvar_perk_1","1");
    			warn="Deselect perk1: "+self.perk1+ " , Selected: "+self.perkselect;
    		}
    
    		else if(self.perkselect == 1)
    		{
    			warn="Deselect first , Selected: "+self.perkselect;
    		}
    			iprintln("Response: "+response+"/nWarn: "+warn);
    
    			self setClientCvar("perk_warn",warn); 
    			wait 0.5;
    			self setClientCvar("perk_warn","");
    		
    	}
    }
    Code:
    //Perk 1
    		itemDef
    		{
    			name			perk1
    			type			ITEM_TYPE_BUTTON
    			rect			35 100 70 70
    			border			1
    			bordercolor		1 0 0 1
    			style			WINDOW_STYLE_FILLED
    			visible			1
    			textscale		.2
    			textalignx		2
    			textaligny		76
    			text			""
    		}
    
    		itemDef
    		{
    			name			"atem_locked1"
    			visible 		1
    			rect			37 102 68 68
    	 		style			WINDOW_STYLE_SHADER
    			background		"atem_perk_locked"
    			type			ITEM_TYPE_BUTTON
    			//decoration
    			dvartest		"dvar_perk_1"
    			showDvar		{ "0" }
    		}
    
    		itemDef
    		{
    			name			"atem_perk_1"
    			visible 		1
    			rect			37 102 68 68
    	 		style			WINDOW_STYLE_SHADER
    			background		"atem_perk_1"
    			type			ITEM_TYPE_BUTTON
    			//decoration
    			dvartest		"dvar_perk_1"
    			showDvar		{ "1","2" }
    		}
    
    		itemDef
    		{
    			name			"atem_perk_select1"
    			visible 		1
    			rect			87 142 25 30
    	 		style			WINDOW_STYLE_SHADER
    			background		"atem_perk_select"
    			type			ITEM_TYPE_BUTTON
    			//decoration
    			dvartest		"dvar_perk_1"
    			showDvar		{ "2" }
    		}
    		itemDef
    		{
    			name			"warn"
    			visible			1
    			textstyle		ITEM_TEXTSTYLE_SHADOWED
    			origin			320 395
    			textfont		UI_FONT_NORMAL
    			dvar			"perk_warn"
    			textalign 		ITEM_ALIGN_CENTER
    			textscale		.35
    			forecolor		1 1 0 1
    			decoration
    		}
    The other dvar is working correctly with showing the images

  4. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Im seeing you set the warn var but not pushing it to the dvar/cvar in all ifs(). Could that be the issue?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. #5
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    What do you mean? The warn is when u click on perk1 in the perkmenu. Depending on the "if" it will tell you the warning

  6. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    can you show a log of the iprintln(response) at the start of this function and a iprintln(response + "done") at the end
    Include desired behaviour and observed behaviour
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  7. #7
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by IzNoGoD View Post
    can you show a log of the iprintln(response) at the start of this function and a iprintln(response + "done") at the end
    Include desired behaviour and observed behaviour
    any results?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  8. #8
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Quote Originally Posted by IzNoGoD View Post
    any results?
    Quote Originally Posted by Ni3ls View Post
    Maybe a dumb question, but i dont understand where I should place them?
    And the dvar for the images does work, which is
    Code:
    self setClientCvar("dvar_perk_1",value);
    Dont really understand where to place them. Inside the if's?

  9. #9
    Private
    Join Date
    Jan 2013
    Location
    Hungary
    Posts
    113
    Thanks
    10
    Thanked 74 Times in 45 Posts
    After you hit the perk button, press shift+0, find something similar to "Response: "+response+"/nWarn: "+warn" and paste here what the game printed. Maybe you can put another iprintln before the "if" to make sure the script is runs.
    Oh, and comment or delete these two lines:
    PHP Code:
    wait 0.5;
    self setClientCvar("perk_warn",""); 
    I think there is no man in the world who can read the warn message in half second.

  10. #10
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Maybe a dumb question, but i dont understand where I should place them?
    And the dvar for the images does work, which is
    Code:
    self setClientCvar("dvar_perk_1",value);

Posting Permissions

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