Jump to content
  • 0

Compact IF Statement need help!


Bin4ry

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  782
  • Reputation:   82
  • Joined:  01/01/12
  • Last Seen:  

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!

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  782
  • Reputation:   82
  • Joined:  01/01/12
  • Last Seen:  

 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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

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;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  782
  • Reputation:   82
  • Joined:  01/01/12
  • Last Seen:  

Hmm now it's working. Thanks both of you. and would you suggest using .var or $var in this case? Like an event NPC setting.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

no matter what variable you use...you still can access it....with this..

getvariableofnpc()

or other method..if there is any.....

Link to comment
Share on other sites

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.

×
×
  • Create New...