• 0
Sign in to follow this  
M4karov

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;
}

 

Share this post


Link to post
Share on other sites

3 answers to this question

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;
}

 

  • Upvote 1

Share this post


Link to post
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).

  • Upvote 1

Share this post


Link to post
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.

Loading...
Sign in to follow this