SA-MP Forums Archive
[SOLVED] Algebraic Expression - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED] Algebraic Expression (/showthread.php?tid=90866)



[SOLVED] Algebraic Expression - Blantas - 10.08.2009

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.







Re: Algebraic Expression - RSX - 10.08.2009

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


Re: Algebraic Expression - Blantas - 10.08.2009

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



Re: Algebraic Expression - Weirdosport - 10.08.2009

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


Re: Algebraic Expression - s0nic - 10.08.2009

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



Re: Algebraic Expression - Blantas - 10.08.2009

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



Re: Algebraic Expression - paytas - 10.08.2009

You have to divide by a float value.


Re: Algebraic Expression - Blantas - 10.08.2009

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.


Re: Algebraic Expression - paytas - 10.08.2009

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.


Re: Algebraic Expression - Blantas - 10.08.2009

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.