• 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

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

 

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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this