THPO Posted August 15, 2014 Group: Members Topic Count: 5 Topics Per Day: 0.00 Content Count: 45 Reputation: 7 Joined: 08/15/14 Last Seen: May 8, 2020 Share Posted August 15, 2014 (edited) Hi guys wanted to learn how to use array since I'm always using variables and it would take me some time to list everything there. I wanted to use an array for my Quests and I wanted to use 2 set of array 1 for the Items needed and 1 for it's Quantity. as you can see below I wanted them to countitem first then if it's true they will be deleted. else end; example: setarray .@ItemReq[0], 501, 502, 503, 504; setarray .@ItemQty[0], 5, 10, 15, 20; if(countitem(.@ItemReq[0]) >= .@ItemQty[0] || (.@ItemReq[1]) >= .@ItemQty[1] || (.@ItemReq[2]) >= .@ItemQty[2] || (.@ItemReq[3]) >= .@ItemQty[3] ) { delitem .@ItemReq[0],.@ItemQty[0]; delitem .@ItemReq[1],.@ItemQty[1]; delitem .@ItemReq[2],.@ItemQty[2]; delitem .@ItemReq[3],.@ItemQty[3]; mes "Deleted all items ."; close; } else { end; } I'm really new to scripting and arrays. appreciate any help you would mention anyone can help me make it work and much easier? Edited August 15, 2014 by THPO Quote Link to comment Share on other sites More sharing options...
Emistry Posted August 15, 2014 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2372 Joined: 10/28/11 Last Seen: 21 hours ago Share Posted August 15, 2014 something like this. prontera,155,181,5 script Sample#array 757,{ // loop + check item for( .@i = 0; .@i < .item_size; .@i++ ) if( countitem( .item[.@i] ) < .amount[.@i] ){ mes "You need "+.amount[.@i]+"x "+getitemname( .item[.@i] ); close; } // loop again to delete item for( .@i = 0; .@i < .item_size; .@i++ ) delitem .item[.@i],.amount[.@i]; // done, get item getitem 607; mes "Done."; close; OnInit: // initialize items setarray .item,501,502,503,504,505; setarray .amount,1,2,3,4,5; .item_size = getarraysize( .item ); end; } 1 Quote Link to comment Share on other sites More sharing options...
THPO Posted August 15, 2014 Group: Members Topic Count: 5 Topics Per Day: 0.00 Content Count: 45 Reputation: 7 Joined: 08/15/14 Last Seen: May 8, 2020 Author Share Posted August 15, 2014 Thanks for your moment Mr. Emistry for taking a look at my thread but can I ask what does this mean: for( .@i = 0; .@i < .item_size; .@i++ ) especially the .@i Quote Link to comment Share on other sites More sharing options...
Emistry Posted August 15, 2014 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2372 Joined: 10/28/11 Last Seen: 21 hours ago Share Posted August 15, 2014 loop .. variable .... http://en.wikipedia.org/wiki/For_loop Quote Link to comment Share on other sites More sharing options...
THPO Posted August 15, 2014 Group: Members Topic Count: 5 Topics Per Day: 0.00 Content Count: 45 Reputation: 7 Joined: 08/15/14 Last Seen: May 8, 2020 Author Share Posted August 15, 2014 loop .. variable .... http://en.wikipedia.org/wiki/For_loop I need to read that , and here if I wanted do display all the items need: how should i make it should I add someting like .item[.@i+1] so all items needed will appear: You still need : 1x Red Potion 2x Orange Potion 3x Yellow Potion 4x White Potion etc.. mes "You still need "+.amount[.@i]+"x "+getitemname( .item[.@i] ); Quote Link to comment Share on other sites More sharing options...
Question
THPO
Hi guys wanted to learn how to use array since I'm always using variables and it would take me some time to list everything there.
I wanted to use an array for my Quests and I wanted to use 2 set of array 1 for the Items needed and 1 for it's Quantity.
as you can see below I wanted them to countitem first then if it's true they will be deleted. else end;
example:
anyone can help me make it work and much easier?
Edited by THPOLink to comment
Share on other sites
4 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.