• 0

# Calculate Array Value

## Question

How do you calculate the remaining monsters? Checking all values of arrays.

prontera,155,175,4	script	TestScript	69,{

setarray .@mob_id, 1002, 1004, 1005;
setarray .@mob_qt,    1,    3,    8;
setarray .@mob_req,   7,    8,   10;

for(; .@i < getarraysize(.@mob_id); .@i++){

if(.@mob_qt[.@i] >=  .@mob_req[.@i]) {
dispbottom "You hunted down all the monsters on that map.";
}
else {
dispbottom "You still have to hunt down the following monsters:";
dispbottom "MonsterID: "+.@mob_id[.@i]+" Amount: "+.@mob_qt[.@i]+" Required quantity: "+.@mob_req[.@i];
}
}
end;
}

## Recommended Posts

• 0

Like this?

prontera,155,175,4	script	TestScript	69,{

setarray [email protected]_id, 1002, 1004, 1005;
setarray [email protected]_qt,    1,    3,    8;
setarray [email protected]_req,   7,    8,   10;

for(; [email protected] < getarraysize([email protected]_id); [email protected]++){

if([email protected]_qt[[email protected]] >=  [email protected]_req[[email protected]]) {
dispbottom "You hunted down all the monsters on that map.";
}
else {
dispbottom "You still have to hunt down the following monsters:";
dispbottom "MonsterID: "[email protected]_id[[email protected]]+" Amount: "[email protected]_qt[[email protected]]+" Required quantity: "[email protected]_req[[email protected]];
[email protected] += ([email protected]_req[[email protected]] - [email protected]_qt[[email protected]]);
}
}
if([email protected])
dispbottom "You still need to hunt "+F_InsertPlural([email protected],"monster")+".";
end;
}

• 1
• 1
##### Share on other sites

• 0
2 hours ago, M4karov said:

Checking all values of arrays.

Hope you guys don't hate me for using spoiler the code box is slow to loading on a slow internet speed.

Spoiler

prontera,155,175,4    script    TestScript    69,{

setarray [email protected]_id, 1002, 1004, 1005;
setarray [email protected]_qt,    1,    3,    8;
setarray [email protected]_req,   7,    8,   10;

for( [email protected] = 0; [email protected] < getarraysize([email protected]_id); [email protected]++){
if([email protected]_qt[[email protected]] >=  [email protected]_req[[email protected]]) {
[email protected] += ([email protected]_req[[email protected]] - [email protected]_qt[[email protected]]);
}
}
if([email protected]) {
dispbottom "You still have to hunt down the following monsters:";
for( [email protected] = 0; [email protected] < getarraysize([email protected]_id); [email protected]++){
dispbottom "MonsterID: "[email protected]_id[[email protected]]+" Amount: "[email protected]_qt[[email protected]]+" Required quantity: "[email protected]_req[[email protected]];
}
} else {
dispbottom "You hunted down all the monsters on that map.";
}
end;
}

credit to nott:

I only restructured the script based on (Checking all array values).

• 1
• 1

• 0

Thank you guys

## Join the conversation

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
• Forums