Help on script

Jedzkie

The Master of White Spaces
Messages
632
Points
0
Age
33
Location
Philippines
Discord
✪ Jedzkie#0662
IRC Nickname
Jedzkie
Github
Jedzkie
Emulator
Client Version
2016-03-16 RE
hi! how can i set a black list here in my script? i copied the black list from disguise event, then i transfer it to my script.

i set my black list as an array.

i try to put if( .@disguise == .@blacklist[0] ) but its not working. can someone help me.

here's my script:

Code:
				mes "[ ^ffa500Master of Disguise^000000 ]";				mes "Okay then, please write the NUMBER ID of the Monster or NPC you would like to be Disguised as.";				next;				input .@disguise,0;								if( .@disguise == 0 ) || ( .@disguise <= 1001 ) || ( .@disguise >= 2082 ) || ( .@disguise == .@blacklist[0] ){				goto choose_one;				close;				}				else {				disguise (.@disguise);				delitem 21000,1;				close;				}
 
The problem right off the bat is how you're writing the expression for your if statement. You can't separate expressions in parentheses and compare them that way; you'd have to have another set of parentheses enclosing the entire expression. The proper way to write your (improper) check would be:

if(.@disguise == 0 || .@disguise < 1001 || .@disguise > 2082 || .@disguise == .@blacklist[0])

Now, this is still wrong because the blacklist isn't being checked the way you want it to. Here, you should use a loop and a variable to keep count of incrementation. By this, I mean changing .blacklist[0] into .blacklist[.@i].

Replace this:

if( .@disguise == 0 ) || ( .@disguise <= 1001 ) || ( .@disguise >= 2082 ) || ( .@disguise == .@blacklist[0] ){goto choose_one;close;}

With this:

for(.@i = 0; .@i < getarraysize(.blacklist); .@i++){  if(.@disguise == 0 || .@disguise < 1001 || .@disguise > 2082 || .@disguise == .@blacklist[.@i])  {    mes "[ ^ffa500Master of Disguise^000000 ]";    mes "Sorry, the ID you chose is either unavailable or blacklisted.";    close;  }}

Here, we're enclosing our if statement inside of a for loop. What this for loop does is check each value of your .blacklist array until it has gone through each and every value.

Fill your array with monster IDs, like this:

.blacklist[0], 1001, 1002, 1003, 1004, 1005;

Keep in mind that you can only store up to 128 values in an array (though if this has changed, someone please correct me).

For more on the if statement, loops, and arrays, please refer to the Wiki; it's quite useful for referencing.

http://herc.ws/wiki/If

http://herc.ws/wiki/Loops

http://herc.ws/wiki/Array

 
Last edited by a moderator:
i was about to answer, but your answer was perfect
default_biggrin.png


 
off topic though

arrays are 128, but a small hack is that it can use negative values too
default_tongue.png


-127 to 127.

but i think there is some secret plans to make the arrays unlimited, shhh, secret

 
Last edited by a moderator:
off topic though

arrays are 128, but a small hack is that it can use negative values too
default_tongue.png


-128 to 128.

but i think there is some secret plans to make the arrays unlimited, shhh, secret
Oh wow. I hadn't quite thought of using negative values. While 256-ish is great, unlimited arrays would be amazing. *__*

 
Thank you both of you!
default_smile.png


 
Back
Top