01.09.2011, 13:34
PHP код:
if(strcmp(cmd, "/buybusiness", true) == 0 || strcmp(cmd, "/buybiz", true) == 0)
{
for(new i = 0; i <MAX_HOUSES; i++)
{
if (PlayerToPoint(3.0, playerid, BusinessInfo[i][bEntrancex], BusinessInfo[i][bEntrancey], BusinessInfo[i][bEntrancez]))
{
if(PlayerInfo[playerid][pLevel] < BusinessInfo[i][bLevel])
{
format(string, sizeof(string), "You must be level %d to buy this business.", BusinessInfo[i][bLevel]);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
if(PlayerInfo[playerid][pBusinessKey] != INVALID_BUSINESS_ID)
{
SendClientMessage(playerid, COLOR_RED, "You are already owning a business, sell that first.");
return 1;
}
if(BusinessInfo[i][bOwned] == 1)
{
SendClientMessage(playerid, COLOR_RED, "This business you are trying to buy is already owned.");
return 1;
}
if(GetPlayerMoney(playerid) < BusinessInfo[i][bPrice])
{
format(string, sizeof(string), "You need %d$ dollars in cash to buy this business.", BusinessInfo[i][bPrice]);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
else
{
SetPlayerPos(playerid, BusinessInfo[i][bExitx], BusinessInfo[i][bExity], BusinessInfo[i][bExitz]);
SetPlayerInterior(playerid, BusinessInfo[i][bInt]);
SetPlayerVirtualWorld(playerid, BusinessInfo[i][bWorld]);
GivePlayerMoney(playerid, -BusinessInfo[i][bPrice]);
BusinessInfo[i][bOwned] = 1;
strmid(BusinessInfo[i][bOwner], PlayerName[playerid], false, strlen(PlayerName[playerid]), 25);
PlayerInfo[playerid][pBusinessKey] = i;
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "You have successfully bought this business for %d$.", BusinessInfo[i][bPrice]);
SendClientMessage(playerid, COLOR_YELLOW, string);
new bizzname[32];
strmid(bizzname, BusinessInfo[i][bDescription], 3, strlen(BusinessInfo[i][bDescription]), 32);
format(string, sizeof(string), "%s has bought business %s.", PlayerName[playerid], BusinessInfo[i][bDescription]);
SendClientMessageToAll(COLOR_YELLOW, string);
OnBusinessUpdate();
return 1;
}
}
}
return 1;
}