HeyC Posted June 3, 2018 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 14 Reputation: 0 Joined: 04/23/18 Last Seen: November 20, 2018 Share Posted June 3, 2018 Hi. Guys, how can i make an npc count mutiple items before "goto" next part? For example: check if player has 10 jellopy and 10 feather, then "goto" GvI GvI: delitem 909,10; delitem 949,10; close; Quote Link to comment Share on other sites More sharing options...
1 TheDerpySupport Posted June 3, 2018 Group: Members Topic Count: 13 Topics Per Day: 0.00 Content Count: 208 Reputation: 60 Joined: 09/23/17 Last Seen: July 28, 2021 Share Posted June 3, 2018 6 minutes ago, HeyC said: Hi. Guys, how can i make an npc count mutiple items before "goto" next part? For example: check if player has 10 jellopy and 10 feather, then "goto" GvI GvI: delitem 909,10; delitem 949,10; close; You'll use an AND statement designated by &&, you need it double like this, in your IF statement. if(countitem(1111) >= 10 && countitem(1111) >= 10 ) Quote Link to comment Share on other sites More sharing options...
1 Tyrfing Posted June 4, 2018 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 86 Reputation: 21 Joined: 10/02/13 Last Seen: October 23, 2024 Share Posted June 4, 2018 Or, if you have a list os many items, you can store their IDs in an array: setarray .@items[0], 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245; Then, if you want to make sure that the player has at least X of each item, you iterate over the array: set .@requiredAmount, X; set .@hasAllItems, 1; for (.@i = 0; .@i < getarraysize(.@items); .@i++) { if (countitem(.@item[.@i]) < .@requiredAmount) { set .@hasAllItems, 0; break; } } if (.@hasAllItems) { // Player has at least X items of every ID } else { // Player does not have X items of every ID } Or, if you'd like to specify different quantities for each item, you can also do: setarray .@items[0], 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245; setarray .@requiredAmount[0], 10, 10, 5, 5, 10, 10, 5, 6, 7, 10, 50, 100; set .@hasAllItems, 1; for (.@i = 0; .@i < getarraysize(.@items); .@i++) { if (countitem(.@item[.@i]) < .@requiredAmount[.@i]) { set .@hasAllItems, 0; break; } } if (.@hasAllItems) { // Player has the required amount of items of every ID } else { // Player does not have the required amount of items of every ID } You can also unite the two arrays together: setarray .@item_and_amount[0], 1234, 10, 1235, 10, 1236, 5, 1237, 5, 1238, 10, 1239, 10, 1240, 5, 1241, 6, 1242, 7, 1243, 10, 1244, 50, 1245, 100; /* The above array holds pairs of values, where the first value is the item ID and the second value is the required amount */ set .@hasAllItems, 1; for (.@i = 0; .@i < getarraysize(.@item_and_amount) - 1; .@i = .@i + 2) { if (countitem(.@item_and_amount[.@i]) < .@item_and_amount[.@i+1]) { set .@hasAllItems, 0; break; } } if (.@hasAllItems) { // Player has the required amount of items of every ID } else { // Player does not have the required amount of items of every ID } Quote Link to comment Share on other sites More sharing options...
0 NotKappa Posted June 3, 2018 Group: Members Topic Count: 15 Topics Per Day: 0.00 Content Count: 52 Reputation: 37 Joined: 06/28/13 Last Seen: April 5, 2023 Share Posted June 3, 2018 https://github.com/rathena/rathena/blob/master/doc/script_commands.txt#L4858 if(countitem(id) >= count){ // your code } Quote Link to comment Share on other sites More sharing options...
Question
HeyC
Hi.
Guys, how can i make an npc count mutiple items before "goto" next part?
For example:
check if player has 10 jellopy and 10 feather, then "goto" GvI
GvI:
delitem 909,10;
delitem 949,10;
close;
Link to comment
Share on other sites
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.