Jump to content
  • 0

how do I get this npc to remove 20% of the value on conversion


Question

Posted

how do I get this npc to remove 20% of the value on conversion
for example:
exchange 100 pass for 80 cash (-20%)

 

prontera,155,155,4    script    Converter    83,{

    .@name$ ="[^FF0000Converter^000000]";



    mes .@name$;

    mes "Hello, 1 cashpoints is equals to 1 Pass.";

    mes "What would you like to do?";

    next;



    switch( select("Cash to Pass","Pass to Cash") ) {

        case 1:

            mes .@name$;

            mes "How many pass(s) do you want?";

            input .@num;

            next;



            if( .@num <= 0 || #CASHPOINTS < .@num * 1 ) {

                mes .@name$;

                mes "Sorry, you don't have enough cashpoints!";

                close;

            }

            mes .@name$;

            mes "This will cost ^FF0000" +(.@num * 1)+ " cashpoints^000000.";

            next;



            if( select("Proceed:Nevermind") -1 ) {

                mes .@name$;

                mes "Goodbye!";

                close;

            }

            set #CASHPOINTS, #CASHPOINTS - .@num * 1;

            dispbottom "Lost: " +(.@num * 1)+ " cashpoints. Total: " +#CASHPOINTS+" cashpoints.";

            getitem 7350 , .@num;

            break;

    

        case 2:

            mes .@name$;

            mes "How many Pass(s) will you give?";

            input .@num;

            next;



            if( .@num <= 0 || countitem(7350 ) < .@num ) {

                mes .@name$;

                mes "Sorry, you don't have enough Pass !";

                close;

            }

            mes .@name$;

            mes "I can give you ^FF0000" +(.@num * 1)+ " cashpoints^000000 for this.";

            next;



            if( select("Proceed:Nevermind") -1 ) {

                mes .@name$;

                mes "Goodbye!";

                close;

            }

            set #CASHPOINTS, #CASHPOINTS + .@num * 1;

            dispbottom "Gained: " +(.@num * 1)+ " cashpoints. Total: " +#CASHPOINTS+" cashpoints.";

            delitem 7350 ,.@num;

    }

    close;

}

 

 

3 answers to this question

Recommended Posts

  • 0
Posted

Not sure since I haven't tested this at all, but this line

set #CASHPOINTS, #CASHPOINTS + .@num * 1;

makes me think you could write: 

set #CASHPOINTS, #CASHPOINTS + .@num * (80/100);

 

Again, I haven't tested this. Not sure what would happen if a decimal were put in for .@num either. Should get the ball rolling though.

  • 0
Posted
16 hours ago, chappox said:

Again, I haven't tested this. Not sure what would happen if a decimal were put in for .@num either. Should get the ball rolling though.

the NPC script doesn't support decimal.

the script need to be changed to accept stacks of items instead of 1 by 1 exchange to support the tax on conversion.

prontera,155,155,4	script	Converter	83,{
	.@name$ ="[^FF0000Converter^000000]";
	mes .@name$;
	mes "Hello, 1 cashpoints is equals to 1 Pass.";
	mes "What would you like to do?";
	next;
	switch( select("Cash to Pass","Pass to Cash") ) {
		case 1:
			mes .@name$;
			mes "How many pass(s) do you want?";
			input .@num;
			next;
			mes .@name$;
			mes "This will cost ^FF0000" +.@num+ " cashpoints^000000.";
			next;
			if( select("Proceed:Nevermind") -1 ) {
				mes .@name$;
				mes "Goodbye!";
				close;
			}
			if( .@num <= 0 || #CASHPOINTS < .@num ) {
				mes .@name$;
				mes "Sorry, you don't have enough cashpoints!";
				close;
			}
			set #CASHPOINTS, #CASHPOINTS - .@num;
			dispbottom "Lost: " +.@num+ " cashpoints. Total: " +#CASHPOINTS+" cashpoints.";
			getitem 7350, .@num;
			break;
	
		case 2:
			mes .@name$;
			mes "How many Pass(s) will you give? Multiple of 10";
			input .@num;
			next;
			.@num = ((.@num / 10) * 10);
			mes .@name$;
			mes "I can give you ^FF0000" +((.@num * 8) / 10)+ " cashpoints^000000 for this.";
			next;
			if( select("Proceed:Nevermind") -1 ) {
				mes .@name$;
				mes "Goodbye!";
				close;
			}
			if( .@num < 10 || countitem(7350) < .@num) {
				mes .@name$;
				mes "Sorry, you don't have enough Pass ! Minimum of 10 "+getitemname(7350)+" are required.";
				close;
			}
			delitem 7350, .@num;
			.@num = ((.@num * 8) / 10);
			set #CASHPOINTS, #CASHPOINTS + ((.@num * 8) / 10);
			dispbottom "Gained: " +.@num+ " cashpoints. Total: " +#CASHPOINTS+" cashpoints.";
			break;
	}
	close;
}

 

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