Jump to content
  • 0

How to change zeny into Cash Points?


Question

Posted

Hello,

 

I'm using this script at my server.. https://rathena.org/board/files/file/2821-coin-exchanger/

Right now, I want to change coins into Cash Points or Zeny into Cash Points.. I tried to edit but seems not working.. Can anyone guide me? Thanks..



prontera,151,155,5	script	Coin Manager	906,{
function int__;

do{
	callsub exchange_rate;
	.@menu = select( "Zeny to Coin","Coin to Zeny","Close" );
	switch( .@menu ){
		Case 1:
			mes "Convert Zeny to which Coins ?";
			.@coin = select( implode( .coin_name$,":" ) ) - 1;
			if( Zeny <  .value[.@coin] ){
				mes "^FF0000[ERROR]^000000 You didnt have enough zeny.";
			}else{
				.@maximum = Zeny / .value[.@coin];
				mes "You can get maximum of ^FF0000"+int__( .@maximum )+" x "+getitemname( .coin_id[.@coin] )+"^000000";
				input .@amount,0,.@maximum;
				if( .@maximum )
					if( checkweight( .coin_id[.@coin],.@amount ) ){
						.@total = ( .@amount * .value[.@coin] );
						Zeny -= .@total;
						getitem .coin_id[.@coin],.@amount;
						message strcharinfo(0),"Exchanged "+int__( .@total )+" Zeny to "+int__( .@amount )+" "+getitemname( .coin_id[.@coin] )+"^000000";
					}else{
						mes "^FF0000[ERROR]^000000 You cant take this much.";
					}
			}
			break;
		Case 2:
			mes "Convert which Coins to Zeny ?";
			.@coin = select( implode( .coin_name$,":" ) ) - 1;
			if( !countitem( .coin_id[.@coin] ) ){
				mes "^FF0000[ERROR]^000000 You didnt have any "+getitemname( .coin_id[.@coin] )+".";
			}else if( ( .max_zeny - Zeny ) < .value[.@coin] ){
				mes "^FF0000[ERROR]^000000 You cant exchange this Coin as it will exceed the Zeny limit.";
			}else{
				.@maximum = (( .max_zeny - Zeny ) / .value[.@coin] );
				if( .@maximum > countitem( .coin_id[.@coin] ) ) .@maximum = countitem( .coin_id[.@coin] );
				mes "You can exchange maximum of ^FF0000"+int__( .@maximum )+" x "+getitemname( .coin_id[.@coin] )+"^000000 to zeny";
				input .@amount,0,.@maximum;
				if( .@maximum ){
					.@total = ( .@amount * .value[.@coin] );
					Zeny += .@total;
					delitem .coin_id[.@coin],.@amount;
					message strcharinfo(0),"Exchanged "+int__( .@amount )+" "+getitemname( .coin_id[.@coin] )+" to "+int__( .@total )+" Zeny^000000";
				}
			}
			break;
		default: break;
	}
	next;
}while( .@menu != 3 );
mes "Thank you.";
close;

exchange_rate:
	mes "Exchange Rate :";
	for( .@i = 0; .@i < .coin_size; .@i++ )
		mes "^777777 > "+.coin_name$[.@i]+" - "+int__( .value[.@i] )+" z^000000";
	return;
	
OnInit:
// server max zeny
.max_zeny = 1000000000;
// coin list + name + value
setarray .coin_name$,"Silver","Gold","Mithril";
setarray .coin_id,675,671,674;
setarray .value,10000,1000000,100000000;

.coin_size = getarraysize( .coin_name$ );
end;


// credits to annieruru
function	int__	{
	set .@num, atoi(""+getarg(0));
	if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
	set .@l, getstrlen(""+.@num);
	for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
		set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
			if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
	}
	return .@num$;
}

}

3 answers to this question

Recommended Posts

  • 0
Posted (edited)

Try this:

prontera,0,0,0	script	Money Changer	100,{

mes "[ Money Changer ]";
mes "Your Cash: "+#CASHPOINTS+"";
mes "Your Zeny: "+Zeny+"";
mes "Rate";
mes "1 cash = 10z";
switch(select("Cash to Zeny:Zeny to Cash")){

	case 1:
	input .@czamt;
	if(.@czamt == 0) { close; }
	next;
	mes "[ Money Changer ]";
	if(#CASHPOINTS < .@czamt){
		mes "Not enough Cash!";
		close; }
	mes "Converting "+.@czamt+" cash to "+.@czamt*10+"z. Continue?";
	if(select("No:Yes") == 1) { close; }
	next;
	mes "[ Money Changer ]";
	mes "Done!";
	set Zeny,Zeny+.@czamt*10;
	set #CASHPOINTS,#CASHPOINTS-.@czamt;
	close;
	
	case 2:
	input .@czamt;
	if(.@czamt == 0) { close; }
	next;
	mes "[ Money Changer ]";
	if(Zeny < .@czamt){
		mes "Not enough Zeny!";
		close; }
	mes "Converting "+.@czamt+"z to "+.@czamt/10+" cash. Continue?";
	if(select("No:Yes") == 1) { close; }
	next;
	mes "[ Money Changer ]";
	mes "Done!";
	set #CASHPOINTS,#CASHPOINTS+.@czamt/10;
	set Zeny,Zeny-.@czamt;
	close; }
	
}
Edited by sotf

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