02.12.2013, 19:54
This is the coding
PHP код:
CMD:buybiz(playerid, params[])
{
new string[128], done;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
{
for(new idx=1; idx<MAX_BIZ; idx++)
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
{
if(!strcmp("The State", BizInfo[idx][bOwner], false))
{
if(PlayerInfo[playerid][pMoney] < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
GiveZaiatMoney(playerid, -BizInfo[idx][bPrice]);
if(PlayerInfo[playerid][pBiz]) PlayerInfo[playerid][pVBiz] = idx;
else PlayerInfo[playerid][pBiz] = idx;
format(BizInfo[idx][bOwner], 32, "%s", RPNU(playerid));
format(string, sizeof(string), ""COE"["CWE"%d, %s"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a business.");
SendClientMessage(playerid, COLOR_WHITE, " Type /bizhelp to view your business commands.");
format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
Log("logs/business.log", string);
idx = MAX_BIZ;
done = 1;
}
if(idx == MAX_BIZ-1 && !done)
{
SendClientMessage(playerid, COLOR_GREY, "This business is owned by someone else.");
}
}
if(idx == MAX_BIZ-1 && !done)
{
SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable business.");
}
}
return 1;
}