The forums will be going offline for an extended maintenance period at 1400hrs GMT on 19th June 2025. The number of hours for this downtime is intentionally not advertised due to the nature of these upgrades.
×
- 0
on checking array items infinite loop
-
Recently Browsing 0 members
- No registered users viewing this page.
Question
utofaery
I am trying to insert this condition check of preventing selling things in the array into the script in below
but everytime I tried it goes into infinite loop
setarray(.@noSell0x[0], 1065, 6124, 40101, 40102, 40103, 40105 );
function script F_ETCSELLRefined {
setarray .Overcharge[0], 0, 7,9,11,13,15,17,19,21,23,24;
disable_items;
getinventorylist;
for ( .@i = 0; .@i < @inventorylist_count; ++.@i ) {
if ( getiteminfo( @inventorylist_id[.@i], ITEMINFO_TYPE ) == IT_ETC ) {
.@id[.@c] = @inventorylist_id[.@i];
.@amount[.@c] = @inventorylist_amount[.@i];
.@zeny_total += getiteminfo( .@id[.@c], ITEMINFO_SELLPRICE ) * .@amount[.@c] *(100 + .Overcharge[ getskilllv(MC_OVERCHARGE)] )/100;
++.@c;
}
}
if ( !.@c ) {
mes "you don't have any items to sell";
close;
}
mes "Are you sure selling :";
for ( .@i = 0; .@i < .@c; ++.@i )
mes .@amount[.@i] +"x "+ getitemname(.@id[.@i]);
mes "for "+ F_InsertComma(.@zeny_total) +" Zeny ?";
next;
if ( select( "Yes", "No" ) == 2 ) close;
if ( Zeny + .@zeny_total > MAX_ZENY ) {
mes "You can't carry that much Zeny.";
close;
}
for ( .@i = 0; .@i < .@c; ++.@i )
delitem .@id[.@i], .@amount[.@i];
mes "All item sold for "+ F_InsertComma(.@zeny_total) +" Zeny";
Zeny += .@zeny_total;
return;
}
The Broken Script:: (Loop till infiniti)
function script F_ETCSELLRefined {
setarray(.@noSell0x[0], 1065, 6124, 40101, 40102, 40103, 40105 );
setarray .Overcharge[0], 0, 7,9,11,13,15,17,19,21,23,24;
disable_items;
getinventorylist;
for ( .@i = 0; .@i < @inventorylist_count; ++.@i ) {
if ( getiteminfo( @inventorylist_id[.@i], ITEMINFO_TYPE ) == IT_ETC ) {
.@FCheck = 0;
for( .@c = 0; .@c < getarraysize(.@noSell0x); ++.@c ) {
if ( @inventorylist_id[.@i] == .@noSell0x[.@c] ) {
.@FCheck = 1;
}
}
if ( .@FCheck == 0 ) {
.@id[.@c] = @inventorylist_id[.@i];
.@amount[.@c] = @inventorylist_amount[.@i];
.@zeny_total += getiteminfo( .@id[.@c], ITEMINFO_SELLPRICE ) * .@amount[.@c] *(100 + .Overcharge[ getskilllv(MC_OVERCHARGE)] )/100;
}
++.@c;
}
}
if ( !.@c ) {
mes "you don't have any items to sell";
close;
}
mes "Are you sure selling :";
for ( .@i = 0; .@i < .@c; ++.@i )
mes .@amount[.@i] +"x "+ getitemname(.@id[.@i]);
mes "for "+ F_InsertComma(.@zeny_total) +" Zeny ?";
next;
if ( select( "Yes", "No" ) == 2 ) close;
if ( Zeny + .@zeny_total > MAX_ZENY ) {
mes "You can't carry that much Zeny.";
close;
}
for ( .@i = 0; .@i < .@c; ++.@i )
delitem .@id[.@i], .@amount[.@i];
mes "All item sold for "+ F_InsertComma(.@zeny_total) +" Zeny";
Zeny += .@zeny_total;
return;
}
Edit:
Does it has something to do with how much Etc item I has inside my inventory?
like when I don't have more than 40 Count of different types of Etc Item it doesn't go to loop
but when I exceed to count 80 of different type of Etc item the loop happens.
Edited by utofaeryLink 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.