pawn Код:
dcmd_comprarcasa(playerid, params[])
{
#pragma unused params
new Float:oldposx, Float:oldposy, Float:oldposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new h = 0; h < MAX_HOUSES; h++)
{
if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) && HouseInfo[h][hOwned] == 0)
{
if(Player[playerid][pLevel] < HouseInfo[h][hLevel])
{
format(thestring, sizeof(thestring), " Vocк precisa de Nнvel %d para comprar essa Casa.", HouseInfo[h][hLevel]);
SendClientMessage(playerid, COLOR_GREY, thestring);
return 1;
}
if(Player[playerid][pPhousekey] != 255 && strcmp(Player[playerid][pName], hOwner[Player[playerid][pPhousekey]], false) == 0)
return SendClientMessage(playerid, COLOR_RED, "[ERRO] Vocк jб й o dono desta casa, digite /vendercasa para vender e comprar outra.");
if(GetPlayerGP(playerid) > HouseInfo[h][hValue])
{
new dia,mes,ano,hora;
getdate(ano,mes,dia);
gettime(hora);
Player[playerid][pPhousekey] = h;
Player[playerid][pPaluguelkey] = 255;
Incasa[playerid] = Player[playerid][pPhousekey];
HouseInfo[h][hOwned] = 1;
Player[playerid][pLocalSpawn] = 1;
strmid(hOwner[h], Player[playerid][pName], 0, strlen(Player[playerid][pName]), 255);
GivePlayerGP(playerid,-HouseInfo[h][hValue]);
PlayerPlayMusic(playerid);
SetPlayerInterior(playerid,HouseInfo[h][hInt]);
SetPlayerVirtualWorld(playerid,HouseInfo[h][hWorld]);
SafeSetPlayerPos(playerid,HouseInfo[h][hExitx],HouseInfo[h][hExity],HouseInfo[h][hExitz]);
GameTextForPlayer(playerid, "~w~bem vindo~n~voce pode sair qualquer hora ~n~por essa porta digite /sair", 5000, 3);
Player[playerid][pInt] = HouseInfo[h][hInt];
Player[playerid][pLocal] = h;
format(thestring, sizeof(thestring), "%s comprou a casa %d por R$%d",Player[playerid][pName], h,HouseInfo[h][hValue]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, thestring);
WriteLog("houses", thestring);
SendClientMessage(playerid, COLOR_WHITE, "Digita /ajuda e veja a sessгo de ajuda de casas.");
DateProp(playerid);
//SaveProperty(h);
CCasa[playerid] = false;
OnPropUpdate();
OnPlayerSave(playerid);
return 1;
}
else
return SendClientMessage(playerid, COLOR_RED, "[ERRO] Vocк nгo tem dinheiro para esse produto.");
}
}
return 1;
}