25.07.2012, 11:03
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;
}