Jump to content
  • 0

How to stop loop in the same item function?


mawjustin

Question


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   6
  • Joined:  09/26/14
  • Last Seen:  

Hi Team,

 

May I ask for assistance regarding this matter? Is there a way for this script to display only one value? I understand that it loops because of for loop value added in .@itmCnt++; but is there a way to display only 1 value of this loop stored value?

function	script	Aqua_Set	{
    getinventorylist;
    setarray .@rental[0],61500,61501,61502,61503,61504;
    .@itmCnt = 0;
    for (.@i = 0; .@i < getarraysize(.@rental); .@i++) {
        if (countitem(.@rental[.@i]) == 1) {
            .@itmCnt++;
        }
    }
    for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1){
    	for(set .@ii,0; .@ii < getarraysize(.@rental); set .@ii,.@ii + 1){
           	if(@inventorylist_id[.@i] == .@rental[.@ii] && countitem(.@rental[.@ii]) == 1) {
           		set .@itemCount,.@itemCount + 1;
           	}
    	}
    }
    if (.@itmCnt >= 2) { // this is the part that I want to fix, if possible to only display 1 loop value.
       	mes .@itmCnt;
	end;
    }
}

I'm tryin to make an Etc. or charm type of items that depend on number of parts available, it must only read unique id, any duplicate in the inventory will render that part of the combo unusable, and will not add any stats.

this is the result in my end.

image.png.a50bee7c92ba912a5c9476147d000d83.png

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  439
  • Reputation:   29
  • Joined:  12/08/11
  • Last Seen:  

    if (2 < .@itmCnt) {
        mes "You can have a maximum of two out of the following list:";
        for (.@i = 0; .@i < getarraysize(.@rental); .@i++) {
            mes "" + getitemname(.@rental[.@i]) + "";
        }
        close;
    } 

It'll work. Have you tried checking the part where your script called Aqua_Set?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   6
  • Joined:  09/26/14
  • Last Seen:  

On 9/17/2013 at 3:29 PM, DeadlySilence said:

You want to check if the user has fewer than three of an array of items?

 

setarray .@rental[0],990,991,992,993;
.@itmCnt = 0;
for (.@i = 0; .@i < getarraysize(.@rental); .@i++) {
    if (countitem(.@rental[.@i])) {
        .@itmCnt++;
    }
}

if (2 < .@itmCnt) {
    mes "You can have a maximum of two out of the following list:";
    for (.@i = 0; .@i < getarraysize(.@rental); .@i++) {
        mes "" + getitemname(.@rental[.@i]) + "";
    }
    close;
}

 

This should be what you're looking for, then.

Hi, is there a way for this to stop looping? I mean to only display 1 value and not repeat it multiple times?

 

Hi Team,

 

How do we end loops? I'm trying to get the getitemname(.@rental[.@i]); but I want it to only display a single set, and not loop again and again.

How can we display only a single set of result, and not multiple results?

I have etc. item with the same script called.
image.thumb.png.e2ea06a2f584494ced6661f1b7699cdb.png

Basically my concern is stopping for loop to affect other parts of the code.

function	script	Aqua_Set	{
    setarray .@rental[0],61500,61501,61502,61503,61504;
    .@itmCnt = 0;
    for (.@i = 0; .@i < getarraysize(.@rental); .@i++) {
        if (countitem(.@rental[.@i])) {
            .@itmCnt++;
        }
    }
    
    if (2 < .@itmCnt) {
        mes "You can have a maximum of two out of the following list:";
        for (.@i = 0; .@i < getarraysize(.@rental); .@i++) {
            mes "" + getitemname(.@rental[.@i]) + "";
        }
        close;
    }  
}

This is the screenshot of the result of the code. This is in etc.

image.png.0ef51742c096be0398cbad753617e4ef.png

Thank you.

 

 

On 6/4/2021 at 3:39 AM, Magnetix said:
    if (2 < .@itmCnt) {
        mes "You can have a maximum of two out of the following list:";
        for (.@i = 0; .@i < getarraysize(.@rental); .@i++) {
            mes "" + getitemname(.@rental[.@i]) + "";
        }
        close;
    } 

It'll work. Have you tried checking the part where your script called Aqua_Set?

Thanks, I fixed it, I called the function multiple times in the item_db, that's what's causing the loop. I converted it into a script instead.

 

Hi Team,

 

Is there a way to do item combo like this? instead of using item_combo_db.txt, we will create a script, or function that will count the number of parts the cards are equipped, and each part will give a different combo stats?

 

