03.09.2012, 13:00
Well since yesterday evening i've had a issue with my gmx function, everytime i used the gmx command it would delete all my current houses/businesses/organisations/factions everything. Now today i tried starting my script and it won't even load up the .cfg files of the houses etc. Could anyone help me with this? (NOTE: It used to work and i didn't change a thing to the gmx function) Here's an example:
This is what's placed under OnGameModeInit()
And under OnGameModeExit()
This is what's placed under OnGameModeInit()
pawn Код:
LoadHouses();
pawn Код:
SaveHouses();
pawn Код:
stock LoadHouses()
{
new binfo[21][32];
new string[256];
new File:file = fopen("houses.cfg", io_read);
if(file)
{
new idx = 1;
while(idx < MAX_HOUSES)
{
fread(file, string);
split(string, binfo, '|');
HouseInfo[idx][hLevel] = strval(binfo[0]);
HouseInfo[idx][hPrice] = strval(binfo[1]);
HouseInfo[idx][hStatus] = strval(binfo[2]);
format(HouseInfo[idx][hOwner], 32, "%s", binfo[3]);
HouseInfo[idx][hX] = floatstr(binfo[4]);
HouseInfo[idx][hY] = floatstr(binfo[5]);
HouseInfo[idx][hZ] = floatstr(binfo[6]);
HouseInfo[idx][hMoney] = strval(binfo[7]);
HouseInfo[idx][hMaterials] = strval(binfo[8]);
HouseInfo[idx][hWeed] = strval(binfo[9]);
HouseInfo[idx][hCrack] = strval(binfo[10]);
HouseInfo[idx][hGun][0] = strval(binfo[11]);
HouseInfo[idx][hGunAmmo][0] = strval(binfo[12]);
HouseInfo[idx][hGun][1] = strval(binfo[13]);
HouseInfo[idx][hGunAmmo][1] = strval(binfo[14]);
HouseInfo[idx][hGun][2] = strval(binfo[15]);
HouseInfo[idx][hGunAmmo][2] = strval(binfo[16]);
HouseInfo[idx][hGun][3] = strval(binfo[17]);
HouseInfo[idx][hGunAmmo][3] = strval(binfo[18]);
HouseInfo[idx][hGun][4] = strval(binfo[19]);
HouseInfo[idx][hGunAmmo][4] = strval(binfo[20]);
if(HouseInfo[idx][hLevel])
{
HouseInfo[idx][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
if(!strcmp("The State", HouseInfo[idx][hOwner])) format(string, sizeof(string), "[Property]\nID: {FFFFFF}%d\n{33AA33}House {FFFFFF}(Size: %d)\n{33AA33}Status: {FFFFFF}For Sale\n{33AA33}Price: {FFFFFF}$%d", idx, HouseInfo[idx][hLevel], HouseInfo[idx][hPrice]);
else format(string, sizeof(string), "[Property]\nID: {FFFFFF}%d\n{33AA33}House {FFFFFF}(Size: %d)\n{33AA33}Status: {FFFFFF}%s", idx, HouseInfo[idx][hLevel], RHS(idx));
HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_GREEN, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3, 5);
}
idx++;
}
}
print("Houses loaded successfully.");
return 1;
}
pawn Код:
stock SaveHouses()
{
new idx = 1, File:file;
new string[256];
while(idx < MAX_HOUSES)
{
format(string, sizeof(string), "%d|%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",
HouseInfo[idx][hLevel],
HouseInfo[idx][hPrice],
HouseInfo[idx][hStatus],
HouseInfo[idx][hOwner],
HouseInfo[idx][hX],
HouseInfo[idx][hY],
HouseInfo[idx][hZ],
HouseInfo[idx][hMoney],
HouseInfo[idx][hMaterials],
HouseInfo[idx][hWeed],
HouseInfo[idx][hCrack],
HouseInfo[idx][hGun][0],
HouseInfo[idx][hGunAmmo][0],
HouseInfo[idx][hGun][1],
HouseInfo[idx][hGunAmmo][1],
HouseInfo[idx][hGun][2],
HouseInfo[idx][hGunAmmo][2],
HouseInfo[idx][hGun][3],
HouseInfo[idx][hGunAmmo][3],
HouseInfo[idx][hGun][4],
HouseInfo[idx][hGunAmmo][4]
);
if(idx == 1)
{
file = fopen("houses.cfg", io_write);
}
else
{
file = fopen("houses.cfg", io_append);
}
fwrite(file, string);
fclose(file);
idx++;
}
print("Houses saved successfully.");
}
pawn Код:
CMD:ggmx(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 7) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
new string[128];
format(string, sizeof(string), "AdmCmd: %s %s has issued an instant server restart.", RPALN(playerid), RPN(playerid));
SendClientMessageToAll(0xff000000, string);
SetTimer("gmxtimer", 5000, false);
return 1;
}
forward gmxtimer();
public gmxtimer()
{
foreach(Player, i)
{
SaveChar(i);
ClearChar(i);
GMX[i] = 1;
}
SendRconCommand("gmx");
}