Код:
if(strcmp(cmd, "/comprarcasa", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new h = 0; h < sizeof(HouseInfo); h++)
{
if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) && HouseInfo[h][hOwned] == 0)
{
if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel])
{
format(string, sizeof(string), " Necesitas Nivel: %d, Para Comprar La Casa.", HouseInfo[h][hLevel]);
SendClientMessage(playerid, COLOR_GRAD5, string);
return 1;
}
if(PlayerInfo[playerid][pPhousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwner], true) == 0)
{
SendClientMessage(playerid, COLOR_WHITE, " Ya Tienes Una Casa, Escribe: /VenderCasa, En Caso De Que Desee Venderla!");
return 1;
}
if(HouseInfo[h][hOwned] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "Esta casa ya tiene dueсo!");
return 1;
}
if(GetPlayerMoney(playerid) > HouseInfo[h][hValue])
{
PlayerInfo[playerid][pPhousekey] = h;
HouseInfo[h][hOwned] = 1;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
SafeGivePlayerMoney(playerid,-HouseInfo[h][hValue]);
SBizzInfo[14][sbTill] += HouseInfo[h][hValue];
SBizzInfo[14][sbProducts] -= 100;
PlayerPlayMusic(playerid);
SetPlayerInterior(playerid,HouseInfo[h][hInt]);
SetPlayerVirtualWorld(playerid,HouseInfo[h][hWorld]);
SetPlayerPos(playerid,HouseInfo[h][hExitx],HouseInfo[h][hExity],HouseInfo[h][hExitz]);
GameTextForPlayer(playerid, "~w~Bienvenido~n~Por Favor, Acerquese a La Puerta y Esciba: /Salir", 5000, 3);
PlayerInfo[playerid][pInt] = HouseInfo[h][hInt];
PlayerInfo[playerid][pLocal] = h;
SendClientMessage(playerid, COLOR_WHITE, "Vendedora: Gracias Por La Compra!!");
SendClientMessage(playerid, COLOR_WHITE, "Puedes Escribir: /Ayuda!");
DateProp(playerid);
OnPropUpdate();
PlayerUpdate(playerid);
format(string, sizeof(string), "ESET-NOD32: %s compra casa por %d (%d)", sendername, HouseInfo[h][hValue],h);
ESETPropertyLog(string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "No Tienes Tanto Dinero Como Para Realizar La Compra.!");
return 1;
}
}
}
}
return 1;
}