Example:

2 Card Parts Equipped  = STR + 3

3 Card Parts Equipped = INT + 5

4 Card Parts Equipped = DEX + 10

..

..

..

and so on.

 

Thanks in advance guys.

 

Hi guys, may I ask why am I receiving this error? I'm calling @MagicaeVentus from a function in combo.

image.png.ef88e34504cec5dee09ca1320f0d89c8.png

This is the code:

////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
function	script	Magicae_Set_Ventus	{

sleep2 10;
setarray .setcomboarray[0],61500;
setarray .setcombotext$[0],"INT +5","Maximum SP +5%","Maximum HP +5%","Wind Matk +5%","Wind Resist +5%","Ignore Mdef +10%","MATK. +10%";
// use @MagicaeVentus to check combo.
bindatcmd "MagicaeVentus",strnpcinfo(3)+"::OnOrbCheck",0,60;
set .@size,getarraysize( .setcomboarray );
.itmCnt = 0;

for (.@i = 0; .@i < .@size; .@i++) {
   if(getequipcardid (EQI_HEAD_TOP,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_HEAD_MID,3) == .setcomboarray[.@i] ) {    
	.itmCnt++;
 } if(getequipcardid (EQI_HEAD_LOW,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_ARMOR,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_HAND_R,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_HAND_L,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_GARMENT,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_SHOES,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_ACC_L,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_ACC_R,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 }
} mes .itmCnt;
	if (.itmCnt > 10 ) {
	dispbottom "You have more than 10 parts equipped.";
	} else {
    if(.itmCnt >= 2) {
    	 bonus bInt,5; 
    	}
    if(.itmCnt >= 3) {
    	 bonus bMaxSPrate,5;
    	}
    if(.itmCnt >= 4) {
    	 bonus bMaxHPrate,5;
    	}
    if(.itmCnt >= 5) {
    	 bonus2 bAddEle,Ele_Wind,5;
    	}
    if(.itmCnt >= 6) {
    	 bonus2 bSubEle,Ele_Wind,5;
    	}
    if(.itmCnt >= 7) {
    	 bonus2 bIgnoreMdefClassRate,Class_All,10;
    	}
    if(.itmCnt >= 8) {
    	 bonus bMatkRate,10;
    	}
	end;
	}

OnOrbCheck:
.itmCntTotal = 0;
mes "^0000FFMagicae Ventus Set^000000: ";

set .@size,getarraysize( .setcomboarray );
.itmCntTotal= 0;
for (.@i = 0; .@i < .@size; .@i++) {
	if(getequipcardid (EQI_HEAD_TOP,3) == .setcomboarray[.@i]) {
	.itmCntTotal++; mes F_getpositionname(EQI_HEAD_TOP) + " - [" + getitemname(getequipcardid (EQI_HEAD_TOP,3)) + "]";
 } if(getequipcardid (EQI_HEAD_MID,3) == .setcomboarray[.@i]) {
	.itmCntTotal++; mes F_getpositionname(EQI_HEAD_MID) + " - [" + getitemname(getequipcardid (EQI_HEAD_MID,3)) + "]";
 } if(getequipcardid (EQI_HEAD_LOW,3) == .setcomboarray[.@i]) { 
	.itmCntTotal++; mes F_getpositionname(EQI_HEAD_LOW) + " - [" + getitemname(getequipcardid (EQI_HEAD_LOW,3)) + "]";
 } if(getequipcardid (EQI_ARMOR,3) == .setcomboarray[.@i]) {
	.itmCntTotal++; mes F_getpositionname(EQI_ARMOR) + " - [" + getitemname(getequipcardid (EQI_ARMOR,3)) + "]";
 } if(getequipcardid (EQI_HAND_R,3) == .setcomboarray[.@i]) { 
	.itmCntTotal++; mes F_getpositionname(EQI_HAND_R) + " - [" + getitemname(getequipcardid (EQI_HAND_R,3)) + "]";
 } if(getequipcardid (EQI_HAND_L,3) == .setcomboarray[.@i]) { 
	.itmCntTotal++; mes F_getpositionname(EQI_HAND_L) + " - [" + getitemname(getequipcardid (EQI_HAND_L,3)) + "]";
 } if(getequipcardid (EQI_GARMENT,3) == .setcomboarray[.@i]) { 
	.itmCntTotal++; mes F_getpositionname(EQI_GARMENT) + " - [" + getitemname(getequipcardid (EQI_GARMENT,3)) + "]";
 } if(getequipcardid (EQI_SHOES,3) == .setcomboarray[.@i]) {
	.itmCntTotal++; mes F_getpositionname(EQI_SHOES) + " - [" + getitemname(getequipcardid (EQI_SHOES,3)) + "]";
 } if(getequipcardid (EQI_ACC_L,3) == .setcomboarray[.@i]) { 
	.itmCntTotal++; mes F_getpositionname(EQI_ACC_L) + " - [" + getitemname(getequipcardid (EQI_ACC_L,3)) + "]";
 } if(getequipcardid (EQI_ACC_R,3) == .setcomboarray[.@i]) { 
	.itmCntTotal++; mes F_getpositionname(EQI_ACC_R) + " - [" + getitemname(getequipcardid (EQI_ACC_R,3)) + "]";
 } else {
	}
    }


mes " ";
mes "Set Effect: [^00FF00Active^000000 : ^FF0000Inactive^000000] ";
    for (.@i = 0; .@i < getarraysize(.setcombotext$); .@i++) {
	.itmCntTotal--;
	if (.itmCntTotal > 0) {	
        mes "^00FF00" + .setcombotext$[.@i] + "^000000";
	} else {
	mes "^FF0000" + .setcombotext$[.@i] + "^000000";
	}
	}
mes " ";
mes "^8b0000Note: Magicae Soul can be stacked with other Soul Sets.^000000";
    close;
end;
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  924
  • Reputation:   166
  • Joined:  04/05/13
  • Last Seen:  

Try change this function to npc script-based.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   6
  • Joined:  09/26/14
  • Last Seen:  

Just now, Start_ said:

Try change this function to npc script-based.

Is there no other way from this? I'm avoiding doing it like that because I have around 60+ scripts like this and it might overload the server ?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  924
  • Reputation:   166
  • Joined:  04/05/13
  • Last Seen:  

Ummm you do this on item script right?

 

For ::OnXXX just call the main npc that contain every item script to call.


 

- script MawJustin ,{

OnSetChaosCheck:

end;

OnSetPowerfulCheck:

end;

}

 

then call it on function MawJustin::OnSetChaosCheck instead of strcharinfo(3).

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   6
  • Joined:  09/26/14
  • Last Seen:  

16 hours ago, Start_ said:

Ummm you do this on item script right?

 

For ::OnXXX just call the main npc that contain every item script to call.


 


- script MawJustin ,{

OnSetChaosCheck:

end;

OnSetPowerfulCheck:

end;

}

 

then call it on function MawJustin::OnSetChaosCheck instead of strcharinfo(3).

I will try this.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  177
  • Reputation:   25
  • Joined:  12/24/14
  • Last Seen:  

if (isequippedcnt(cardID) > 2) { bonus bStr,3; }

 

Edited by mR L
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   6
  • Joined:  09/26/14
  • Last Seen:  

20 hours ago, mR L said:

if (isequippedcnt(cardID) > 2) { bonus bStr,3; }

 

what if 1 type of card can be equipped in multiple items? example both poring cards can be equipped in upper,middle, and lower headgear? it will duplicate the effects of isequippedcnt()?

 

Hi Team,

May I ask why Is the stats not adding to the player?

-	script	ScriptComboCaller	-1,{
    OnPCStatCalcEvent:
         if(getequipcardid (EQI_HEAD_TOP,3) == 61500 || getequipcardid (EQI_HEAD_MID,3) == 61500 || 
          getequipcardid (EQI_HEAD_LOW,3) == 61500 || getequipcardid (EQI_ARMOR,3) == 61500 || 
          getequipcardid (EQI_HAND_R,3) == 61500 || getequipcardid (EQI_HAND_L,3) == 61500 || 
          getequipcardid (EQI_GARMENT,3) == 61500 || getequipcardid (EQI_SHOES,3) == 61500 || 
          getequipcardid (EQI_ACC_L,3) == 61500 || getequipcardid (EQI_ACC_R,3) == 61500 ) {
     	  callfunc ("Generalis_Arvis");
        } if(getequipcardid (EQI_HEAD_TOP,3) == 61501 || getequipcardid (EQI_HEAD_MID,3) == 61501 || 
          getequipcardid (EQI_HEAD_LOW,3) == 61501 || getequipcardid (EQI_ARMOR,3) == 61501 || 
          getequipcardid (EQI_HAND_R,3) == 61501 || getequipcardid (EQI_HAND_L,3) == 61501 || 
          getequipcardid (EQI_GARMENT,3) == 61501 || getequipcardid (EQI_SHOES,3) == 61501 || 
          getequipcardid (EQI_ACC_L,3) == 61501 || getequipcardid (EQI_ACC_R,3) == 61501 ) {
     	  callfunc ("Generalis_Mercator");
        }
}

////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
function	script	Generalis_Arvis	{
sleep2 10;
OnPCStatCalcEvent:
setarray .setcomboarray[0],61500;
set .@size,getarraysize( .setcomboarray );
.itmCnt = 0;
for (.@i = 0;.@i < .@size;.@i++) {
   if(getequipcardid (EQI_HEAD_TOP,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_HEAD_MID,3) == .setcomboarray[.@i] ) {    
	.itmCnt++;
 } if(getequipcardid (EQI_HEAD_LOW,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_ARMOR,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_HAND_R,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_HAND_L,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_GARMENT,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_SHOES,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_ACC_L,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_ACC_R,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 }
} mes "Generalis_Arvis"+ .itmCnt;
	if (.itmCnt > 10 ) {
	dispbottom "You have more than 10 parts equipped.";
	} else {
    if(.itmCnt >= 2) {
    	 bonus bStr,5;
    	}
    if(.itmCnt >= 3) {
    	 bonus bMaxSPrate,5;
    	}
    if(.itmCnt >= 4) {
    	 bonus bMaxHPrate,5;
    	}
    if(.itmCnt >= 5) {
    	 bonus bVariableCastrate,-5;
    	}
    if(.itmCnt >= 6) {
    	 bonus bDelayRate,5;
    	}
    if(.itmCnt >= 7) {
    	 bonus2 bIgnoreDefClassRate,Class_All,5;
    	}
    if(.itmCnt >= 8) {
    	 bonus bAtkRate,5;
    	}
	return;
	}
}
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
function	script	Generalis_Mercator	{
sleep2 10;
OnPCStatCalcEvent:
setarray .setcomboarray[0],61501;
set .@size,getarraysize( .setcomboarray );
.itmCnt = 0;
for (.@i = 0;.@i < .@size;.@i++) {
   if(getequipcardid (EQI_HEAD_TOP,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_HEAD_MID,3) == .setcomboarray[.@i] ) {    
	.itmCnt++;
 } if(getequipcardid (EQI_HEAD_LOW,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_ARMOR,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_HAND_R,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_HAND_L,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_GARMENT,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_SHOES,3) == .setcomboarray[.@i] ) {
	.itmCnt++;
 } if(getequipcardid (EQI_ACC_L,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 } if(getequipcardid (EQI_ACC_R,3) == .setcomboarray[.@i] ) { 
	.itmCnt++;
 }
} mes "Generalis_Mercator"+ .itmCnt;
	if (.itmCnt > 10 ) {
	dispbottom "You have more than 10 parts equipped.";
	} else {
    if(.itmCnt >= 2) {
    	 bonus bVit,5;
    	}
    if(.itmCnt >= 3) {
    	 bonus bMaxSPrate,5;
    	}
    if(.itmCnt >= 4) {
    	 bonus bMaxHPrate,5;
    	}
    if(.itmCnt >= 5) {
    	 bonus bVariableCastrate,-5;
    	}
    if(.itmCnt >= 6) {
    	 bonus bDelayRate,5;
    	}
    if(.itmCnt >= 7) {
    	 bonus2 bSubEle,Ele_All,5;
    	}
    if(.itmCnt >= 8) {
    	 bonus bMaxHPrate,5;
    	}
	return;
	}
}

Output shows both, but stats is not adding into the player.

May I ask for assistance in where did I go wrong here?
image.png.b1909c1a3bace61f671fc52f38147eae.png

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

item_combo effect should be done at db/re/item_combo_db.txt 

this way, you won't need to worry about same effect triggered multiple times.

isequipped(61500, 61501, 61502, 61503, 61504);

using this would tell you how many items are currently equipped.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   6
  • Joined:  09/26/14
  • Last Seen:  

1 hour ago, Emistry said:

item_combo effect should be done at db/re/item_combo_db.txt 

this way, you won't need to worry about same effect triggered multiple times.


isequipped(61500, 61501, 61502, 61503, 61504);

using this would tell you how many items are currently equipped.

may I ask how will I do this?
61500:61500,{ if  (isequipped(61500) <=10) { bonus bStr,1000; } } ?
because 61500 can be inserted into non slotted slot 4 item only. and can be slotted to all general equipment

image.png.f45295b7cf9119bada4fa54bdfa62fc7.png.
 

Edited by mawjustin
added details
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...