SendClientMessage spam in loop
#2

pawn Code:
CMD:buybiz(playerid, params[])
{
    new string[128];
    new id = IsPlayerNearBusiness(playerid);
    if(id == -1 || id == 0) return SendClientMessage(playerid, COLOR_RED, "You aren't near in any business");
    if(BusinessInfo[id][bPrice] < GetPlayerMoney(playerid))
    {
        if(BusinessInfo[id][bOwned] == 0)
        {
            BusinessInfo[id][bOwned] = 1;
            BusinessInfo[id][bOwner] = PlayerName(playerid);
            BusinessInfo[id][bLocked] = 0;
            BusinessInfo[id][bMoney] = 0;
            GivePlayerMoney(playerid, -BusinessInfo[id][bPrice]);
        }
        else
        {
            format(string,sizeof(string),"This business is already owned by: %s",BusinessInfo[id][bOwner]);
            SendClientMessage(playerid, COLOR_RED, string);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You don't have enough money");
    }
    return 1;
}
There is no need for a loop since you already know the id of the business you are near to. Just check the price and the owner for that particular business and that's it.
Reply


Messages In This Thread
SendClientMessage spam in loop - by nezo2001 - 07.02.2015, 09:17
Re: SendClientMessage spam in loop - by HazardouS - 07.02.2015, 09:24

Forum Jump:


Users browsing this thread: 1 Guest(s)