Angel Posted September 17, 2013 Posted September 17, 2013 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 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 Quote
DeadlySilence Posted September 17, 2013 Posted September 17, 2013 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. 2 Quote
Khazou Posted September 17, 2013 Posted September 17, 2013 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 1 Quote
Angel Posted September 18, 2013 Author Posted September 18, 2013 (edited) Thank you very much, I tried both and they worked perfectly to what I needed. Note: I do not mark best answer because both work ,thank you very much again. Edited September 18, 2013 by Angel Quote
Question
Angel
Hello, ppl.
I need some help, i need a script that check a limit only 3 ids of array in inventory.
example:
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
Hope someone help me
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.