Error gets spammed
#4

pawn Код:
CMD:buybizz(playerid, params[])
{
    if(pInfo[playerid][OwnedBizz] == 1)
        return SendClientMessage(playerid,COLOR_PINK2,"Error: You already own a business");

    new bizzid = 0;
    for(new a; a < MAX_BUSINESSES; a++)
    {
           if(!IsPlayerInRangeOfPoint(playerid, 10.0, bInfo[a][Position][0], bInfo[a][Position][1], bInfo[a][Position][2]))
                 continue;

           bizzid = a;
    }

    if(!bizzid)
        return SendClientMessage(playerid, COLOR_PINK2, "Error: you are not near any property.");
       
       
    if(pInfo[playerid][pMoney] < bInfo[bizzid][Price])
        return SendClientMessage(playerid, COLOR_PINK2, "Error: you don't have money.");

    if(strcmp(bInfo[bizzid][bOwner], "Nobody", true))
        return SendClientMessage(playerid, COLOR_PINK2, "Error: this already belongs to someone"); //note that there could be a player named nobody!!

    new query[128],query2[128];
    format(bInfo[bizzid][bOwner], MAX_PLAYER_NAME, "%s", GetName(playerid));
    pInfo[playerid][pMoney] -= bInfo[bizzid][Price];
    pInfo[playerid][pBizz] = bInfo[bizzid][ID];
    pInfo[playerid][OwnedBizz] = 1;
   
    format(query,sizeof(query),"UPDATE businesses SET `owner` = '%s' WHERE `id` =%d",bInfo[bizzid][bOwner],bInfo[bizzid][ID]);
    mysql_query(query);
    format(query2,sizeof(query2),"UPDATE `accounts` SET `BusinessID` =%i,`OwnedBizz` = %i WHERE `id` =%d LIMIT 1", pInfo[playerid][pBizz],pInfo[playerid][OwnedBizz], pInfo[playerid][ID]);
    mysql_query(query2);
   
    print(query2);
    print(query);
   
    new string2[144];
    format(string2, sizeof(string2), "%s\nOwner: %s\nPrice: %i\n ID: %i\nEntry Fee: %i",bInfo[bizzid][bName],bInfo[bizzid][bOwner], bInfo[bizzid][Price],bInfo[bizzid][ID],bInfo[bizzid][bEntryFee]);
    Update3DTextLabelText(bInfo[bizzid][LabelID], 0xB0D5E8FF, string2);
   
    SendClientMessage(playerid,0x9EC7DEFF,"Congratulations!, You have successfully bought the business");
    return 1;
}
Try that; I highly believe 10.0 is too high for a range checking on this kind of things, if there are two bizzes within that range it will only take the one with the latter memory id.
Reply


Messages In This Thread
Error gets spammed - by ZBits - 01.02.2014, 13:07
Re: Error gets spammed - by CuervO - 01.02.2014, 13:12
Re: Error gets spammed - by ZBits - 01.02.2014, 13:25
Re: Error gets spammed - by CuervO - 01.02.2014, 13:29
Re: Error gets spammed - by ZBits - 01.02.2014, 23:38
Re: Error gets spammed - by CuervO - 02.02.2014, 00:22
Re: Error gets spammed - by ZBits - 02.02.2014, 00:25
Re: Error gets spammed - by ZBits - 02.02.2014, 00:31
Re: Error gets spammed - by CuervO - 02.02.2014, 00:32
Re: Error gets spammed - by ZBits - 02.02.2014, 00:35

Forum Jump:


Users browsing this thread: 1 Guest(s)