Jump to content
The forums will be going offline for an extended maintenance period at 1400hrs GMT on 19th June 2025. The number of hours for this downtime is intentionally not advertised due to the nature of these upgrades. ×
  • 0

get item with percentage!


Chasewalk

Question


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.02
  • Content Count:  94
  • Reputation:   0
  • Joined:  10/17/20
  • Last Seen:  

Good day everyone, i'm requesting for a npc script how to put in the script for example when they pay 5k zeny is 5% to chance get item, but when 5m zeny 10% chance they getitem. sorry for may bad english!!

PS: 5,000 zeny is 5% chance and 5M zeny is 10% chance

 ~Thanks.

 

        input .@zeny_to_gamble;
        if (.@zeny_to_gamble == 0) {
             mes "You can only put ^FF00005,000^000000 up to ^FF00005,000,000^000000 Zeny to proceed.";
             close;
        }
        if (.@zeny_to_gamble < 5000 || .@zeny_to_gamble > 5000000) {
                mes "You can only put ^FF00005,000^000000 up to ^FF00005,000,000^000000 Zeny to proceed.";
                close;
            }
            Zeny -= .@zeny_to_gamble;
            .@r = rand(100);
            if (.@r < (.@zeny_to_gamble/100000)) { // 50/100 = 50% chance

Edited by Chasewalk
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  189
  • Reputation:   124
  • Joined:  07/11/14
  • Last Seen:  

would it be this?

      input .@zeny_to_gamble;

      if(!.@zeny_to_gamble){ mes "You can only put ^FF00005,000^000000 up to ^FF00005,000,000^000000 Zeny to proceed."; close; }
      if(.@zeny_to_gamble != 5000 && .@zeny_to_gamble != 5000000){ mes "You can only put ^FF00005,000^000000 up to ^FF00005,000,000^000000 Zeny to proceed."; close; }
      if(Zeny < .@zeny_to_gamble){ mes "^FF0000* Insufficient Zeny^000000"; close; }
	
      Zeny -= .@zeny_to_gamble;
      .@r = rand(1,10000);
      //dispbottom ""+.@r+""; //debug
	
      if(.@r <= (.@zeny_to_gamble == 5000 ? 500:1000))
      {
		mes "Won with "+((.@zeny_to_gamble == 5000 ? 5:10))+"%!";
		getitem 607,1;
      }
      else mes "You were not lucky.";
      close;

 

  • Upvote 1
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...