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

Helena

New member
Messages
238
Points
0
Emulator
rAthena
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.
default_smile.png


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

 
@@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.
default_sad.png


 
Why don't you just divide the weight by 10

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

 
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
 

 
Last edited by a moderator:
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

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

 
Last edited by a moderator:
Back
Top