[SOLVED] Algebraic Expression
#1

Hello

I've got a formula:
Код:
((playerHP*204) / 100) + 400
I tried to write it in pawno, but i failed:
Код:
new Float:ExpKord = floatadd(400,floatdiv(floatmul(playerHP,204),100));
When 'playerHP' = 100, 'ExpKord' = 402.040008,
when 'playerHP' = 50, 'ExpKord' = 402.040008,
when 'playerHP' = 1, 'ExpKord' = 402.040008.




Reply
#2

I could say, that i don't see variable for player hp, but maybe i just don't know how to use it...
Reply
#3

Here's more code from GM:
Код:
new Float:playerHP = GetPlayerHealth(i, playerHP);
new Float:ExpKord = floatadd(400,floatdiv(floatmul(playerHP,204),100));
printf("ExpKord: %f",ExpKord);
Reply
#4

A problem is that that isn't how you get the player health.

pawn Код:
new Float:playerHP = 100.0;
    playerHP *= 2.04;
    playerHP += 400;
    printf("%f", playerHP);
That gives you a good value with 100, but you still get the pesky 0008 with 1.0
Reply
#5

Possibly just modify it to this?:
pawn Код:
printf("%.f", playerHP);
Reply
#6

All what I need is how to get this formula work in pawn!
Код:
((playerHP*204) / 100) + 400
Reply
#7

You have to divide by a float value.
Reply
#8

Quote:
Originally Posted by paytas
You have to divide by a float value.
What do you mean? Should I change '100' to '100.0'? Sorry for my bad English, I don't get it.
Reply
#9

Yes exactly replace 100 by 100.0, and it should work. But yeah, *204 and then /100... it's the same as *2.04, and you save one operation.
Reply
#10

Quote:
Originally Posted by paytas
Yes exactly replace 100 by 100.0, and it should work. But yeah, *204 and then /100... it's the same as *2.04, and you save one operation.
Now I got this:
Код:
new Float:ExpKord = floatadd(400.0,floatmul(playerHP,2.04));
And it's still not working.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)