float problems - 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)
+--- Thread: float problems (
/showthread.php?tid=657196)
float problems -
IdonTmiss - 02.08.2018
Well I'm doing a system with a float well it wont work anyways
pawn Код:
PlayerInfo[playerid][pFloatt] += 4200 / KIP[eBuyPrice]; // the buy price is 500.000$
va_print("%f float", PlayerInfo[playerid][pFloatt]);
[00:33:26] 0.000000 float
Soo yeah?
Re: float problems -
GRiMMREAPER - 02.08.2018
What's the initial value of PlayerInfo[playerid][pFloatt]?
Re: float problems -
IdonTmiss - 02.08.2018
Quote:
Originally Posted by GRiMMREAPER
What's the initial value of PlayerInfo[playerid][pFloatt]?
|
In my MySQL database its "None" if that's what u mean or "0" it types out "0" when I create it, I mean the column
Re: float problems -
GRiMMREAPER - 02.08.2018
Make sure that
PlayerInfo[playerid][pFloatt]* and
KIP[eBuyPrice]* are both floats. Just to be safe, you could convert
4200 to float, therefore making it
4200.0 or
float(4200).
pawn Код:
new Float:foo;
foo += 4200.0/500000.0;
printf("%.5f", foo);
This happens because integer division truncates (4200/500000 < 0, so it truncates — rounds down — to 0), so you need to make sure atleast one of the parameters is of type float.
* In your enums, set
pFloatt to
Float: pFloatt and
eBuyPrice to
Float:eBuyPrice.
Re: float problems -
IdonTmiss - 02.08.2018
Quote:
Originally Posted by GRiMMREAPER
Make sure that PlayerInfo[playerid][pFloatt] and KIP[eBuyPrice] are both floats. Just to be safe, you could convert 4200 to float, therefore making it 4200.0 or float(4200).
pawn Код:
new Float:foo; foo = 4200.0/500000.0; printf("%.5f", foo);
This happens because integer division truncates (4200/500000 < 0, so it truncates — rounds down — to 0), so you need to make sure atleast one of the parameters is of type float.
|
hmm "eBuyPrice" is an int lemme fix that and try
Re: float problems -
GRiMMREAPER - 02.08.2018
Quote:
Originally Posted by IdonTmiss
hmm "eBuyPrice" is an int lemme fix that and try
|
That should be the problem, as the rest of the code has no errors. I appended some information to my initial reply.
Re: float problems -
IdonTmiss - 02.08.2018
Quote:
Originally Posted by GRiMMREAPER
That should be the problem, as the rest of the code has no errors. I appended some information to my initial reply.
|
It works ! Arigato Gozaimasu