SA-MP Forums Archive
Help about strval and float - 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: Help about strval and float (/showthread.php?tid=177488)



Help about strval and float - Diagram - 18.09.2010

About this line :
pawn Код:
if( strcmp( key , "VehicleLocX1", true ) == 0) { val = ini_GetValue( Data ); PlayerInfo[playerid][pVlocx1] = strval( val );}
So basically, [pVlocx1] is used to store the X location of a car, and I store it in a .ini file as a float.
But when the script tried to pull information on the .ini file, it actually converts it into an integer with strval.
That's why my script in https://sampforum.blast.hk/showthread.php?tid=177075 crashes.

The question is, can I change this "strval" into a function that turns "val" into a float? Tried using float(val) but then it shows argument type mismatch on the pawno.


Any help would be appreciated, thanks.


Re: Help about strval and float - Ash. - 18.09.2010

Im not sure, but couldnt you do something like this?

*Note, ive never had/come accross this before, and so i might be wrong

pawn Код:
new Float:Temp_X[MAX_PLAYERS];
Temp_X[playerid] = strval(val);

//Then back to your code

if( strcmp( key , "VehicleLocX1", true ) == 0) { val = ini_GetValue( Data ); PlayerInfo[playerid][pVlocx1] = Temp_X[playerid];}
Like i said, im not sure, but its worth a try i guess?


Re: Help about strval and float - Diagram - 18.09.2010

Still crashes.

In my code, the ini_GetValue is used to take the data, and stores it into "val".
If you changed it like this :
pawn Код:
PlayerInfo[playerid][pVlocx1] = Temp_X[playerid];
Wouldn't that makes the [pVlocx1] as 0.0 instead of the data stored in val?

Nevertheless, thanks.


Re: Help about strval and float - Double-O-Seven - 18.09.2010

For floats you must use floatstr, not strval.


Re: Help about strval and float - Diagram - 18.09.2010

Ah, that solved the problem perfectly.
Thanks Double-O-Seven.

Requesting lock for the thread, thanks.