Jump to content
  • 0
Lord Ganja

Help with loops

Question

Im currently modifying my enchantment system.

I want to it work like, no the same orb on the same items. 1 orb ID per item only

But im having troubles with loops.

 

Here's my script.

setarray .@cardid[0], getequipcardid(.@part,1),getequipcardid(.@part,2),getequipcardid(.@part,3);	for( .@i = 0; .@i < getarraysize(.@cardid); .@i++ ){		if( getequipcardid(.@part,.@i) == .@cardid[.@i] ) {			mes .npc$;			mes "Sorry, I cannot enchant the same orb on the same item.";			close;		}	}

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

for( .@i = 0; .@i < 4; .@i++ ){		if( getequipcardid(.@part,.@i) == .@orbid ) {			mes .npc$;			mes "Sorry, I cannot enchant the same orb on the same item.";			close;		}	}

Replace .@orbid with the variable that contains the orb id.

Note: this (above) check should be done after a player has selected orb to enchant.

Share this post


Link to post
Share on other sites
  • 0

Uhh. Basically you're putting things in array, and then compare them to themselves. I'd say you're always getting that stop, right?

 

So can you elaborate what exactly do you want? Any amount of orbs, but so they won't repeat within item? Also, mind me asking why you're checking only last 3 slots, and not all 4? How many slots are available? What's the variable you use to store which orb players wants to slot in?

 

I think the following script should work, if you'll fill in the needed parts.

input .@orbID; //orb that player wants to slot// .@part, I guess, contains which equip we're enchantingsetarray .@cardid[0],getequipcardid(.@part,0),getequipcardid(.@part,1),getequipcardid(.@part,2),getequipcardid(.@part,3);.@string = "," + implode(.@cardid,",") + ",";if( compare(.@string,","+.@orbID+",") ) {	mes .npc$;	mes "Sorry, I cannot enchant the same orb on the same item.";	close;}

Share this post


Link to post
Share on other sites
  • 0

@@Dastgir I need it to check for multiple enchantments.

 

@@Garr I triend your script but it gives me error when it runs.

[Debug]: Data: variable name='.@cardid' index=0[Error]: script:implode: not string array

 

Btw, thanks to both of  you. I'll explain this further.

 

 

My custom enchantment system can only add enchantment orb to 2nd,3rd and last slot of an item.

 

For example:

I have 5 orbs with id numbers 4700, 4701, 4702, 4703, 4704.

 

And let's say my 'Alice Doll' helm has already an echantment

2nd card slot: 4700

3rd card slot: <emtpy / not yet enchanted>

4th card slot: 4703

 

Now, when I will try to enchant the 3rd slot which is emtpy, I have again to select which orb I have to enchant into it..

 

After selecting an orb, it will compare the selected orb from the orb which are already enchanted into the item.

If it match any orbs which is already in the item, it will now say this 'mes "Sorry, I cannot enchant the same orb on the same item.";'

 

So in that case, the 'Alice Doll' helm cannot be enchanted with orbs with item id 4700 or 4703 since it is only one orb ID per item.

Share this post


Link to post
Share on other sites
  • 0

@@Dastgir I need it to check for multiple enchantments.

 

@@Garr I triend your script but it gives me error when it runs.

 

[Debug]: Data: variable name='.@cardid' index=0[Error]: script:implode: not string array
 

Btw, thanks to both of  you. I'll explain this further.

 

 

My custom enchantment system can only add enchantment orb to 2nd,3rd and last slot of an item.

 

For example:

I have 5 orbs with id numbers 4700, 4701, 4702, 4703, 4704.

 

And let's say my 'Alice Doll' helm has already an echantment

2nd card slot: 4700

3rd card slot: <emtpy / not yet enchanted>

4th card slot: 4703

 

Now, when I will try to enchant the 3rd slot which is emtpy, I have again to select which orb I have to enchant into it..

 

After selecting an orb, it will compare the selected orb from the orb which are already enchanted into the item.

If it match any orbs which is already in the item, it will now say this 'mes "Sorry, I cannot enchant the same orb on the same item.";'

 

So in that case, the 'Alice Doll' helm cannot be enchanted with orbs with item id 4700 or 4703 since it is only one orb ID per item.

My one exactly does that.

Thats why I told place it in the place after you select orb Id, and change .@orbid with variable containing the Id of orb you selected.

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.   Restore formatting

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

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.