Jump to content
  • 0

Division problem


Question

Posted

I was trying to make a npc and had a problem when making a division ... count returns 0

prt_in,63,58,3 script test 826,{
set .price_R, 100000;
set .desc, 50;
mes "repair all?";
next;
if(select("- yes:- close")==1){
mes "ok";
set .price_R2, .price_R*(.desc/100);
set Zeny, Zeny - .price_R2;
atcommand "@repairall";
close;
}
else {close;}

}

.desc/100 >> Returns 0... how to solve this?

thks

5 answers to this question

Recommended Posts

Posted

It is, so long as your result is greater than zero. You just need to be careful with your order of operations, making sure no result ever hits 0 or an unwanted decimal.

Posted

So rA script language doesn't have any round/floor/ceiling function?

there is.....

For Example :

5 / 2 = 2

the actual result should be 2.5 but it only return 2 ....

decimal is not supported in emulator...


in your case....

.price_R*(.desc/100);

this calculation .... is the problem...

( .desc/100 ) 

because emulator doesnt support decimal places....

if any possibility that your variable is below 100 ...it will return 0 ....

then...the calculation will become something like this..

.price_R * 0;

this is commen sense...every value that is multiply by 0 will return you 0 as answer....

basically it's the way how you write the formulae affect the answer it return .....


if you are doing it like this..

( .price_R * .desc ) / 100;

then it should be no problem...if your formulae...

( .price_R * .desc )

return a value bigger than 100 ....

  • Upvote 1

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