28.07.2015, 15:50
Hello guys i have a problem at house system.
i made asellhouse,sellhouse,and they are working,they load/save corectly,now i tried to make /buyhouse .it works until restart,when i restart...and then open the server again,the house is for sale again.
cmd:
Thanks for help.
i made asellhouse,sellhouse,and they are working,they load/save corectly,now i tried to make /buyhouse .it works until restart,when i restart...and then open the server again,the house is for sale again.
cmd:
PHP код:
YCMD:buyhouse(playerid, params[], help)
{
new string[128];
if(PlayerData[playerid][HKey] != -1) return SendClientMessage(playerid, COLOR_WHITE,"{FFFFCC}Error: Detii deja o casa.");
for(new h = 1; h <= houses; h++)
{
if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) && HouseInfo[h][hOwned] == 0)
{
if(PlayerData[playerid][Level] < HouseInfo[h][hLevel]) return SendClientMessage(playerid, COLOR_WHITE,"{FFFFCC}Error: Ai nivel prea mic.");
if(PlayerData[playerid][Cash] < HouseInfo[h][hValue]) return SendClientMessage(playerid, COLOR_WHITE,"{FFFFCC}Error: Nu ai destui bani.");
PlayerData[playerid][HKey] = h;
HouseInfo[h][hOwned] = 1;
strmid(HouseInfo[h][hOwner], PlayerData[playerid][Name], 0, strlen(PlayerData[playerid][Name]), 255);
GivePlayerCash(playerid,-HouseInfo[h][hValue]);
SendClientMessage(playerid, COLOR_WHITE,"{FFFFCC}Felicitari,ai achizitionat o casa!");
SetPlayerPos(playerid, HouseInfo[h][hExitx], HouseInfo[h][hExity], HouseInfo[h][hExitz]);
mysql_format(SQL, string, 128,"UPDATE `users` SET `HouseKey`='%d' WHERE `ID`='%d' LIMIT 1",h,PlayerData[playerid][ID]);
mysql_tquery(SQL, string, "", "");
mysql_format(SQL, string, sizeof(string), "UPDATE houses SET Owner='%s' WHERE id='%d'", HouseInfo[h][hOwner], h);
mysql_tquery(SQL, string, "", "");
mysql_format(SQL, string, sizeof(string), "UPDATE houses SET Owned='1' Rent='0' , Rentabil='1' , WHERE id='%d'", h);
mysql_tquery(SQL, string, "", "");
OnPropTextdrawUpdate(1, h);
return 1;
}
}
return 1;
}

