Jump to content
  • 0

Announce item from random box


wut751

Question


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  30
  • Reputation:   2
  • Joined:  07/17/17
  • Last Seen:  

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

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  30
  • Reputation:   2
  • Joined:  07/17/17
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  173
  • Reputation:   9
  • Joined:  11/14/12
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  148
  • Reputation:   10
  • Joined:  12/03/18
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  1
  • Reputation:   0
  • Joined:  03/30/20
  • Last Seen:  

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?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  176
  • Topics Per Day:  0.15
  • Content Count:  666
  • Reputation:   9
  • Joined:  12/04/20
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  120
  • Reputation:   8
  • Joined:  09/16/18
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  176
  • Topics Per Day:  0.15
  • Content Count:  666
  • Reputation:   9
  • Joined:  12/04/20
  • Last Seen:  

7 hours ago, lelouchxv said:

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

i will try it later thanks

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  120
  • Reputation:   8
  • Joined:  09/16/18
  • Last Seen:  

@chadnessYou'll try what sir? haha im kinda confused

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