[HELP] float is written as 0.0000
#1

Hello everyone. I was working something about event system and I made saving of all data and some data is saved but the problem is arround float it should saved cordinates which I get from player vehicle in the file but I get in file like 0.0000. Thanks

pawn Код:
GetVehiclePos(GetPlayerVehicleID(playerid),evPos[0],evPos[1],evPos[2]);
            format(string,sizeof(string),"CP%dPosX",idcpa);
            INI_WriteFloat(File,string,evPos[0]);
            format(string,sizeof(string),"CP%dPosY",idcpa);
            INI_WriteFloat(File,string,evPos[1]);
            format(string,sizeof(string),"CP%dPosZ",idcpa);
            INI_WriteFloat(File,string,evPos[2]);
Reply
#2

pawn Код:
GetVehiclePos(GetPlayerVehicleID(playerid),evPos[0],evPos[1],evPos[2]);        
            INI_WriteFloat(File,X,evPos[0]);
            INI_WriteFloat(File,Y,evPos[1]);
            INI_WriteFloat(File,Z,evPos[2]);
Reply
#3

I need all of that code which I provide not just this which I also try. Thanks

and you put everything fine but there is format string

and INI_WriteFloat(there you don't have string? )
Thanks

CP%dPosX",idcpa); // this code also have a purpose and I can't do this without it
Reply
#4

anyone? Thanks
Reply
#5

make sure variable is declared like this -
Quote:

new Float:evPos[3];

And make sure that player is in vehicle when the following code is executed
Reply
#6

Yes I did that
Reply
#7

Try this
pawn Код:
new temp[20];
GetVehiclePos(GetPlayerVehicleID(playerid),evPos[0],evPos[1],evPos[2]);
format(temp, sizeof(temp), "%.0f", evPos[0]);
format(string,sizeof(string),"CP%dPosX",idcpa);
INI_WriteString(File,string,temp, sizeof(temp));
format(temp, sizeof(temp), "%.0f", evPos[1]);
format(string,sizeof(string),"CP%dPosY",idcpa);
INI_WriteString(File,string,temp,sizeof(temp));
format(temp, sizeof(temp), "%.0f", evPos[2]);
format(string,sizeof(string),"CP%dPosZ",idcpa);
INI_WriteString(File,string,temp,sizeof(temp));
Reply
#8

I again get written in the file 0.0000
Reply
#9

Did you checked that these floats aren't zero ?
Because I don't think that the problems is with INI_WriteFloat
pawn Код:
GetVehiclePos(GetPlayerVehicleID(playerid),evPos[0],evPos[1],evPos[2]);

printf("%f %f %f", evPos[0], evPos[1], evPos[2]);

format(string,sizeof(string),"CP%dPosX",idcpa);
INI_WriteFloat(File,string,evPos[0]);
format(string,sizeof(string),"CP%dPosY",idcpa);
INI_WriteFloat(File,string,evPos[1]);
format(string,sizeof(string),"CP%dPosZ",idcpa);
INI_WriteFloat(File,string,evPos[2]);
If they are all zero than the player isn't in any vehicle
Reply
#10

these is what is printed in console

[15:57:17] 1786.763793 1447.293090 6.299123
[15:57:21] 1787.098632 1522.474731 6.301001
[15:57:24] 1788.441772 1595.715087 6.301182
[15:57:27] 1789.998046 1680.599487 6.300642
[15:57:34] 1792.211059 1801.224365 6.300647
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)