Jump to content
  • 0

Check max 3 ids of array in the inventory !


Question

Posted

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

3 answers to this question

Recommended Posts

Posted

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
Posted
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
Posted (edited)

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

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