Jump to content
  • 0
kalabasa

script:implode: array length = 0 Gatcha Script

Question

prontera,155,180,5	script	Random	98,{

	mes .npc_name$;
	mes "Hello, do you want to play ?";
	next;
	if( select( "Play !", "More Informations", "Leave" ) == 3 ) {
		mes .npc_name$;
		mes "Bye!~";
		close;
	}
	else if( @menu == 2 ) {
		while( getd(".p"+ [email protected] ) ) {
			mes .npc_name$;
			mes "Item required: ^FFCC00"+ getitemname( getd(".p"+ [email protected] ) ) +"^000000";
			mes "Chance to gain something: ^CC0000"+ getd(".p"+ [email protected] +"[1]" ) +"%^000000";
			mes "Possible gains:";
			for( [email protected] = 3; [email protected] < getarraysize( getd(".p"+ [email protected] ) ); [email protected] +=  3 )
				mes "^0000FFx"+ getd(".p"+ [email protected] +"["+ [email protected] +"]" ) +"^000000 "+ getitemname( getd(".p"+ [email protected] +"["+ ([email protected] -1) +"]" ) ) +" (^CC0000"+ getd(".p"+ [email protected] +"["+ ([email protected] +1) +"]" ) +"%^000000)";
			[email protected]++;
			next;
		}
	}
	mes .npc_name$;
	mes "Which item do you want to use ?";
	next;
	for( [email protected] = 0; getd(".p"+ [email protected] ); [email protected]++ )
		if( countitem( getd(".p"+ [email protected] ) ) ) {
			[email protected] = getarraysize( [email protected]$ );
			[email protected]$[ [email protected] ] = getitemname( getd(".p"+ [email protected] ) );
			[email protected][ [email protected] ] = [email protected];
		}
	[email protected] = [email protected][ select( implode( [email protected]$, ":" ) ) -1 ];
	mes .npc_name$;
	while (1) {
		mes "Here we go...";
		delitem getd(".p"+ [email protected] ), 1;
		if( rand(100) > getd(".p"+ [email protected] +"[1]" ) )// lose
			mes "You got nothing";
		else {
			[email protected] = rand( getd(".totalchance"+ [email protected] ) );
			[email protected] = 1;
			while ( ( [email protected] = [email protected] - getd( ".p"+ [email protected] +"["+ (1+ 3 * [email protected]) +"]" ) ) >= 0 ) [email protected]++;
			getitem getd( ".p"+ [email protected] +"["+ (1+ 3*[email protected] -2) +"]" ), getd( ".p"+ [email protected] +"["+( 1+3*[email protected] -1 )+"]" );
			mes "You got ^FF00CC"+ getd( ".p"+ [email protected] +"["+( 1+3*[email protected] -1 )+"]" ) +" "+ getitemname( getd( ".p"+ [email protected] +"["+ (1+ 3*[email protected] -2) +"]" ) ) +"^000000";
		}
		mes " ";
		mes "wanna try again ?";
		next;

		if ( select( "Yes", "No" ) == 2 ) close;
		mes .npc_name$;
		if ( countitem( getd(".p"+ [email protected] ) ) < 1 ) {
			mes "it seems you have ran out of "+ getitemname( getd(".p"+ [email protected] ) );
			close;
		}
	}
	close;

OnInit:
// (item ID need) (chance), (reward 1) (number of reward 1) (chance to gain), (reward 2) (number of reward 2) (chance to gain)...
	setarray .p0, 671,50,	2462,1,20,	1161,1,30,	5394,1,50;					// gold coin 
	setarray .p1, 7227,20,	2462,1,10,	2541,1,10,	1161,1,10,	13517,1,70;

	while ( getd(".p"+ [email protected] ) ) {
		for( [email protected] = 4; [email protected] < getarraysize( getd(".p"+ [email protected] ) ); [email protected] += 3 )
			setd ".totalchance"+ [email protected], getd(".totalchance"+ [email protected] ) + getd(".p"+ [email protected] +"["+ [email protected] +"]" );
		[email protected]++;
	}
	
	.npc_name$ = "[ "+ strnpcinfo(1) +"]";
	end;
}

Required Items are Gold Coin (671) and tcg (7227)

if none of this on the user inventory gives error

[Warning]:script:implode: array length = 0

[Error]: buildin_delitem: failed to delete 1 items(AID=20000000) item_id=671

 

Link to comment
Share on other sites

2 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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.