How to load multiple files using Y_Ini? - 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: How to load multiple files using Y_Ini? (
/showthread.php?tid=362700)
How to load multiple files using Y_Ini? -
Riddick94 - 25.07.2012
As topic says.. using Parsing file method.
pawn Код:
stock SaveObjects()
{
for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
{
new INI:Objects = INI_Open(ObjectFile(i));
INI_WriteFloat (Objects, "oX", ObjectInfo[i][oX]);
INI_WriteFloat (Objects, "oY", ObjectInfo[i][oY]);
INI_WriteFloat (Objects, "oZ", ObjectInfo[i][oZ]);
INI_WriteFloat (Objects, "rX", ObjectInfo[i][oRX]);
INI_WriteFloat (Objects, "rY", ObjectInfo[i][oRY]);
INI_WriteFloat (Objects, "rZ", ObjectInfo[i][oRZ]);
INI_Close(Objects);
break;
}
return true;
}
stock LoadObjects()
{
for(new i = 1; i < MAX_CREATED_OBJECTS; i++)
{
INI_ParseFile(ObjectFile(i), "LoadCreatedObjects", .bExtra = true, .extra = i);
CreateObjectEx(ObjectInfo[i][oModelID], ObjectInfo[i][oX], ObjectInfo[i][oY], ObjectInfo[i][oZ]);
ObjectInfo[i][oDescriptionLabel] = Create3DTextLabel(ObjectInfo[i][oDescription], COLOR_NICK, ObjectInfo[i][oX], ObjectInfo[i][oY], ObjectInfo[i][oZ], 100.0, 0);
}
return true;
}
forward LoadCreatedObjects(playerid, name[], value[]);
public LoadCreatedObjects(playerid, name[], value[])
{
for(new i = 1; i < MAX_CREATED_OBJECTS; i++)
{
if(!strcmp(name, "ModelID")) ObjectInfo[i][oModelID] = strval(value);
if(!strcmp(name, "oX")) ObjectInfo[i][oX] = floatstr(value);
if(!strcmp(name, "oY")) ObjectInfo[i][oY] = floatstr(value);
if(!strcmp(name, "oZ")) ObjectInfo[i][oZ] = floatstr(value);
if(!strcmp(name, "rX")) ObjectInfo[i][oRX] = floatstr(value);
if(!strcmp(name, "rY")) ObjectInfo[i][oRY] = floatstr(value);
if(!strcmp(name, "rZ")) ObjectInfo[i][oRZ] = floatstr(value);
ObjectInfo[i][oObjectID] = CreateObjectEx(ObjectInfo[i][oModelID], ObjectInfo[i][oX], ObjectInfo[i][oY], ObjectInfo[i][oZ]);
}
return true;
}
Re: How to load multiple files using Y_Ini? -
Riddick94 - 29.07.2012
Hello?! 10th page..
Re: How to load multiple files using Y_Ini? -
Finn - 29.07.2012
You had a break in the saving loop and you were trying to parse every objects' data from 1 object file.
I tried to fix it:
pawn Код:
stock SaveObjects()
{
for(new i = 0, INI:Objects; i < MAX_CREATED_OBJECTS; i++)
{
Objects = INI_Open(ObjectFile(i));
INI_WriteFloat (Objects, "oX", ObjectInfo[i][oX]);
INI_WriteFloat (Objects, "oY", ObjectInfo[i][oY]);
INI_WriteFloat (Objects, "oZ", ObjectInfo[i][oZ]);
INI_WriteFloat (Objects, "rX", ObjectInfo[i][oRX]);
INI_WriteFloat (Objects, "rY", ObjectInfo[i][oRY]);
INI_WriteFloat (Objects, "rZ", ObjectInfo[i][oRZ]);
INI_Close(Objects);
}
return true;
}
stock LoadObjects()
{
for(new i = 0; i < MAX_CREATED_OBJECTS; i++)
{
INI_ParseFile(ObjectFile(i), "LoadCreatedObjects", .bExtra = true, .extra = i);
ObjectInfo[i][oObjectID] = CreateObjectEx(ObjectInfo[i][oModelID], ObjectInfo[i][oX], ObjectInfo[i][oY], ObjectInfo[i][oZ]);
ObjectInfo[i][oDescriptionLabel] = Create3DTextLabel(ObjectInfo[i][oDescription], COLOR_NICK, ObjectInfo[i][oX], ObjectInfo[i][oY], ObjectInfo[i][oZ], 100.0, 0);
}
return true;
}
forward LoadCreatedObjects(i, name[], value[]);
public LoadCreatedObjects(i, name[], value[])
{
if(!strcmp(name, "ModelID")) ObjectInfo[i][oModelID] = strval(value);
if(!strcmp(name, "oX")) ObjectInfo[i][oX] = floatstr(value);
if(!strcmp(name, "oY")) ObjectInfo[i][oY] = floatstr(value);
if(!strcmp(name, "oZ")) ObjectInfo[i][oZ] = floatstr(value);
if(!strcmp(name, "rX")) ObjectInfo[i][oRX] = floatstr(value);
if(!strcmp(name, "rY")) ObjectInfo[i][oRY] = floatstr(value);
if(!strcmp(name, "rZ")) ObjectInfo[i][oRZ] = floatstr(value);
return true;
}