Jump to content
  • 0

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


rickzera

Question


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  51
  • Reputation:   3
  • Joined:  08/01/12
  • Last Seen:  

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;

}

 

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

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

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  123
  • Topics Per Day:  0.03
  • Content Count:  640
  • Reputation:   82
  • Joined:  04/07/14
  • Last Seen:  

I dont see the 20% value.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  12
  • Reputation:   0
  • Joined:  01/18/12
  • Last Seen:  

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.

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