SA-MP Forums Archive
floats - 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: floats (/showthread.php?tid=182140)



SOLVED[Floats] - armyoftwo - 09.10.2010

the fStock variable's value: 13.92
When i do this:
Код:
FactoryInfo[GetPVarInt(playerid, "InFactory")][fStock] -= 1.00;
Then it shows up as: 137853251231.00 can someone help me?
I use this format to show the value:
%0.2f


Re: floats - hencz - 09.10.2010

if fStock in your enum marked with Float: ?


Re: floats - armyoftwo - 09.10.2010

yes lol, i said that it shows up as 13.92 before the -= 1.00


Re: floats - Mean - 09.10.2010

I am not too good with pWars, i cant help you there


Re: floats - armyoftwo - 09.10.2010

Quote:
Originally Posted by Mean
Посмотреть сообщение
I am not too good with pWars, i cant help you there
The pvars is fine, but the -= 1; is not


Re: floats - legodude - 09.10.2010

new Float:minus=-1.00;
FactoryInfo[GetPVarInt(playerid, "InFactory")][fStock] -= 1.00;

and then use floatsub(tract) with the vars


Re: floats - Voldemort - 09.10.2010

You print it wrong you want print decial as float or float as decimal, cant understand from your post that.


Re: floats - Babul - 09.10.2010

GetPVarFloat, not GetPVarInt? ah silly me, an array calling this way aint possible ><


Re: floats - armyoftwo - 09.10.2010

Babul, i dont need an float there example: InFactory = 1( factory id from wich i want to take off the 1.00)


Re: floats - armyoftwo - 09.10.2010

Quote:
Originally Posted by armyoftwo
Посмотреть сообщение
Babul, i dont need an float there example: InFactory = 1( factory id from wich i want to take off the 1.00)
Quote:
Originally Posted by Macluawn
Посмотреть сообщение
did you even read what i said◘? i repeat again THERES NOTHING WRONG WITH THE GETPVARINT ITS JUST THE -1.00!! sorry for caps

Thanks legodude, i am sure that the function will work.


Re: floats - Babul - 09.10.2010

i assume you want to it like this:
FactoryInfo[GetPVarInt(playerid, "InFactory")][fStock] -= 1.00;
equals
FactoryInfo[1][fStock] -= 1.00;// nothing wrong with the PVar. it needs to be an Integer (to call an array indeed)
equals
FactoryInfo[1][1] -= 1.00;//assuming any value 1 for fStock would do fine...
that makes me to ask you if you initialized it as a float? coz you store a float inside...
Код:
new Float:FactoryInfo[][];
if you print out an integer as a float, such huge values like 137853251231.00 are normal.
i suggest you to store the values as a float and later then you can print them out by using
Код:
format(string,sizeof(string),"%f",FactoryInfo[1][1]);//1 and 1 made it simpler to read
as you told us. is there any difference to the way you tried? or did i run into the same problem yet?


Re: floats - armyoftwo - 09.10.2010

Yes i have the variable as a float, its in table. Float:fStock
And no i am storing them as floats not as integers
EDIT: fu** i just needed to convert the TakeOff = 1; to a float,
Код:
FactoryInfo[GetPVarInt(playerid, "InFactory")][fStock] -= float(TakeOff);