Jump to content
  • 0

Compact IF Statement need help!


Question

Posted

mes "[Emperium Manager]";
mes "Global Prize Distribution:";
mes (($EmpBrk_PrzDG == 1)?"Enabled":"^FF0000Disabled^000000");
mes "Personal Prize Distribution:";
mes (($EmpBrk_PrzDP == 1)?"Enabled":"^FF0000Disabled^000000");
next;
switch(select("Toggle Global Prize Distribution:Toggle Personal Prize Distribution:Return")) {
case 1:
if ($EmpBrk_PrzDG == 1) set $EmpBrk_PrzDG, 0; goto L_TPD;
if ($EmpBrk_PrzDG == 0) set $EmpBrk_PrzDG, 1; goto L_TPD;

case 2:
if ($EmpBrk_PrzDP == 1) set $EmpBrk_PrzDP, 0; goto L_TPD;
if ($EmpBrk_PrzDP == 0) set $EmpBrk_PrzDP, 1; goto L_TPD;

case 3:
goto L_GM;
}
}

So here's the problem, once I enabled I can't disable it anymore. Not sure where I did wrong, please help!

6 answers to this question

Recommended Posts

Posted

Could the global variable not be updating fast enough? That's all I can think of - you can test by switching to an NPC variable (.var) and if it works, that's the problem.

Edit: woops.

Posted

 mes "[Emperium Manager]";
mes "Global Prize Distribution:";
mes ((.EmpBrk_PrzDG == 1)?"Enabled":"^FF0000Disabled^000000");
mes "Personal Prize Distribution:";
mes ((.EmpBrk_PrzDP == 1)?"Enabled":"^FF0000Disabled^000000");
next;
switch(select("Toggle Global Prize Distribution:Toggle Personal Prize Distribution:Return")) {
case 1:
if (.EmpBrk_PrzDG == 1) set .EmpBrk_PrzDG, 0; goto L_TPD;
if (.EmpBrk_PrzDG == 0) set .EmpBrk_PrzDG, 1; goto L_TPD;

case 2:
if (.EmpBrk_PrzDP == 1) set .EmpBrk_PrzDP, 0; goto L_TPD;
if (.EmpBrk_PrzDP == 0) set .EmpBrk_PrzDP, 1; goto L_TPD;

case 3:
goto L_GM;
}
}

Like this? Will show Disabled all time.

Posted

It missing {} each time so it go directly on the goto.

Should be:

if ($EmpBrk_PrzDG == 1) { set $EmpBrk_PrzDG, 0; goto L_TPD; }
if ($EmpBrk_PrzDG == 0) { set $EmpBrk_PrzDG, 1; goto L_TPD; }

Or:

if ($EmpBrk_PrzDG == 1) set $EmpBrk_PrzDG, 0;
else set $EmpBrk_PrzDG, 1;
goto L_TPD;

Or even:

set $EmpBrk_PrzDG, !$EmpBrk_PrzDG; goto L_TPD;

Posted

Ah, missed that. Thanks, Keyworld! xD

would you suggest using .var or $var in this case? Like an event NPC setting.

NPC variables reset each time you reload scripts or the server restarts. If that doesn't matter, use NPC variables. If you need the values to be persistent, use global.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...