SA-MP Forums Archive
y_ini file saving - 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)
+--- Thread: y_ini file saving (/showthread.php?tid=659371)



y_ini file saving - matje - 01.10.2018

I'm not sure how to create so the files saved using y_ini all have unique ID's (file name as ID), such as 0, 1, 2, 3...
For example, I would have /createhouse command. The first house would have "0" as file name, second house "1" as file name etc.

This is what I have so far but it doesn't work:

Код:
COMMAND:plantweed(playerid, params[]){
    new Float:X, Float:Y, Float:Z;
	GetPlayerPos(playerid, X,Y,Z);
	for(new i = 0; i < MAX_WEED; i++){
     	WeedInfo[i][Faze] = 0;
		WeedInfo[i][LocX] = X;
		WeedInfo[i][LocY] = Y;
		WeedInfo[i][LocZ] = Z;
		WeedSave(i);
		WeedSpawn();
	}
	return 1;
}

WeedSpawn(){
	new hFile[50], string[64];
    for(new i = 0; i < MAX_WEED; i++){
        format(hFile, sizeof(hFile), WEED_PATH, i);
        if(fexist(hFile)){
            INI_ParseFile(hFile, "WeedLoad", .bExtra = true, .extra = i);
            WeedObjects[i] = CreateDynamicObject(3409, WeedInfo[i][LocX], WeedInfo[i][LocY], WeedInfo[i][LocZ] - 2, 0, 0, 0, -1, -1, -1, STREAMER_OBJECT_SD, STREAMER_OBJECT_DD, -1, 0);
            format(string, sizeof(string), "Weed ID: %d\nWeed Faze: %d", i, WeedInfo[i][Faze]);
	       	WeedLabel[i] = CreateDynamic3DTextLabel( string, -1, WeedInfo[i][LocX], WeedInfo[i][LocY], WeedInfo[i][LocZ], 20, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0,-1, -1, -1, STREAMER_3D_TEXT_LABEL_SD, -1, 0);
		}
	}
}

forward WeedLoad(id, name[], value[]);
public WeedLoad(id, name[], value[]){
    INI_Int("Faze", WeedInfo[id][Faze]);
    INI_Float("EnterX", WeedInfo[id][LocX]);
    INI_Float("EnterY", WeedInfo[id][LocY]);
    INI_Float("EnterZ", WeedInfo[id][LocZ]);
    return 1;
}

stock WeedSave(id){
    new hFile[50];
    format(hFile, sizeof(hFile), WEED_PATH, id);
    new INI:File = INI_Open(hFile);
    INI_WriteInt(File, "Faze", WeedInfo[id][Faze]);
    INI_WriteFloat(File, "LocX", WeedInfo[id][LocX]);
    INI_WriteFloat(File, "LocY", WeedInfo[id][LocY]);
    INI_WriteFloat(File, "LocZ", WeedInfo[id][LocZ]);
    INI_Close(File);
    return 1;
}



Re: y_ini file saving - matje - 02.10.2018

Bump.