Jump to content
  • 0
Thyr

Token Quest Shop

Question

Hello anyone here can help me edit the Token to Zeny? I don't understand how it is working I want it to make 5m - 1 T,  50m - 10T, and  500m - 100T

Here's the script I use.

// Trades tokens
// getarg(0) - number of tokens to be traded
function	script	thqs_trade_token	{
	@type = getarg(0);
	if( @type == 4 )
		close;

	// 10^0, 10^1, 10^2
	@type -= 1;
	@price = (10 ** @type);

	// 10^3, 10^4, 10^5
	@type += 3; // So we can use pow later to determine the qt of Zeny
	@prize = (10 ** @type);

	if( #Treasure_Token < @price ) {
		mes "You don't have enough tokens!";
		close;
	}

	if( Zeny == MAX_ZENY ) {
		mes "You can't add more zeny to your character";
		close;
	}

	Zeny += @prize;
	#Treasure_Token -= @price;
	close;
}

// Main script
prt_in,164,174,1	script	Treasure Hunter's Shop	1_M_YOUNGKNIGHT,{
	mes "[Ash]";
	mes "Ahh, "+strcharinfo(PC_NAME)+"! Welcome to the Offical Treasure Hunter's Guild Shop.";
	mes "You currently have ^FF0000"+#Treasure_Token+"^000000 treasure tokens!!!";
	next;
	switch( select("How does this place work?","What do you have in stock?","Nevermind") ) {
		case 1:
			mes "[Ash]";
			mes "Well you see here you can exchange your treasure hunter tokens for zeny or rare weapons forged by our blacksmiths.";
			mes " ";
			mes "Everything has its own price value and the only way you can get the tokens is by completing quests assigned to you,the system normally works like this.";
			mes " ";
			mes "The harder the mission the more Tokens you will earn. All red quests are worth 4-8 Tokens, and the rest are worth 1-5.";
			mes " ";
			mes "Hope that solves your problem and questions.";
			close;
		case 2:
			break;
		case 3:
			close;
	}

	mes "[Ash]";
	mes "Ok here is our Big list of goods.";
	mes " ";
	mes "(Note T stands for a Treasure Token.)";
	next;
	mes "[Ash]";
	mes "This is what we have to offer.";
	next;
	switch( select("Trade for zeny", "Trade for Weapons", "Trade for Cards", "Nevermind") ) {
		case 1:
			select("1000z - 1T","10000z - 10T","100000z - 100T","Nevermind");
			thqs_trade_token(@menu);
		case 2:
			mes "[Ash]";
			mes "This is what we have to offer.";
			next;
			select("Axe's","1 Handed Swords","2 Handed Swords","Book's","Bow's","Katar's","Knuckle's","Mace's","Whips","Wands","Nevermind");
			ths_menu_weapons(@menu);
		case 3:
			mes "[Ash]";
			mes "This is what we have to offer.";
			next;
			thqs_menu_buy("$THQS_menu_cards","$THQS_menu_price");
		case 4:
			close;
	}
	end;
}

 

Edited by Thyr

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0
// 10^3, 10^4, 10^5
@type += 6; // So we can use pow later to determine the qt of Zeny
@prize = (10 ** @type);
@fnlprize = @prize * 5;

then change

Zeny += @prize; -- to -- Zeny += @fnlprize;

 

Share this post


Link to post
Share on other sites
  • 0
On 5/7/2018 at 3:26 PM, Rebel said:

// 10^3, 10^4, 10^5
@type += 6; // So we can use pow later to determine the qt of Zeny
@prize = (10 ** @type);
@fnlprize = @prize * 5;

then change

Zeny += @prize; -- to -- Zeny += @fnlprize;

 

How can i determine if it exchange 5m - 1 T,  50m - 10T, and  500m - 100T?

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, Thyr said:

How can i determine if it exchange 5m - 1 T,  50m - 10T, and  500m - 100T?

