• 0
Sign in to follow this  
utofaery

on checking array items infinite loop

Question

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

Spoiler

   setarray([email protected][0], 1065, 6124, 40101, 40102, 40103, 40105 );

 

Spoiler

function    script    F_ETCSELLRefined    {
    setarray .Overcharge[0], 0, 7,9,11,13,15,17,19,21,23,24;
    disable_items;
    getinventorylist;
    for ( [email protected] = 0; [email protected] < @inventorylist_count; [email protected] ) {
        if ( getiteminfo( @inventorylist_id[[email protected]], ITEMINFO_TYPE ) == IT_ETC ) {
            [email protected][[email protected]] = @inventorylist_id[[email protected]];
            [email protected][[email protected]] = @inventorylist_amount[[email protected]];
            [email protected]_total += getiteminfo( [email protected][[email protected]], ITEMINFO_SELLPRICE ) * [email protected][[email protected]] *(100 + .Overcharge[ getskilllv(MC_OVERCHARGE)] )/100;
            [email protected];
        }
    }
    if ( [email protected] ) {
        mes "you don't have any items to sell";
        close;
    }
    mes "Are you sure selling :";
    for ( [email protected] = 0; [email protected] < [email protected]; [email protected] )
        mes [email protected][[email protected]] +"x "+ getitemname([email protected][[email protected]]);
    mes "for "+ F_InsertComma([email protected]_total) +" Zeny ?";
    next;
    if ( select( "Yes", "No" ) == 2 ) close;
    if ( Zeny + [email protected]_total > MAX_ZENY ) {
        mes "You can't carry that much Zeny.";
        close;
    }
    for ( [email protected] = 0; [email protected] < [email protected]; [email protected] )
        delitem [email protected][[email protected]], [email protected][[email protected]];
    mes "All item sold for "+ F_InsertComma([email protected]_total) +" Zeny";
    Zeny += [email protected]_total;
    return;
}


The Broken Script:: (Loop till infiniti)

Spoiler

function    script    F_ETCSELLRefined    {
    setarray([email protected][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 ( [email protected] = 0; [email protected] < @inventorylist_count; [email protected] ) {
        if ( getiteminfo( @inventorylist_id[[email protected]], ITEMINFO_TYPE ) == IT_ETC ) {
            [email protected] = 0;
            for( [email protected] = 0; [email protected] < getarraysize([email protected]); [email protected] ) {
                    if ( @inventorylist_id[[email protected]] == [email protected][[email protected]] ) {
                            [email protected] = 1;
                    }
            }
            if ( [email protected] == 0 ) {
                [email protected][[email protected]] = @inventorylist_id[[email protected]];
                [email protected][[email protected]] = @inventorylist_amount[[email protected]];
                [email protected]_total += getiteminfo( [email protected][[email protected]], ITEMINFO_SELLPRICE ) * [email protected][[email protected]] *(100 + .Overcharge[ getskilllv(MC_OVERCHARGE)] )/100;
            }
            [email protected];
        }
    }
    if ( [email protected] ) {
        mes "you don't have any items to sell";
        close;
    }
    mes "Are you sure selling :";
    for ( [email protected] = 0; [email protected] < [email protected]; [email protected] )
        mes [email protected][[email protected]] +"x "+ getitemname([email protected][[email protected]]);
    mes "for "+ F_InsertComma([email protected]_total) +" Zeny ?";
    next;
    if ( select( "Yes", "No" ) == 2 ) close;
    if ( Zeny + [email protected]_total > MAX_ZENY ) {
        mes "You can't carry that much Zeny.";
        close;
    }
    for ( [email protected] = 0; [email protected] < [email protected]; [email protected] )
        delitem [email protected][[email protected]], [email protected][[email protected]];
    mes "All item sold for "+ F_InsertComma([email protected]_total) +" Zeny";
    Zeny += [email protected]_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 utofaery

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

1. why you ask question on rathena board when the script was solved on hercules board ?
http://herc.ws/board/topic/16523-hhow-to-make-it-report-actual-sold-item-count/
I can't even merge topic because you ask in different forum

2. why you use a function instead of npc ? issit because you want this to be use from an item ?

and since you ask in rathena forum, I use rathena specific script commands, that throw error on hercules

prontera,155,185,4	script	Mass Junk Seller	1_M_MERCHANT,{
	disable_items;
	getinventorylist;
	for ( [email protected] = 0; [email protected] < @inventorylist_count; [email protected] ) {
		if ( getiteminfo( @inventorylist_id[[email protected]], 2 ) == IT_ETC && inarray( .item_deny, @inventorylist_id[[email protected]] ) == -1 ) {
			[email protected][[email protected]] = @inventorylist_id[[email protected]];
			[email protected][[email protected]] = @inventorylist_amount[[email protected]];
			[email protected]_total += getiteminfo( [email protected][[email protected]], 1 ) * [email protected][[email protected]] *(100 + .Overcharge[ getskilllv("MC_OVERCHARGE")] )/100;
			[email protected];
		}
	}
	if ( [email protected] ) {
		mes "you don't have any items to sell";
		close;
	}
	mes "Are you sure selling :";
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected] )
		mes [email protected][[email protected]] +"x "+ getitemname([email protected][[email protected]]);
	mes "for "+ F_InsertComma([email protected]_total) +" Zeny ?";
	next;
	if ( select( "Yes", "No" ) == 2 ) close;
	if ( Zeny + [email protected]_total > MAX_ZENY ) {
		mes "You can't carry that much Zeny.";
		close;
	}
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected] )
		delitem [email protected][[email protected]], [email protected][[email protected]];
	mes "All item sold for "+ F_InsertComma([email protected]_total) +" Zeny";
	Zeny += [email protected]_total;
	close;
OnInit:
	setarray .Overcharge[0], 0, 7,9,11,13,15,17,19,21,23,24;
	setarray .item_deny, 907,908,909, 7539;
	end;
}

 

EDIT: and the reason probably why your script give infinite loop error is because
I used [email protected] to store the total amount of possible items, and you reuse [email protected] in a loop

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0
On 2/7/2019 at 4:03 PM, AnnieRuru said:

2. why you use a function instead of npc ? issit because you want this to be use from an item ?

EDIT: and the reason probably why your script give infinite loop error is because
I used [email protected] to store the total amount of possible items, and you reuse [email protected] in a loop

4.

since you ask in rathena forum, I use rathena specific script commands, that throw error on hercules

2

truthfully yes meant to be created as custom vip item so one can use it with autoloot 100 in instance where monster's are filled with lots of drop.  so easier maintaining inventory...

 

3  so what do I make to fix that loop hole???

 

4.  it's like unpopulated place there...

well I will correct and stop this error in the future of posting there and here...

Share this post


Link to post
Share on other sites
  • 0

2. I hope you can edit this yourself, this isn't an overly complicated script ...

3. just don't use [email protected] counter ... use some other variable like [email protected] or [email protected] ...

4. if you ask in this forum, I'll write in rathena language, otherwise ask in that forum, I'll use hercules language ...
https://annieruru.blogspot.com/2019/01/basic-script-command-comparision.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this