07.03.2015, 16:29
Hello, i have problem with house system.
Im created 30 houses, and buyed one house, and im sell this house. buyed new house, and when exit from house, server port me to last buyed house (first house what buyed).
here is my function for house system.
(i will pasto only function for save exit cordinates)
savehouses function:
command createhouse:
command sellhouse:
GetAvailableID function
Thanks.
Im created 30 houses, and buyed one house, and im sell this house. buyed new house, and when exit from house, server port me to last buyed house (first house what buyed).
here is my function for house system.
(i will pasto only function for save exit cordinates)
savehouses function:
Код:
stock SaveHouses() { for(new i=1;i < MAX_HOUSES;i++) { if(HouseTaken[i] == 0) continue; new hFile[35]; format(hFile, 35, HOUSE_PATH, i); new INI:File = INI_Open(hFile); INI_SetTag(File, "House Data"); INI_WriteFloat(File, "ExitX", HouseInfo[i][ExitX]); INI_WriteFloat(File, "ExitY", HouseInfo[i][ExitY]); INI_WriteFloat(File, "ExitZ", HouseInfo[i][ExitZ]); INI_WriteFloat(File, "ExitA", HouseInfo[i][ExitA]); INI_Close(File); } }
Код:
CMD:createhouse(playerid, params[]) { new type[128], string[256]; new id = GetAvailableID(); if(sscanf(params, "s[128]",type)) { SendClientMessage(playerid, COLOR_RED, "/createhouse"); return 1; } if(!strcmp(type, "1", true, 2)) { HouseInfo[id][EnterX] = 2308.8; HouseInfo[id][EnterY] = -1212.8; HouseInfo[id][EnterZ] = 1049.0; HouseInfo[id][EnterInt] = 6; HouseInfo[id][Price] = 9000; HouseInfo[id][Level] = 3; } GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); HouseInfo[id][ExitX] = Pos[0]; HouseInfo[id][ExitY] = Pos[1]; HouseInfo[id][ExitZ] = Pos[2]; SaveHouses(); return 1; }
command sellhouse:
Код:
CMD:sellhouse(playerid, params[]) { { new id = PlayerInfo[playerid][pHouseID]; HouseInfo[id][Owned] = 0; HouseInfo[id][Locked] = 0; PlayerInfo[playerid][pHouseKey] = 0; PlayerInfo[playerid][pHouseID] = 0; } return 1; }
Код:
stock GetAvailableID() { for(new i = 1; i<MAX_HOUSES; i++) { if(HouseTaken[i] == 0) return i; } return -1; }