Jump to content
  • 0

Calculate Array Value


Question

Posted

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

 

3 answers to this question

Recommended Posts

  • 0
Posted

Like this?

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];
			.@remain += (.@mob_req[.@i] - .@mob_qt[.@i]);
		}
	}
	if(.@remain)
		dispbottom "You still need to hunt "+F_InsertPlural(.@remain,"monster")+".";
	end;
}

 

  • Upvote 1
  • Like 1
  • 0
Posted
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 .@mob_id, 1002, 1004, 1005;
    setarray .@mob_qt,    1,    3,    8;
    setarray .@mob_req,   7,    8,   10;
    
    for( .@i = 0; .@i < getarraysize(.@mob_id); .@i++){
        if(.@mob_qt[.@i] >=  .@mob_req[.@i]) {
            .@remain += (.@mob_req[.@i] - .@mob_qt[.@i]);
        }
    }
    if(.@remain) {
            dispbottom "You still have to hunt down the following monsters:";
            for( .@i = 0; .@i < getarraysize(.@mob_id); .@i++){
                    dispbottom "MonsterID: "+.@mob_id[.@i]+" Amount: "+.@mob_qt[.@i]+" Required quantity: "+.@mob_req[.@i];        
            }
    } 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
  • Like 1

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...