Se for a gm que estou pensando fica assim...
PHP код:
dcmd_comprarcasa(playerid,params[])
{
#pragma unused params
new timestamp = GetTickCount();
if(timestamp - inhousepickup[playerid] > 5000)
{
SendClientMessage(playerid, Vermelho, "| ERRO | Vocк nгo estб em uma casa.");
return 1;
}
new str[128],pname[24];
GetPlayerName(playerid, pname, 24);
format(STRX, sizeof(STRX), "Casas/Usuarios/%s", pname);
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), PASTA_CONTAS, pname);
new grana;
grana = dini_Int(file, "SaldoBancario");
dini_IntSet(file, "TemCasa", 0);
if(dini_Exists(STRX))
{
if (dini_Int(STRX, "Houseid")!=-255) return SendClientMessage(playerid, Vermelho, "| ERRO | Vocк jб tem uma casa.");
}
format(STRX, sizeof(STRX), "Casas/Casaid%d", playericonhouse[playerid]);
if (strcmp(hInfo[playericonhouse[playerid]][aName],"Ninguem",true)) return SendClientMessage(playerid, Vermelho, "| ERRO | Esta casa jб tem dono.");
if(grana > hInfo[playericonhouse[playerid]][Cost]){
format(str,sizeof(str),"| INFO | Vocк comprou a casa nъmero [%d] localizada em %s.", hInfo[playericonhouse[playerid]][Casaid],zone);
SendClientMessage(playerid,0x1E90FFAA,str);
print(str);
dini_IntSet(STRX, "TemDono", 1);
new ano,mes,dia;
new string[266];
getdate(ano, mes, dia);
format(string, sizeof(string), " (%d/%d/%d)", dia,mes,ano);
dini_Set(STRX, "Login", string);
format(hInfo[playericonhouse[playerid]][Login],255, string);
dini_IntSet(file, "SaldoBancario", dini_Int(file, "SaldoBancario")-hInfo[playericonhouse[playerid]][Cost]);
PlayerInfo[playerid][pTcasa] = 1;
dini_Set(STRX, "Name", pname);
hInfo[playericonhouse[playerid]][aName]=pname;
hInfo[playericonhouse[playerid]][Locked] = 0;
new Float:sy, Float:sx, Float:sz;
GetPlayerPos(playerid, sx,sy,sz);
dini_FloatSet(STRX, "SpawnX", sx);
dini_FloatSet(STRX, "SpawnY", sy);
dini_FloatSet(STRX, "SpawnZ", sz);
new nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, nome, sizeof(nome));
format(STRX, sizeof(STRX), "Casas/Usuarios/%s", nome);
if (!dini_Exists(STRX)) dini_Create(STRX);
dini_IntSet(STRX, "Houseid", playericonhouse[playerid]);
if(!dini_Isset(STRX,"Rentid"))
{
dini_IntSet(STRX, "Rentid", -255);
}
GetPlayerPos(playerid, sx,sy,sz);
dini_FloatSet(STRX, "SpawnX", sx);
dini_FloatSet(STRX, "SpawnY", sy);
dini_FloatSet(STRX, "SpawnZ", sz);
dini_IntSet(STRX, "SpawnInt", GetPlayerInterior(playerid));
dini_IntSet(STRX, "Luz", 0);
dini_IntSet(STRX, "Agua", 0);
DestroyPickup(HousePickup[playericonhouse[playerid]]);
GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
HousePickup[playericonhouse[playerid]] = CreatePickup(1272, 23, hInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony], hInfo[playericonhouse[playerid]][iconz]);
format(STRX, sizeof(STRX), "| CASAS | O(A) jogador(a) %s comprou a casa id [%d] localizada em %s ",pname,hInfo[playericonhouse[playerid]][Casaid], zone);
LogCasas(STRX);
SendClientMessageToAll(Branco,STRX);
foreach(Player, i)
{
RemovePlayerMapIcon(i, housemapicon[playerid]);
housemapicon[playerid] = SetPlayerMapIcon(i,32,hInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony], hInfo[playericonhouse[playerid]][iconz],32,0xE3955CFF);
}
} else {
SendClientMessage(playerid, 0xE3955CFF,"| ERRO | Vocк nгo tem esse dinheiro em seu banco.");
}
return 1;
}
dcmd_vendercasa(playerid,params[])
{
#pragma unused params
new timestamp = GetTickCount();
if(timestamp - inhousepickup[playerid] > 5000)
{
return 1;
}
new pname[24];
GetPlayerName(playerid, pname, 24);
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), PASTA_CONTAS, pname);
format(pf, sizeof(pf), "Casas/Casaid%d", playericonhouse[playerid]);
format(gStr, sizeof(gStr), "Casas/Usuarios/%s", hInfo[playericonhouse[playerid]][aName]);
if (strcmp(hInfo[playericonhouse[playerid]][aName],pname,false)) return SendClientMessage(playerid, 0xFF0000AA, "| ERRO | Vocк nгo й dono dessa casa.");
dini_Remove(gStr);
new string[128];
format(string,sizeof(string),"| CASAS | Vocк vendeu a casa nъmero '%d'.", hInfo[playericonhouse[playerid]][Casaid]);
SendClientMessage(playerid,0x1E90FFAA,string);
dini_IntSet(file, "TemCasa", 0);
dini_IntSet(file, "SaldoBancario", dini_Int(file, "SaldoBancario")+hInfo[playericonhouse[playerid]][Sell]);
dini_Set(pf, "Name", "Ninguem");
dini_Set(pf, "Renter", "Ninguem");
dini_Set(pf, "Des", "Nada");
dini_Set(pf, "Login", "(00/00/0000)");
dini_IntSet(pf, "TemDono", 0);
dini_IntSet(pf, "alarme", 0);
dini_IntSet(pf, "liberado", 0);
dini_IntSet(pf, "Carrof", 0);
PlayerInfo[playerid][pTcasa] = 0;
hInfo[playericonhouse[playerid]][Locked] = 0;
format(hInfo[playericonhouse[playerid]][aName],255,"Ninguem");
format(hInfo[playericonhouse[playerid]][Renter],255,"Ninguem");
format(hInfo[playericonhouse[playerid]][Des],255,"Nada");
format(hInfo[playericonhouse[playerid]][Login],255,"(0/0/0000)");
new nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, nome, sizeof(nome));
format(pf, sizeof(pf), "Casas/Usuarios/%s", nome);
dini_IntSet(pf, "Houseid", -255);
DestroyPickup(HousePickup[playericonhouse[playerid]]);
GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
HousePickup[playericonhouse[playerid]] = CreatePickup(1273, 23, hInfo[playericonhouse[playerid]][iconx], hInfo[playericonhouse[playerid]][icony], hInfo[playericonhouse[playerid]][iconz]);
format(pf, sizeof(pf), "| CASAS | O(A) jogador(a) %s vendeu a sua casa id [%d] localizada em %s",pname ,hInfo[playericonhouse[playerid]][Casaid],zone);
LogCasas(pf);
SendClientMessageToAll(0xFFFFFFAA,pf);
foreach(Player, i)
{
RemovePlayerMapIcon(i, housemapicon[i]);
housemapicon[playerid] = SetPlayerMapIcon(i,32,hInfo[playericonhouse[i]][iconx], hInfo[playericonhouse[i]][icony], hInfo[playericonhouse[i]][iconz],31,0xFF0000AA);
}
return 1;
}