Jump to content
  • 0

Help with this little script


Question

Posted
-	script	cashmvp	-1,{


OnInit:
	.randcash == rand(10,20);


OnNPCKillEvent:
	if( getmonsterinfo( killedrid,MOB_MVPEXP )){
		atcommand "@cash" .randcash;
		dispbotton .randcash;
			end;
			}
			}

Can't make it work, its supposed to give a random amount of cash, between 10 and 20 every time a player kils an MVP monster. And show a message of how much cash the player got.

5 answers to this question

Recommended Posts

  • 0
Posted (edited)
50 minutes ago, Brizyous said:

-	script	cashmvp	-1,{


OnInit:
	.randcash == rand(10,20);


OnNPCKillEvent:
	if( getmonsterinfo( killedrid,MOB_MVPEXP )){
		atcommand "@cash" .randcash;
		dispbotton .randcash;
			end;
			}
			}

Can't make it work, its supposed to give a random amount of cash, between 10 and 20 every time a player kils an MVP monster. And show a message of how much cash the player got.

dispbottom instead of dispbotton???

 

Update:  Should be good.

Quote

-    script    cashmvp    -1,{
OnNPCKillEvent:
        .@mobIDK = killedrid;
        //dispbottom (" killedrid :: " + killedrid );
        if ( getmonsterinfo( .@mobIDK , MOB_MVPEXP) > 0 ) {
            .@a = callfunc("F_Rand",100,200);
            atcommand ("@Cash " + .@a);
            dispbottom ("Increased Cash " + .@a );
        }
        end;
}

 

Edited by utofaery
  • Upvote 1
  • 0
Posted (edited)

Thanks! it worked but i get either 100 or 200 cash, how do i make so i get a random number from 100 to 200?

edit: i figured it out thanks!

Edited by Brizyous
  • 0
Posted

my bad

change 100 and 200 to anything.

-	script	cashmvp	-1,{
OnNPCKillEvent:
		.@i1 = 100;
		.@i2 = 200;
		if ( getmonsterinfo( killedrid , MOB_MVPEXP) > 0 ) {
			.@a = callfunc("F_Rand",.@i1,.@i2);
			atcommand ("@Cash " + .@a);
			dispbottom ("Increased Cash " + .@a );
		}
		end;
}


 

  • 0
Posted
On 1/29/2019 at 4:15 AM, Brizyous said:

i used  rand(10,20) instead of the function, do u think it could have any bugs like that or its fine?

Replace the line from :

-    script    cashmvp    -1,{
OnNPCKillEvent:
        if ( getmonsterinfo( killedrid , MOB_MVPEXP) > 0 ) {
            .@a = rand(10,20);
            atcommand ("@Cash " + .@a);
            dispbottom ("Increased Cash " + .@a );
        }
        end;
}

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