SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Y_INI Storing not storing float in OnGameModeInit (https://forum.sa-mp.com/showthread.php?t=676074)

Electrifying 29/05/2020 02:53 AM

Y_INI Storing not storing float in OnGameModeInit
 
I'm trying to store positions of an A/D Arena into a .ini file to load after it

The thing is Y_INI is saving the float as "0.00000000000000000000000000000000000000000000000 000000000000000"
but not the value passed on the script

Code:

        new INI:AD_FILE = INI_Open("ADArenas/AmmuLS.ini");       
        if(AD_FILE != INI_NO_FILE){
                INI_SetTag(AD_FILE, "AD_ATTACKER");
                INI_WriteFloat(AD_FILE, "A_X", 1267.2345);
                INI_WriteFloat(AD_FILE, "A_Y", -1411.1877);
                INI_WriteFloat(AD_FILE, "A_Z", 12.8666);
                INI_SetTag(AD_FILE, "AD_DEENDER");
                INI_WriteFloat(AD_FILE, "D_X", 1259.3921);
                INI_WriteFloat(AD_FILE, "D_Y", -1403.4626);
                INI_WriteFloat(AD_FILE, "D_Z", 13.0036);
                INI_SetTag(AD_FILE, "CHECKPOINT");
                INI_WriteFloat(AD_FILE, "CP_X", 1267.2631);
                INI_WriteFloat(AD_FILE, "CP_Y", -1265.8411);
                INI_WriteFloat(AD_FILE, "CP_Z", 13.3806);
                INI_Close(AD_FILE);
        }

The File:
Code:

[CHECKPOINT]
CP_Z=0.00000000000000000000000000000000000000000000000000000000000000
CP_Y=0.000000
CP_X=0.00000000000000000000000000000000000000000000000000000000000000
[AD_DEENDER]
D_Z=0.00000000000000000000000000000000000000000000000000000000000000
D_Y=0.000000
D_X=0.00000000000000000000000000000000000000000000000000000000000000
[AD_ATTACKER]
A_Z=0.00000000000000000000000000000000000000000000000000000000000000
A_Y=0.000000
A_X=0.00000000000000000000000000000000000000000000000000000000000000

You can see the tags are out of order either

Runn3R 29/05/2020 08:11 AM

Re: Y_INI Storing not storing float in OnGameModeInit
 
It's out of order cause your appending to a file aka adding to the file the bottom of the file is your first line.

Try making a new variable then assign the value to it rather than just typing it in inside the WriteFloat.

Electrifying 29/05/2020 07:23 PM

Re: Y_INI Storing not storing float in OnGameModeInit
 
Quote:

Originally Posted by Runn3R (Post 4148537)
It's out of order cause your appending to a file aka adding to the file the bottom of the file is your first line.

Try making a new variable then assign the value to it rather than just typing it in inside the WriteFloat.

Yeah, I've tried this, no solution

I did something like this

PHP Code:

new Float:AmmuLs_attacker[3] = {float0float1float2}; 

and I've placed AmmuLs_attacker[0], AmmuLs_attacker[1], AmmuLs_attacker[2]

Electrifying 29/05/2020 09:36 PM

Re: Y_INI Storing not storing float in OnGameModeInit
 
Anyone?

xRadical3 29/05/2020 10:16 PM

Re: Y_INI Storing not storing float in OnGameModeInit
 
Store coords as string and try.
See this example:
pawn Code:
INI_Write(AD_FILE, "CP_XYZ", "1267.2631,-1265.8411,13.3806");

//get coords from string with sscanf
new dest[64], Float:x, Float:y, Float:z;
INI_Get(AD_FILE, "CP_XYZ", dest);
sscanf(dest, "p<,>fff", x, y, z);

Electrifying 29/05/2020 10:46 PM

Re: Y_INI Storing not storing float in OnGameModeInit
 
Quote:

Originally Posted by xRadical3 (Post 4148663)
Store coords as string and try.
See this example:
pawn Code:
INI_Write(AD_FILE, "CP_XYZ", "1267.2631,-1265.8411,13.3806");

//get coords from string with sscanf
new dest[64], Float:x, Float:y, Float:z;
INI_Get(AD_FILE, "CP_XYZ", dest);
sscanf(dest, "p<,>fff", x, y, z);

Yes, saving as String is working, thanks. Looks like there's something wrong with WriteFloat


All times are GMT. The time now is 08:52 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.