Jump to content
  • 0

Calculate Array Value


M4karov

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   35
  • Joined:  04/01/13
  • Last Seen:  

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

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  228
  • Reputation:   19
  • Joined:  10/27/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   35
  • Joined:  04/01/13
  • Last Seen:  

Thank you guys

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

×
×
  • Create New...