Jump to content
  • 0
Helena

Don't show last zero in weight (npc dialogue box)?

Question

Hi hi Hercules.

 

I have a small issue, I'm using a query to fetch data but the issue is with weight. As we all know the script display weight is different from the text display, I.e: 200 weight in item_db would in fact only be 20 in RO which causes issues at the following:

 

Im using this query to fetch data (which works perfect):

.@amount = query_sql ("SELECT ID, weight, attack, defence, slots, equip_level FROM item_db WHERE name_japanese = '"+ escape_sql(.@itemname$) +"'", @iid, .@weight, .@attack, .@defence, .@slots, .@elvl); 

 

 

and this in the NPC dialogue box:

mes "Weight: "+.@weight[.@i];

 

It both works, but the weight is not correct. For example with white potion, the NPC dialogue box displays 130 instead of 13. How to make it display only 13?

 

Thank you so much, god bless. :)

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

@@Helena

.@amount = query_sql ("SELECT ID, weight, attack, defence, slots, equip_level FROM item_db WHERE name_japanese = '"+ escape_sql(.@itemname$) +"'", @iid, .@weight, .@attack, .@defence, .@slots, .@elvl); 

change to this

.@amount = query_sql ("SELECT `ID`, `weight`, `attack`, `defence`, `slots`, `equip_level` FROM `item_db` WHERE `name_japanese` = '"+ escape_sql(.@itemname$) +"'", @iid, .@weight, .@attack, .@defence, .@slots, .@elvl); 


@@Helena by the way if weight is 200 in item_db then weight in-game is 20

 

e.g

weight in item_db = weight ingame

1000 = 100

500 = 50

250 = 25

25 = 2.5

5 = 0.5

Share this post


Link to post
Share on other sites
  • 0

@@Helena

.@amount = query_sql ("SELECT ID, weight, attack, defence, slots, equip_level FROM item_db WHERE name_japanese = '"+ escape_sql(.@itemname$) +"'", @iid, .@weight, .@attack, .@defence, .@slots, .@elvl); 

change to this

.@amount = query_sql ("SELECT `ID`, `weight`, `attack`, `defence`, `slots`, `equip_level` FROM `item_db` WHERE `name_japanese` = '"+ escape_sql(.@itemname$) +"'", @iid, .@weight, .@attack, .@defence, .@slots, .@elvl); 

@@Helena by the way if weight is 200 in item_db then weight in-game is 20

 

e.g

weight in item_db = weight ingame

1000 = 100

500 = 50

250 = 25

25 = 2.5

5 = 0.5

 

 

I am aware that it is a display bug. That's why I made this thread, to find a way to "fix" the display bug.

 

I've tried your script but no difference in the display. :(

Share this post


Link to post
Share on other sites
  • 0

Why don't you just divide the weight by 10

            mes "Weight: "+(.@weight[.@i]/10);

?

 

Wow, that was easier than I thought. Thanks so much!

Edited by Helena

Share this post


Link to post
Share on other sites
  • 0

not sure, but you can try....
.
@amount = query_sql ("SELECT ID, (weight/10), attack, defence, slots, equip_level FROM item_db WHERE name_japanese = '"+ escape_sql(.@itemname$) +"'", @iid, .@weight$, .@attack, .@defence, .@slots, .@elvl);

mes "Weight: "+.@weight$; //--> maybe it can show float

 

Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

You could use TRUNCATE(weight/10,1) or ROUND(...) in your query, although the result may not be what you'd except. You could also simply convert the weight manually instead (and make it a function) : 
 

.@weight$ = .@weight;if (.@weight % 10 != 0) {	.@length = getstrlen(.@weight$);	.@weight$ = (.@length == 1 ? "0" : "") + insertchar(.@weight$, ".", .@length - 1);}else {	.@weight$ = .@weight / 10;}

This would give you : 

500 > 50

505 > 50.5

8 > 0.8

Share this post


Link to post
Share on other sites
  • 0

You could use TRUNCATE(weight/10,1) or ROUND(...) in your query, although the result may not be what you'd except. You could also simply convert the weight manually instead (and make it a function) : 

 

.@weight$ = .@weight;if (.@weight % 10 != 0) {	.@length = getstrlen(.@weight$);	.@weight$ = (.@length == 1 ? "0" : "") + insertchar(.@weight$, ".", .@length - 1);}else {	.@weight$ = .@weight / 10;}

This would give you : 

500 > 50

505 > 50.5

8 > 0.8

nope, the query result (floating point numbers) can't be fully saved into *athena integer variable , but can be fully saved into string variable.

my test:

query_sql ("SELECT TRUNCATE(weight/10,1) FROM item_db WHERE name_japanese = 'Poison Arrow'",.@weight);

 

query_sql ("SELECT ROUND(weight/10,1) FROM item_db WHERE name_japanese = 'Poison Arrow'", .@weight$);

 

mes "Weight: "+.@weight;

mes "Weight: "+.@weight$;

Edited by Angelmelody

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.