Jump to content
  • 0

Need help using rand command.


Rojen

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  05/22/18
  • Last Seen:  

sec_in02,154,165,6    script    Fishing Hole    723,{
    
//Fishing rod
set .@Rod,2764;
//Fishing Lure
set .@Lure,2775;
//Auto-Fish
set .@Auto,1;
//Auto-Fish on Fail
set .@AutoFail,1;
Fish:
    if (isequipped(.@Rod)) && (isequipped(.@Lure)){
        specialeffect EF_BUBBLE,"Fishing Hole";

        dispbottom "[Fishing] Baiting.....";
        set .@fcast,11;
            if (isequipped(2550)) { //Fisher's Muffler
                set .@fcast,.@fcast - 2;
            }
            if (isequipped(2443)) { //Fisher's Boots
                set .@fcast,.@fcast - 2;
            }
            if (isequipped(2764)) { //Fishing Rode
                set .@fcast,.@fcast - 3;
            }
            if (isequipped(2775)) { //Fishing Lure
                set .@fcast,.@fcast - 1;
            }
        progressbar "ffffff",.@fcast;
        if (rand(1,40) == 2){
        getitem 26080,1; //Credit
        specialeffect2 EF_TEMP_OK;
        mapannounce strcharinfo(3),strcharinfo(0)+" has caught a ATM Credit Card x1!",bc_map,"0xff77ff";
        }
        if (rand(1,40) == 2){
        getitem 7227,5; //TCG
        specialeffect2 EF_TEMP_OK;
        mapannounce strcharinfo(3),strcharinfo(0)+" has caught TCG Cards x5!",bc_map,"0xff77ff";
        }
        if (rand(1,50) == 2){
        getitem 671,1; //Gold Coins
        specialeffect2 EF_TEMP_OK;
        mapannounce strcharinfo(3),strcharinfo(0)+" has caught a Gold Coin x1!",bc_map,"0xff77ff";
        }
        if(.@Auto==1){
        goto Fish;}else{
        end;}     
        } else {
    dispbottom "[Fishing] You need a Fishing Rod and Lure.";
    end;
    }


}

This is my script. Actually this script is working. I just don't understand the "rand"

I want 10% for ATM Credit
I want 5% for TCG Card
and 1% for Gold Coin.

PLEASE HELP!

 

Edited by TheDerpySupport
Codebox
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.01
  • Content Count:  208
  • Reputation:   60
  • Joined:  09/23/17
  • Last Seen:  

Well this is my script you're using so It's relatively easy to understand;

        if (rand(0,9) == 2){
        getitem 26080,1; //Credit
        specialeffect2 EF_TEMP_OK;
        mapannounce strcharinfo(3),strcharinfo(0)+" has caught a ATM Credit Card x1!",bc_map,"0xff77ff";
        }

This would be 10%
rand(0,19) would be 5% and 1% would be rand(0,99)

  • Love 1
Link to comment
Share on other sites

  • 0

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

sec_in02,154,165,6    script    Fishing Hole    723,{
    
//Fishing rod
set .@Rod,2764;
//Fishing Lure
set .@Lure,2775;
//Auto-Fish
set .@Auto,1;
//Auto-Fish on Fail
set .@AutoFail,1;
Fish:
    if (isequipped(.@Rod)) && (isequipped(.@Lure)){
        specialeffect EF_BUBBLE,"Fishing Hole";

        dispbottom "[Fishing] Baiting.....";
        set .@fcast,11;
            if (isequipped(2550)) { //Fisher's Muffler
                set .@fcast,.@fcast - 2;
            }
            if (isequipped(2443)) { //Fisher's Boots
                set .@fcast,.@fcast - 2;
            }
            if (isequipped(2764)) { //Fishing Rode
                set .@fcast,.@fcast - 3;
            }
            if (isequipped(2775)) { //Fishing Lure
                set .@fcast,.@fcast - 1;
            }
        progressbar "ffffff",.@fcast;
        if (rand(1,10) == 2){ // 10%
        getitem 26080,1; //Credit
        specialeffect2 EF_TEMP_OK;
        mapannounce strcharinfo(3),strcharinfo(0)+" has caught a ATM Credit Card x1!",bc_map,"0xff77ff";
        }
        if (rand(1,20) == 2){ // 5%
        getitem 7227,5; //TCG 
        specialeffect2 EF_TEMP_OK;
        mapannounce strcharinfo(3),strcharinfo(0)+" has caught TCG Cards x5!",bc_map,"0xff77ff";
        }
        if (rand(1,100) == 2){ 1%
        getitem 671,1; //Gold Coins
        specialeffect2 EF_TEMP_OK;
        mapannounce strcharinfo(3),strcharinfo(0)+" has caught a Gold Coin x1!",bc_map,"0xff77ff";
        }
        if(.@Auto==1){
        goto Fish;}else{
        end;}     
        } else {
    dispbottom "[Fishing] You need a Fishing Rod and Lure.";
    end;
    }


}

Applying the basic math for percentage will do the trick.

Edited by crazyarashi
  • Love 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...