Это же уже реализовано с помощью массивов house_price, house_materials и house_drugs.
Правда, лучше это реализовать так:
PHP код:
enum {
SELL_HOUSE_CURRENCY_DOLLAR,
SELL_HOUSE_CURRENCY_MATERIAL,
SELL_HOUSE_CURRENCY_DRUGS,
}
new gSellHouseCurrency[MAX_PLAYERS char];
(ещё можно использовать теги, по желанию)
PHP код:
switch(currency)
{
case '$':
{
if(!(1 <= price <= cellmax))
return SendClientMessage(playerid, COLOR_GREY, !"Цена от $1.");
static const fmt_str[] = "Игрок %s предложил вам купить дом за $%s. Для покупки введите /accept house";
new string[sizeof(fmt_str) - 4 + MAX_PLAYER_NAME + 25];
format(string, sizeof string, fmt_str, pInfo[playerid][pName], money);
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
format(string, sizeof string,"Ты предложил купить дом игроку %s за $%s.",pInfo[giveplayerid][pName], money);
SendClientMessage(playerid,COLOR_YELLOW,string);
gSellHouseCurrency{playerid} = SELL_HOUSE_CURRENCY_DOLLAR;
}
case 'м', 'М', 'm', 'M':
{
if(!(100 <= price <= cellmax))
return SendClientMessage(playerid, COLOR_GREY, !"Цена от 100 материалов.");
static const fmt_str[] = "Игрок %s предложил вам купить дом за %s материалов. Для покупки введите /accept house";
new string[sizeof(fmt_str) - 4 + MAX_PLAYER_NAME + 25];
format(string, sizeof string, fmt_str, pInfo[playerid][pName], money);
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
format(string, sizeof string,"Ты предложил купить дом игроку %s за %s материалов.",pInfo[giveplayerid][pName], money);
SendClientMessage(playerid,COLOR_YELLOW,string);
gSellHouseCurrency{playerid} = SELL_HOUSE_CURRENCY_MATERIAL;
}
case 'd', 'D':
{
if(!(1 <= price <= cellmax))
return SendClientMessage(playerid, COLOR_GREY, !"Цена от 1 грамма наркотиков");
static const fmt_str[] = "Игрок %s предложил вам купить дом за %s грамм нарко. Для покупки введите /accept house";
new string[sizeof(fmt_str) - 4 + MAX_PLAYER_NAME + 25];
format(string, sizeof string, fmt_str, pInfo[playerid][pName], money);
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
format(string, sizeof string,"Ты предложил купить дом игроку %s за %s грамм нарко.",pInfo[giveplayerid][pName], money);
SendClientMessage(playerid,COLOR_YELLOW,string);
gSellHouseCurrency{playerid} = SELL_HOUSE_CURRENCY_DRUGS;
}
P.S. Я заменил 100000000000000 на cellmax.
PHP код:
if(strcmp(accept, "house", true) == 0)
{
if(GetPVarInt(playerid,"BUYHOME") == 999)
return SendClientMessage(playerid, COLOR_GREY, !"Вам не кто не предлогал купить дом.");
if(pInfo[playerid][pMoney] < GetPVarInt(playerid,"BUYCENA"))
return SendClientMessage(playerid, COLOR_GREY, !"У вас недостаточно средств.");
new sellpl = GetPVarInt(playerid,"BUYHOME");
pInfo[playerid][pHouse] = pInfo[sellpl][pHouse];
pInfo[sellpl][pHouse] = 0;
strmid(HouseInfo[pInfo[playerid][pHouse]][hOwner], pInfo[playerid][pName], 0, strlen(pInfo[playerid][pName]), 255);
UpdateHouse(pInfo[playerid][pHouse]);
if(gSellHouseCurrency{playerid} == SELL_HOUSE_CURRENCY_DOLLAR)
{
format(string,sizeof string, "Вы купили дом у игрока %s за %d$.",pInfo[sellpl][pName], GetPVarInt(playerid,"BUYCENA"));
SendClientMessage(playerid, COLOR_LBLUE, string);
format(string,sizeof string ,"Вы продали дом игроку %s за %d$.",pInfo[playerid][pName],GetPVarInt(playerid,"BUYCENA"));
SendClientMessage(sellpl, COLOR_LBLUE, string);
pInfo[playerid][pMoney] -= GetPVarInt(playerid, "BUYCENA");
pInfo[sellpl][pMoney] += GetPVarInt(playerid, "BUYCENA");
}
else if(gSellHouseCurrency{playerid} == SELL_HOUSE_CURRENCY_MATERIAL)
{
format(string,sizeof string, "Вы купили дом у игрока %s за %d материалов.",pInfo[sellpl][pName], GetPVarInt(playerid,"BUYCENA"));
SendClientMessage(playerid, COLOR_LBLUE, string);
format(string,sizeof string ,"Вы продали дом игроку %s за %d материалов.",pInfo[playerid][pName],GetPVarInt(playerid,"BUYCENA"));
SendClientMessage(sellpl, COLOR_LBLUE, string);
pInfo[playerid][pMats] -= GetPVarInt(playerid, "BUYCENA");
pInfo[sellpl][pMats] += GetPVarInt(playerid, "BUYCENA");
}
else if(gSellHouseCurrency{playerid} == SELL_HOUSE_CURRENCY_DRUGS)
{
format(string,sizeof string, "Вы купили дом у игрока %s за %d грамм нарко.",pInfo[sellpl][pName], GetPVarInt(playerid,"BUYCENA"));
SendClientMessage(playerid, COLOR_LBLUE, string);
format(string,sizeof string ,"Вы продали дом игроку %s за %d грамм нарко.",pInfo[playerid][pName],GetPVarInt(playerid,"BUYCENA"));
SendClientMessage(sellpl, COLOR_LBLUE, string);
pInfo[playerid][pDrugs] -= GetPVarInt(playerid, "BUYCENA");
pInfo[sellpl][pDrugs] += GetPVarInt(playerid, "BUYCENA");
}
SetPVarInt(playerid,"BUYHOME",999);
SetPVarInt(playerid,"BUYCENA",0);
}