Jump to content
  • 0

Item Reward depends on chances


Reborn

Question


  • Group:  Members
  • Topic Count:  104
  • Topics Per Day:  0.03
  • Content Count:  290
  • Reputation:   3
  • Joined:  09/29/13
  • Last Seen:  

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.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  183
  • Reputation:   15
  • Joined:  06/10/12
  • Last Seen:  

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  148
  • Reputation:   18
  • Joined:  03/03/19
  • Last Seen:  

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

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  90
  • Reputation:   34
  • Joined:  10/01/18
  • Last Seen:  

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;
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

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

 

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