Jump to content
  • 0

Custom Box error


Yukaiii

Question


  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  110
  • Reputation:   9
  • Joined:  11/20/13
  • Last Seen:  

Guys, could anyone help me with how to fix my custom box?

every time I try to open the box I get this error and I get nothing.

 

I'm using this script

 

function	script	event_box	{

	// change Item ID here
	setarray @i1[0],607,608; // Common Items 
	setarray @i2[0],512,513; // Rare Items
	setarray @i3[0],514,515; // Super Rare Items

	set @i1rand,rand( getarraysize(@i1) ); // Randomize Common Items; just change max amount if you add items
	set @i2rand,rand( getarraysize(@i2) ); // Randomize Rare Items; just change max amount if you add items
	set @i3rand,rand( getarraysize(@i3) ); //Randomize Super Rare Items; just change max amount if you add items

	.chance = rand(100);

		// Super Rare Item 1%
		if (.chance == 1) {
			getitem @i[@i3rand],1;
			announce "["+strcharinfo(0)+"] won a ["+getitemname(@i3[@i3rand])+"] from the Super Rare Box.",0;
			end;
		} 

		// Rare Item 10%
		else if (.chance <= 11 && .chance >= 1){
			getitem @i[@i2rand],1;
			announce "["+strcharinfo(0)+"] won a ["+getitemname(@i2[@i2rand])+"] from the Rare Item Box.",0;
			end;
		} 

		// Common Items
		else {
			getitem @i1[@i1rand],1;
	end; }
}

 

image.thumb.png.8c8796d5a66d6dbcd15b10d5be38aecb.png

Edited by Yukaiii
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  232
  • Reputation:   86
  • Joined:  06/30/18
  • Last Seen:  

According to the error messages, the problem doesn't seem to be related to your function. It rather seems like it is a problem how it is called.
You also could use item groups instead of writing your own script: https://github.com/rathena/rathena/blob/master/doc/item_group.txt

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  99
  • Reputation:   19
  • Joined:  05/01/12
  • Last Seen:  

13 hours ago, Yukaiii said:

Guys, could anyone help me with how to fix my custom box?

every time I try to open the box I get this error and I get nothing.

Item script of your custom box should be:

 callfunc "F_EventBox";

and add this in your npc/custom folder

function	script	F_EventBox	{

	// change Item ID here
	setarray .@i1[0],607,608; // Common Items 
	setarray .@i2[0],512,513; // Rare Items
	setarray .@i3[0],514,515; // Super Rare Items

	set .@i1rand,rand( getarraysize(.@i1) ); // Randomize Common Items; just change max amount if you add items
	set .@i2rand,rand( getarraysize(.@i2) ); // Randomize Rare Items; just change max amount if you add items
	set .@i3rand,rand( getarraysize(.@i3) ); //Randomize Super Rare Items; just change max amount if you add items

	.@chance = rand(100);

	// Super Rare Item 1%
	if (.@chance == 1) {
		getitem .@i3[.@i3rand],1;
		announce "[ "+strcharinfo(0)+" ] won a [ "+getitemname(.@i3[.@i3rand])+" ] from the Event Box.",0;
	}
	else if (.@chance <= 10) { // 10%
		getitem .@i2[.@i2rand],1;
	}
	
	// Common Items
	else {
		getitem .@i1[.@i1rand],1;
	}
	end;
}

 

Link to comment
Share on other sites

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