/buyh it's work with the original houses but not work with the houses i added
Код:
CMD:buyh(playerid,params[])
{
if(PlayerInfo[playerid][LoggedIn] == 0) {
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to use this command");
return 1;
}
new str[255],str1[255],pname[24], housenumber;
housenumber = GetHouseID(playerid);
if(housenumber == -1) return SendClientMessage(playerid, c_r, "You are not in a house icon!");
GetPlayerName(playerid, pname, 24);
format(str1, sizeof(str1), "ladmin/users/%s.sav", udb_encode(pname));
if(dini_Exists(str1))
{
if (dini_Int(str1, "Houseid")!=-255) return SendClientMessage(playerid, c_r, "You can only buy one house!");
}
format(str1, sizeof(str1), "SATDM/Houses/houseid%d", housenumber);
if (strcmp(hInfo[housenumber][Name],DEFAULT_OWNER,true)) return SendClientMessage(playerid, c_r, "This house isn't for sale!");
if(GetPlayerMoney(playerid)<hInfo[housenumber][Cost]) return SendClientMessage(playerid, c_r, "Not enough money!");
new hsstring[128];
format(hsstring, sizeof(hsstring), "You just bought this House (ID:%i) for $%d.", housenumber, hInfo[housenumber][Cost]);
SendClientMessage(playerid, COLOR_GREEN, hsstring);
// SendClientMessage(playerid, c_y, "You have bought the house!");
format(str, sizeof(str), "%s has bought houseid %i",pname,housenumber);
print(str);
GivePlayerMoney(playerid, -hInfo[housenumber][Cost]);
dini_Set(str1, "Name", pname);
hInfo[housenumber][Name]=pname;
hInfo[housenumber][Locked] = dini_IntSet(str1,"Locked",0);
format(str1, sizeof(str1), "ladmin/users/%s.sav", udb_encode(pname));
if (!dini_Exists(str1)) dini_Create(str1);
new Float:sy, Float:sx, Float:sz;
dini_IntSet(str1, "Houseid", housenumber);
if(!dini_Isset(str1,"Rentid"))
{
dini_IntSet(str1, "Rentid", -255);
}
GetPlayerPos(playerid, sx,sy,sz);
dini_FloatSet(str1, "SpawnX", sx);
dini_FloatSet(str1, "SpawnY", sy);
dini_FloatSet(str1, "SpawnZ", sz);
dini_IntSet(str1, "SpawnInt", GetPlayerInterior(playerid));
DestroyDynamicPickup(HousePickup[housenumber]);
HousePickup[housenumber] = CreateDynamicPickup(1272, 23, hInfo[housenumber][iconx], hInfo[housenumber][icony], hInfo[housenumber][iconz]);
new hnowner[30];
format(hnowner,128,"{FFFFFF}%s",hInfo[housenumber][Name]);
if(strcmp(hInfo[housenumber][Name],DEFAULT_OWNER,false) == 0) {
format(hnowner,128,"Not Owned");
}
UpdateDynamic3DTextLabelText(hTextInfo[housenumber],0xFF0000FF,hnowner);
DestroyDynamicMapIcon(housemapicon[housenumber]);
housemapicon[housenumber] = CreateDynamicMapIcon(hInfo[housenumber][iconx], hInfo[housenumber][icony], hInfo[housenumber][iconz],32,c_y);
return 1;
}