18.10.2016, 11:54
Hello guys, so when I finished making a house system, I noticed that after creating a house id, the ID stays the same even when I create another house, so the results are, only one house can be saved, which is the last created house, and all other ones get deleted,
here are some part of the script,
the saving stock
the /createhouse command (I think the problem is here)
if I'm not mistaken, the orange highlighted part are not functioning as they should,
do you guys have any ideas how to solve this?
here are some part of the script,
the saving stock
PHP код:
#define MAX_HOUSES 100
new HCount;
PHousePath(houseid){
new str[45];
format(str, sizeof(str), PHOUSE_PATH, houseid);
return str;
}
PHP код:
CMD:createhouse(playerid, params[]){
if(IsPlayerAdmin(playerid)){
new Float:p[3], price, houseid, hinterior, str[250];
//new HouseCount = houseid;
if(sscanf(params, "ii", price, hinterior)) return SendClientMessage(playerid, BLREN, "[USAGE]: {FFFFFF}/createhouse <price> <interior>") && SendClientMessage(playerid, BLREN, "[FUNCTION]: {FFFFFF}Create a house with setting up its price") && SendClientMessage(playerid, BLREN, "[HINT]: {FFFFFF}Use /houseint to preview available house interiors");
if(hinterior < 0 || hinterior > 6) return SendClientMessage(playerid, RED, "[ERROR]: {FFFFFF}invalide interior id, use {FFFF00}/houseint {FFFFFF}to see available interiors");
switch(hinterior){
case 0:{//Ryder's house
HouseInfo[houseid][hExitX] = 2454.717041;
HouseInfo[houseid][hExitY] = -1700.871582;
HouseInfo[houseid][hExitZ] = 1013.515197;
HouseInfo[houseid][hInsideVir] = 3;
}
case 1:{//Sweet's house
HouseInfo[houseid][hExitX] = 2527.654052;
HouseInfo[houseid][hExitY] = -1679.388305;
HouseInfo[houseid][hExitZ] = 1015.498596;
HouseInfo[houseid][hInsideVir] = 1;
}
case 2:{//CJ's house
HouseInfo[houseid][hExitX] = 2496.049804;
HouseInfo[houseid][hExitY] = -1695.238159;
HouseInfo[houseid][hExitZ] = 1014.742187;
HouseInfo[houseid][hInsideVir] = 3;
}
case 3:{//Modern house
HouseInfo[houseid][hExitX] = 2324.419921;
HouseInfo[houseid][hExitY] = -1145.568359;
HouseInfo[houseid][hExitZ] = 1050.710083;
HouseInfo[houseid][hInsideVir] = 12;
}
case 4:{//Og loc's house
HouseInfo[houseid][hExitX] = 513.882507;
HouseInfo[houseid][hExitY] = -11.269994;
HouseInfo[houseid][hExitZ] = 1001.565307;
HouseInfo[houseid][hInsideVir] = 3;
}
case 5:{//Mad dogg
HouseInfo[houseid][hExitX] = 1267.663208;
HouseInfo[houseid][hExitY] = -781.323242;
HouseInfo[houseid][hExitZ] = 1091.906250;
HouseInfo[houseid][hInsideVir] = 5;
}
}
[COLOR="darkorange"]HCount = houseid;[/COLOR]
GetPlayerPos(playerid, p[0], p[1], p[2]);
CreatePickup(1273, 1, p[0], p[1], p[2], 0);
HouseInfo[houseid][hPrice] = price;
format(str, sizeof(str), "{FFFFFF}{FF00FF}/buyhouse\n{FFFFFF}Owner: {FFFF00}None\n{FFFFFF}Price: {FFFF00}%i\n{FFFFFF}Press {008080}N {FFFFFF}to enter", HouseInfo[houseid][hPrice]);
Create3DTextLabel(str, 0xFFFFFF, p[0], p[1], p[2], 10.0, 0, 0);
HouseInfo[houseid][hEnterX] = p[0];
HouseInfo[houseid][hEnterY] = p[1];
HouseInfo[houseid][hEnterZ] = p[2];
HouseInfo[houseid][hOutsideVir] = GetPlayerInterior(playerid);
new INI:File = INI_Open(PHousePath(houseid));
INI_SetTag(File, "HousePos");
INI_WriteFloat(File, "hEnterX", HouseInfo[houseid][hEnterX]);
INI_WriteFloat(File, "hEnterY", HouseInfo[houseid][hEnterY]);
INI_WriteFloat(File, "hEnterZ", HouseInfo[houseid][hEnterZ]);
INI_WriteFloat(File, "hExitX", HouseInfo[houseid][hExitX]);
INI_WriteFloat(File, "hExitY", HouseInfo[houseid][hExitY]);
INI_WriteFloat(File, "hExitZ", HouseInfo[houseid][hExitZ]);
INI_WriteInt(File, "hInsideInt", 0);
INI_SetTag(File, "HouseInfo");
INI_WriteInt(File, "hOwned", 0);
INI_WriteString(File, "hOwner", "N/A");
INI_WriteString(File, "hTitle", "N/A");
INI_WriteInt(File, "hPrice", HouseInfo[houseid][hPrice]);
INI_WriteInt(File, "hInsideVir", HouseInfo[houseid][hInsideVir]);
INI_WriteInt(File, "hOutsideVir", HouseInfo[houseid][hOutsideVir]);
INI_Close(File);
[COLOR="DarkOrange"]HCount++;[/COLOR]
return 1;
}
else{
ErrorMessage(playerid, 6);
}
return 1;
}
do you guys have any ideas how to solve this?