PDA

View Full Version : dvar not working after reopening menu



Ni3ls
20th August 2015, 12:44
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

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.


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?

IzNoGoD
20th August 2015, 14:08
Show the menu and MORE code

Ni3ls
20th August 2015, 14:25
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","");

}
}


//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

IzNoGoD
20th August 2015, 14:58
Im seeing you set the warn var but not pushing it to the dvar/cvar in all ifs(). Could that be the issue?

Ni3ls
20th August 2015, 15:36
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

IzNoGoD
20th August 2015, 15:43
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

Ni3ls
20th August 2015, 16:27
Maybe a dumb question, but i dont understand where I should place them?
And the dvar for the images does work, which is

self setClientCvar("dvar_perk_1",value);

Tally
20th August 2015, 16:32
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


That shows a dvar "perk_warn". Is this the one you say shows the warning? Because if it is, it isn't working the second time you open the menu because you aren't setting the right dvar. I see your dvar as "warn". Shouldn't it be "perk_warn"?

Maybe I missed something.

Ni3ls
20th August 2015, 16:40
Yeah in the first post i used only warn, but I modified to script to perk_warn. The script in my 3th post is the correct script, with correct clientcvars /dvars.
So I use perk_warn in the menu and also in the setclientcvar

IzNoGoD
20th August 2015, 19:44
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?

Ni3ls
21st August 2015, 11:52
any results?


Maybe a dumb question, but i dont understand where I should place them?
And the dvar for the images does work, which is

self setClientCvar("dvar_perk_1",value);

Dont really understand where to place them. Inside the if's?

randall
21st August 2015, 13:03
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:

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.

Ni3ls
22nd August 2015, 10:22
When I open the menu for the first time and select perk1, I see the warn message inside the menu and as iprintln

WARNING: Non-localized Game Message string is not allowed to have letters in it. Must be changed over to a localized string: "Response: perk1/nWarn: Select perk1: 1 , Selected: 1"
Then I select perk1 again, so it must deselect. I see the warning in the menu again and as iprintln.

WARNING: Non-localized Game Message string is not allowed to have letters in it. Must be changed over to a localized string: "Response: perk1/nWarn: Deselect perk1: 0 , Selected: 0"

I close the menu and reopen it. I select perk1 again, but no warn message inside the menu is showed. Only iprintln

WARNING: Non-localized Game Message string is not allowed to have letters in it. Must be changed over to a localized string: "Response: perk1/nWarn: Select perk1: 1 , Selected: 1"
I click on perk1 again to deselect it. Again no warn message inside the menu, but the iprintln is working correctly


WARNING: Non-localized Game Message string is not allowed to have letters in it. Must be changed over to a localized string: "Response: perk1/nWarn: Deselect perk1: 0 , Selected: 0"

Tested with developer 1

Tally
22nd August 2015, 10:45
LOL this is painful to watch. Everyone knows you get those localized string errors, and you just ignore them. You should be beyond the noob stage by now Nils. You've been modding long enough.

IzNoGoD
22nd August 2015, 10:59
LOL this is painful to watch. Everyone knows you get those localized string errors, and you just ignore them. You should be beyond the noob stage by now Nils. You've been modding long enough.

Hes using them to identify the iprintlns and tell us which ones happened. He's not complaining about the warnings, he's using them for debuggin puproses

Tally
22nd August 2015, 12:03
Hes using them to identify the iprintlns and tell us which ones happened. He's not complaining about the warnings, he's using them for debuggin puproses

Why is he including the warning at all? How does that help anyone to identify the problem for him?

And do you notice, he says the iprintln is working, and then he includes - not the iprintln but the fucking warning again!

Tally
22nd August 2015, 12:04
Is this code still there:


self setClientCvar("perk_warn",warn);
wait 0.5;
self setClientCvar("perk_warn","");


Are you waiting a frame, then clearing the warning message to ""? Perhaps that is why it isn't working - if you clear the message, it wont be there, will it?

If the above code is not relevant, you need to post your most up-to-date code. No one can help with outdated code.

Ni3ls
24th August 2015, 11:38
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 <0)
{
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);
}
}
Called from

else if(menu == "perkmenu")
{

self setupperk(); // loads the menu
self handleperk(response);
}
Here is the complete perkmenu.menu

To load it, use /language "1"

http://pastebin.com/4gtg42gf

Ni3ls
25th August 2015, 18:13
Can somebody try it and see if they can fix the error?

serthy
25th August 2015, 21:08
You have over 220 itemdef's in your menu. I guess it just bugs out..
You should handle your language stuff in a different way, by using only ONE menu and use localized strings.
Try remove these and see if it works.

Also you set the client-var on top of your script and also at the bottom (in the same frame) maybe this is also a thing..
You can remove the first setClientCvar() then.

And: you dont need to hide your itemdefs on close

Ni3ls
27th August 2015, 07:13
When I remove all the other perk buttons and only keep perk 1 in all languages, it still break the dvar.
When I use /perk_warn "message" it still wont show up in the menu. I deleted the first setclientCvar() but that doesnt fix it neither.

EDIT:
What is the difference by using localized strings or using the string directly in the menu?

Ni3ls
27th August 2015, 12:57
Its fixed! Just had to delete the "hide warn"