Jump to content
  • 0

Check max 3 ids of array in the inventory !


Angel

Question


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  85
  • Reputation:   17
  • Joined:  12/25/11
  • Last Seen:  

Hello, ppl.

I need some help, i need a script that check a limit only 3 ids of array in inventory.

 

example:
 

setarray .@rental[0],990,991,992,993;


if you have in your inventory 990,991,992 every combination of 3 ids you cannot  get another item.

but if you have only 2 990,993 you can get other item.

 

i don't know how to check more of 3 ids in inventory, only  one  /wah
 

getinventorylist;
    for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1){
        if(@inventorylist_id[.@i] == .@rental > 2) {
              mes "Only 3 ids in inventory";
              close;
        }


Hope someone help me

Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  181
  • Reputation:   53
  • Joined:  04/07/13
  • Last Seen:  

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.

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  44
  • Reputation:   5
  • Joined:  12/06/11
  • Last Seen:  

getinventorylist;
	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]) {
        			set .@itemCount,.@itemCount + 1;
        		}
		}
	}
	if(.@itemCount >= 3) mes "Only 3ids in inventory";

I think that what you're looking for

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  85
  • Reputation:   17
  • Joined:  12/25/11
  • Last Seen:  

Thank you very much, I tried both and they worked perfectly to what I needed.  /no1












Note: I do not mark best answer because both work ,thank you very much again.

Edited by Angel
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...