TRY IT.

Share this post


Link to post
Share on other sites
  • 0
prontera,158,185,1	script	Debug	1_F_MARIA,{
	input #Treasure_Token, 0, 10000;
	Zeny = 0;
}

prontera,161,185,1	script	Debug 2	1_F_MARIA,{
	select "5m Zeny -> 1 Token", "50m Zeny -> 10 Token", "500m -> 100 Token", "Nevermind";
	dispbottom @menu +" "+ 5000000 * 10 ** (@menu -1) +" "+ 10 ** (@menu -1);
	close;
}
prontera,155,185,1	script	Treasure Hunter's Shop	1_M_YOUNGKNIGHT,{
	mes "[Ash]";
	mes "Ahh, "+ strcharinfo(PC_NAME) +"! Welcome to the Offical Treasure Hunter's Guild Shop.";
	mes "You currently have ^FF0000"+ #Treasure_Token +"^000000 treasure tokens!!!";
	next;
	switch( select( "How does this place work?","What do you have in stock?","Nevermind" ) ) {
	case 1:
		mes "[Ash]";
		mes "Well you see here you can exchange your treasure hunter tokens for zeny or rare weapons forged by our blacksmiths.";
		mes " ";
		mes "Everything has its own price value and the only way you can get the tokens is by completing quests assigned to you,the system normally works like this.";
		mes " ";
		mes "The harder the mission the more Tokens you will earn. All red quests are worth 4-8 Tokens, and the rest are worth 1-5.";
		mes " ";
		mes "Hope that solves your problem and questions.";
		close;
	case 2:
		mes "[Ash]";
		mes "Ok here is our Big list of goods.";
		mes " ";
		mes "(Note T stands for a Treasure Token.)";
		next;
		mes "[Ash]";
		mes "This is what we have to offer.";
		next;
		switch( select( "Trade with zeny", "Nevermind" ) ) {
		case 1:
			select "5m Zeny -> 1 Token", "50m Zeny -> 10 Token", "500m -> 100 Token", "Nevermind";
			if ( @menu == 4 )
				close;
			if ( #Treasure_Token < 10 ** (@menu -1) ) {
				mes "[Ash]";
				mes "You don't have enough tokens!";
				close;
			}
			if ( Zeny > MAX_ZENY - 5000000 * 10 ** (@menu -1) ) {
				mes "[Ash]";
				mes "You can't add more zeny to your character";
				close;
			}
			Zeny += 5000000 * 10 ** (@menu -1);
			#Treasure_Token -= 10 ** (@menu -1);
			close;
		default:
		}
	default:
	}
	close;
}

btw your way of handling the MAX_ZENY is wrong, can cause integer overflow

[Warning]: script:op_2num: overflow detected op=C_ADD i1=2147483647 i2=500000000
[Debug]: Source (NPC): Treasure Hunter's Shop at prontera (155,185)

 


 

if you don't like mathematics then just hard-code the value

