Help about strval and float
#1

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.
Reply
#2

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?
Reply
#3

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.
Reply
#4

For floats you must use floatstr, not strval.
Reply
#5

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

Requesting lock for the thread, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)