Jump to content
  • 0

Announce item from random box


Question

Posted

Hi All

I just made random box from exist box in the game  so I want some script to announce when player open the box and get item inside from random box.

below is my random box detail

12152,Special_Box,Special Present,2,0,,100,,,,,0xFFFFFFFF,7,2,,,,,,{ getrandgroupitem(IG_Special_Box),1; },{},{}
 

 

sorry for my bad english

thank you in advance

 

9 answers to this question

Recommended Posts

  • 0
Posted (edited)
12152,Special_Box,Special Present,2,0,,100,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc "specialbox"; },{},{} // box item id

function	script	specialbox {
	setarray .i[0],12345,12346; // Itemlist in box
	set .chance, rand(100);

		// First item in list (12345) x 1 (1% Chance)
		if (.chance == 1){
		getitem .i[0],1;
		announce "["+strcharinfo(0)+"] won a ["+getitemname(.i[0])+"] from the Special Box.",0;
		end;
		} 

		// First item in list (12346) x 100 (5~10% Chance)
		if (.chance <= 10 && .chance > 5){
		getitem .i[1],100;
		end;
	}
}

 

Edited by crazyarashi
  • Upvote 2
  • 0
Posted
1 hour ago, crazyarashi said:

12152,Special_Box,Special Present,2,0,,100,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc "specialbox"; },{},{} // box item id

function	script	specialbox {
	setarray .i[0],12345,12346; // Itemlist in box
	set .chance, rand(100);

		// First item in list (12345) x 1 (1% Chance)
		if (.chance == 1){
		getitem .i[0],1;
		announce "["+strcharinfo(0)+"] won a ["+getitemname(.i[0])+"] from the Special Box.",0;
		end;
		} 

		// First item in list (12346) x 100 (5~10% Chance)
		if (.chance <= 10 && .chance > 5){
		getitem .i[1],100;
		end;
	}
}

 

Thank you crazy, and I have question

if in list is A,B,C,D,E,F,G,H and I want rate A,B = 1%    C,D,E = 10% and F,G,H 50%.

how I can set the rate

  • 0
Posted
On ‎7‎/‎29‎/‎2017 at 7:19 PM, wut751 said:

Thank you crazy, and I have question

if in list is A,B,C,D,E,F,G,H and I want rate A,B = 1%    C,D,E = 10% and F,G,H 50%.

how I can set the rate

Try:

function	script	specialbox {
	setarray .i1[0],909,910; // Common Items
	set .i1rand,rand(0,1); // Randomize Common Items; just change max amount if you add items
	setarray .i2[0],911,912; // Rare Items
	set .i2rand,rand(0,1); // Randomize Rare Items; just change max amount if you add items
	setarray .i3[0],2199,1599; // Super Rare Items
	set .i3rand,rand(0,1); //Randomize Super Rare Items; just change max amount if you add items
	set .chance, rand(100);

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

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

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

Just add items in .i1, .i2 and .i3 arrays and make sure to change the variables that randomizes the items to the max number of item you included -1. (-1 since arrays start with 0).

  • 0
Posted (edited)
On 8/5/2017 at 1:04 PM, sotf said:

Try:


function	script	specialbox {
	setarray .i1[0],909,910; // Common Items
	set .i1rand,rand(0,1); // Randomize Common Items; just change max amount if you add items
	setarray .i2[0],911,912; // Rare Items
	set .i2rand,rand(0,1); // Randomize Rare Items; just change max amount if you add items
	setarray .i3[0],2199,1599; // Super Rare Items
	set .i3rand,rand(0,1); //Randomize Super Rare Items; just change max amount if you add items
	set .chance, rand(100);

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

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

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

Just add items in .i1, .i2 and .i3 arrays and make sure to change the variables that randomizes the items to the max number of item you included -1. (-1 since arrays start with 0).

I need to ask if this is working on the latest rathena? - Solved it works.

I need to ask why it said " Player won a [null] from the Special Box. "

 

Edited by Dev G Inc
Additional
  • 0
Posted
On 7/29/2017 at 5:16 PM, crazyarashi said:

function script specialbox { setarray .i[0],12345,12346; // Itemlist in box set .chance, rand(100); // First item in list (12345) x 1 (1% Chance) if (.chance == 1){ getitem .i[0],1; announce "["+strcharinfo(0)+"] won a ["+getitemname(.i[0])+"] from the Special Box.",0; end; } // First item in list (12346) x 100 (5~10% Chance) if (.chance <= 10 && .chance > 5){ getitem .i[1],100; end; } }

Where i need to put this script? on new txt or just copy under the box item id?

  • 0
Posted
On 7/29/2017 at 6:16 PM, crazyarashi said:

12152,Special_Box,Special Present,2,0,,100,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc "specialbox"; },{},{} // box item id

function	script	specialbox {
	setarray .i[0],12345,12346; // Itemlist in box
	set .chance, rand(100);

		// First item in list (12345) x 1 (1% Chance)
		if (.chance == 1){
		getitem .i[0],1;
		announce "["+strcharinfo(0)+"] won a ["+getitemname(.i[0])+"] from the Special Box.",0;
		end;
		} 

		// First item in list (12346) x 100 (5~10% Chance)
		if (.chance <= 10 && .chance > 5){
		getitem .i[1],100;
		end;
	}
}

what if i got this error  how to fix it sir?

 

1.PNG

  • 0
Posted
On 8/4/2017 at 9:04 PM, sotf said:

Try:


function	script	specialbox {
	setarray .i1[0],909,910; // Common Items
	set .i1rand,rand(0,1); // Randomize Common Items; just change max amount if you add items
	setarray .i2[0],911,912; // Rare Items
	set .i2rand,rand(0,1); // Randomize Rare Items; just change max amount if you add items
	setarray .i3[0],2199,1599; // Super Rare Items
	set .i3rand,rand(0,1); //Randomize Super Rare Items; just change max amount if you add items
	set .chance, rand(100);

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

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

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

Just add items in .i1, .i2 and .i3 arrays and make sure to change the variables that randomizes the items to the max number of item you included -1. (-1 since arrays start with 0).

@sotf how to add Custom points in rewards? Ex. Cashpoints Pvp points Hourly Points

  • Love 1

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...