prontera,155,185,1	script	Treasure Hunter's Shop	1_M_YOUNGKNIGHT,{
	mes "[Ash]";
	mes "Ahh, "+ strcharinfo(PC_NAME) +"! Welcome to the Offical Treasure Hunter's Guild Shop.";
	mes "You currently have ^FF0000"+ #Treasure_Token +"^000000 treasure tokens!!!";
	next;
	switch( select( "How does this place work?","What do you have in stock?","Nevermind" ) ) {
	case 1:
		mes "[Ash]";
		mes "Well you see here you can exchange your treasure hunter tokens for zeny or rare weapons forged by our blacksmiths.";
		mes " ";
		mes "Everything has its own price value and the only way you can get the tokens is by completing quests assigned to you,the system normally works like this.";
		mes " ";
		mes "The harder the mission the more Tokens you will earn. All red quests are worth 4-8 Tokens, and the rest are worth 1-5.";
		mes " ";
		mes "Hope that solves your problem and questions.";
		close;
	case 2:
		mes "[Ash]";
		mes "Ok here is our Big list of goods.";
		mes " ";
		mes "(Note T stands for a Treasure Token.)";
		next;
		mes "[Ash]";
		mes "This is what we have to offer.";
		next;
		switch( select( "Trade with zeny", "Nevermind" ) ) {
		case 1:
			switch( select( "5m Zeny -> 1 Token", "50m Zeny -> 10 Token", "500m -> 100 Token", "Nevermind" ) ) {
			case 1:
				.@zeny = 5000000;
				.@token = 10;
				break;
			case 2:
				.@zeny = 50000000;
				.@token = 10;
				break;
			case 3:
				.@zeny = 500000000;
				.@token = 100;
				break;
			case 4:
				close;
			}
			if ( #Treasure_Token < .@token ) {
				mes "[Ash]";
				mes "You don't have enough tokens!";
				close;
			}
			if ( Zeny > MAX_ZENY - .@zeny ) {
				mes "[Ash]";
				mes "You can't add more zeny to your character";
				close;
			}
			Zeny += .@zeny;
			#Treasure_Token -= .@token;
			close;
		default:
		}
	default:
	}
	close;

}

 

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

I got this problem too, possible to fix?

[Warning]: script:op_2num: overflow detected op=C_ADD i1=2147483647 i2=500000000
[Debug]: Source (NPC): Treasure Hunter's Shop at prontera (155,185)

 

Share this post


Link to post
Share on other sites
  • 0

@ThyroDree you could use the script AnnieRuru provided here:

Spoiler
On 3.6.2018 at 1:01 PM, AnnieRuru said:

if you don't like mathematics then just hard-code the value



prontera,155,185,1	script	Treasure Hunter's Shop	1_M_YOUNGKNIGHT,{
	mes "[Ash]";
	mes "Ahh, "+ strcharinfo(PC_NAME) +"! Welcome to the Offical Treasure Hunter's Guild Shop.";
	mes "You currently have ^FF0000"+ #Treasure_Token +"^000000 treasure tokens!!!";
	next;
	switch( select( "How does this place work?","What do you have in stock?","Nevermind" ) ) {
	case 1:
		mes "[Ash]";
		mes "Well you see here you can exchange your treasure hunter tokens for zeny or rare weapons forged by our blacksmiths.";
		mes " ";
		mes "Everything has its own price value and the only way you can get the tokens is by completing quests assigned to you,the system normally works like this.";
		mes " ";
		mes "The harder the mission the more Tokens you will earn. All red quests are worth 4-8 Tokens, and the rest are worth 1-5.";
		mes " ";
		mes "Hope that solves your problem and questions.";
		close;
	case 2:
		mes "[Ash]";
		mes "Ok here is our Big list of goods.";
		mes " ";
		mes "(Note T stands for a Treasure Token.)";
		next;
		mes "[Ash]";
		mes "This is what we have to offer.";
		next;
		switch( select( "Trade with zeny", "Nevermind" ) ) {
		case 1:
			switch( select( "5m Zeny -> 1 Token", "50m Zeny -> 10 Token", "500m -> 100 Token", "Nevermind" ) ) {
			case 1:
				.@zeny = 5000000;
				.@token = 10;
				break;
			case 2:
				.@zeny = 50000000;
				.@token = 10;
				break;
			case 3:
				.@zeny = 500000000;
				.@token = 100;
				break;
			case 4:
				close;
			}
			if ( #Treasure_Token < .@token ) {
				mes "[Ash]";
				mes "You don't have enough tokens!";
				close;
			}
			if ( Zeny > MAX_ZENY - .@zeny ) {
				mes "[Ash]";
				mes "You can't add more zeny to your character";
				close;
			}
			Zeny += .@zeny;
			#Treasure_Token -= .@token;
			close;
		default:
		}
	default:
	}
	close;

}

 

 

Edited by Winterfox

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.