1 error: Undefined symbol "idx"
#1

This is the coding

PHP код:
CMD:buybiz(playeridparams[])
{
    new 
string[128], done;
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    {
        for(new 
idx=1idx<MAX_BIZidx++)
         if(
IsPlayerInRangeOfPoint(playerid2BizInfo[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(playeridCOLOR_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(stringsizeof(string), ""COE"["CWE"%d, %s"COE"]\n"COE"Owner"CWE" %s\n"COE"Status"CWE" %s"idxRBT(idx), BizInfo[idx][bOwner], RBS(idx));
                
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITEstring);
                
SendClientMessage(playeridCOLOR_GREEN" You have successfully bought a business.");
                
SendClientMessage(playeridCOLOR_WHITE" Type /bizhelp to view your business commands.");
                
format(stringsizeof(string), "%s has bought business id %d."RPN(playerid), idx);
                
Log("logs/business.log"string);
                
idx MAX_BIZ;
                
done 1;
            }
            if(
idx == MAX_BIZ-&& !done)
            {
                
SendClientMessage(playeridCOLOR_GREY"This business is owned by someone else.");
            }
        }
        if(
idx == MAX_BIZ-&& !done)
        {
            
SendClientMessage(playeridCOLOR_GREY"You are not near a buyable business.");
        }
    }
    return 
1;

Reply
#2

What line?
Reply
#3

somewhere here apparently:

PHP код:
   if(idx == MAX_BIZ-&& !done)
            {
                
SendClientMessage(playeridCOLOR_GREY"This business is owned by someone else.");
            }
        }
        if(
idx == MAX_BIZ-&& !done)
        {
            
SendClientMessage(playeridCOLOR_GREY"You are not near a buyable business.");
        }
    } 
Reply
#4

Replace with this
pawn Код:
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;
}
Reply
#5

Try:
pawn Код:
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;
}
Reply
#6

Quote:
Originally Posted by KesaSport
Посмотреть сообщение
Try:
pawn Код:
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;
}
Did you just copy my post lol?
Reply
#7

Quote:
Originally Posted by Wizza
Посмотреть сообщение
Did you just copy my post lol?
Check again lol
Reply
#8

This code should work, give it a quick try and respond with the results if possible.
pawn Код:
CMD:buybiz(playerid, params[])
{
    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) == 0)
            {
                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));
                new string[128];
                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);
                break;
            }
            if(idx == (MAX_BIZ - 1)) return SendClientMessage(playerid, COLOR_GREY, "This business is owned by someone else.");
        }
        if(idx == (MAX_BIZ - 1)) return SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable business.");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)