Jump to content
  • 0

Item Reward depends on chances


Question

Posted

Hello everyone. Can anyone help me make this script?

What I need to do is this.

The player will require item ID 501 for them to play this npc.

setarray .itemReward[0], ItemID, ItemChance, ...

setarray .itemReward[0],501,10,502,20,503,30,504,40,505,50;

The player will get one item reward depending on the chances that they will get. Rare item will have small chance only.

4 answers to this question

Recommended Posts

  • 0
Posted (edited)
prontera,156,187,2	script	Valkyrie#1	4_F_LGTGIRL,{

	if (countitem(501) >= 1) {
		delitem 501,1;
		@chancezz = rand(1, 100);
		mes "ok lets see";
		
	if (@chancezz <= 50) {
		mes "You got the common prize!";
		getitem 501, 2;
		close;
		end;
		}
	if (@chancezz >= 80) {
		mes "You got the rare prize!";
		getitem 501, 12;
		close;
		end;
		}	
	if (@chancezz >= 51) {
		mes "You got the uncommon prize!";
		getitem 501, 5;
		close;
		end;
		}			

		
		}
	mes "Sorry no potions, no items";
	close;
	end;

}

Well i tried my best /ene

It works at least

 

https://github.com/rathena/rathena/blob/master/npc/other/comodo_gambling.txt

 

Edited by Sakurada
  • 0
Posted
5 hours ago, neXus said:

Hello everyone. Can anyone help me make this script?

What I need to do is this.

The player will require item ID 501 for them to play this npc.

setarray .itemReward[0], ItemID, ItemChance, ...

setarray .itemReward[0],501,10,502,20,503,30,504,40,505,50;

The player will get one item reward depending on the chances that they will get. Rare item will have small chance only.

Raw Script:
Lucky Gambler

prontera.gat, 155, 185, 5	script	Lucky Gambler	757,{
/*
Note:
 Calculations: 
	100/50 = 2 so 2 is 50%
*/
	//  Required Item
	.@item_ID = 501;
	// .@item_List[0],<rates>,<item_id>,.........
	setarray .@item_List[0],
		 2,5738,
		20,5443,
		25,2294,
		30,5509,
		50,5150
		;
	setarray .@item_Ann[0],
		5738,
		5443,
		2294,
		5509,
		5150
		;

	mes "Do you want to use your "+getitemname( .@item_ID )+" to try and get something valuable items.";
	next;
	if( select("- Yes:- No")-1 ) close;
	if( !countitem( .@item_ID ) ) {
		mes "You don't have any "+getitemname( .@item_ID )+".";
		mes "Please come back to me if you have it already.";
	}
	else {
			delitem .@item_ID,1;
			for( .@j = 0; .@j < getarraysize(.@item_List); .@j+= 2 ) {
				if( rand(.@item_List[.@j]) == 1 ) {
					getitem( .@item_List[.@j+1] ),1;
					mes "Congratulations!";
				for( .@i = 0; .@i < getarraysize(.@item_List); .@i++ ) {
					if( .@item_List[.@j+1] == .@item_Ann[.@i] ) {
						announce "[ Lucky Gambler ]: Player " + strcharinfo(0) +" has obtained "+ ((.@item_List[.@j]>=50)?"'Low'":"'High'") +" "+getitemname( .@item_List[.@j+1] )+" with ["+ (100/.@item_List[.@j]) +"%] Chance.",bc_all,0xBA55D3;
					}
				}
				specialeffect 154;
				close;
			}
		}
		specialeffect 155;
		mes "It's failed, sorry.";
	}
	close;
}

 

  • 0
Posted
14 hours ago, neXus said:

Hello everyone. Can anyone help me make this script?

What I need to do is this.

The player will require item ID 501 for them to play this npc.

setarray .itemReward[0], ItemID, ItemChance, ...

setarray .itemReward[0],501,10,502,20,503,30,504,40,505,50;

The player will get one item reward depending on the chances that they will get. Rare item will have small chance only.

@AnnieRuru Made a fantastic post with three excellent ways on how to do this already...

 

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