25.12.2012, 21:47
Hello,
I am developing a house system for rp server. In my enum, one of my variables is hOwned which is set to 1 if someone buys house. The thing is that this variable doesn't save like the Player variables. I have a timer which should save it every 10 seconds but it does not.
Appreciate any help. Thanks
I am developing a house system for rp server. In my enum, one of my variables is hOwned which is set to 1 if someone buys house. The thing is that this variable doesn't save like the Player variables. I have a timer which should save it every 10 seconds but it does not.
Код:
#define MAX_HOUSES 10 new Text3D:housetextsell[MAX_HOUSES]; new Text3D:housetextlock[MAX_HOUSES]; forward LoadHouse_data(houseid,name[],value[]); enum hInfo { Float:hEnterx, Float:hEntery, Float:hEnterz, Float:hExitx, Float:hExity, Float:hExitz, hOwned, hInterior, hPrice, hLocked } new Float:HouseInfo[MAX_HOUSES][hInfo]; forward houseinfo();
Код:
public OnGamemodeInit() { SetTimer("savestats",10000,1); // saving player and house stats each minute } for(new i=0;i<MAX_HOUSES;i++) { INI_ParseFile(HousePath(i), "LoadHouse_%s", .bExtra = true, .extra = i); if(IsValidHouse(i)) { if(HouseInfo[i][hOwned]==0) { new housepricetext[50]; format(housepricetext,sizeof(housepricetext),"Nehnutelnosќ - Na predaj. Cena: %i",HouseInfo[i][hPrice]); housetextsell[i]=Create3DTextLabel(housepricetext,COLOR_YELLOW,HouseInfo[i][hEnterx],HouseInfo[i][hEntery],HouseInfo[i][hEnterz],10,0,1); } else housetextsell[i]=Create3DTextLabel("Nehnutelnosќ - Predanб",COLOR_YELLOW,HouseInfo[i][hEnterx],HouseInfo[i][hEntery],HouseInfo[i][hEnterz],10,0,1); if(HouseInfo[i][hLocked]==0) housetextlock[i]=Create3DTextLabel("Odomknutй",COLOR_RED,HouseInfo[i][hEnterx],HouseInfo[i][hEntery],HouseInfo[i][hEnterz]-0.1,10,0,1); else housetextlock[i]=Create3DTextLabel("Zamknutй",COLOR_RED,HouseInfo[i][hEnterx],HouseInfo[i][hEntery],HouseInfo[i][hEnterz]-0.1,10,0,1); } } return 1;
Код:
stock IsValidHouse(houseid) { if(fexist(HousePath(houseid))) return 1; else return 0; }
Код:
public savestats() { for(new i=0;i<MAX_PLAYERS;i++) { if(IsPlayerConnected(i)) { new INI:File = INI_Open(UserPath(i)); INI_SetTag(File,"Player Info Save"); INI_WriteInt(File,"House",PlayerInfo[i][pHouse]); INI_WriteInt(File,"Cash",PlayerInfo[i][pCash]); INI_Close(File); return 1; } } for(new i=0;i<MAX_HOUSES;i++) { if(IsValidHouse(i)) { new INI:File = INI_Open(HousePath(i)); INI_WriteInt(File,"Owned",HouseInfo[i][hOwned]); INI_WriteInt(File,"Locked",HouseInfo[i][hLocked]); INI_Close(File); } } return 1; }