Need Help.
#1

Having some errors....

warning 215: expression has no effect

pawn Код:
CMD:buybiz(playerid, params[])
{
    new string[128], done;
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVBiz] && PlayerInfo[playerid][pDonator] >= 3) return SendClientMessage(playerid, COLOR_GREY, "You already own two businesses.");
    if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You already own a business.");
    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][pCash] < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
                PlayerInfo[playerid][pCash] -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), "%s\n\n{FFFFFF}%s\nOwner: %s\nID: %d", RBS(idx), RBT(idx), BizInfo[idx][bOwner], 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;
}
Line/code that causing the warning: PlayerInfo[playerid][pCash] -BizInfo[idx][bPrice];

The effect is .. no deduction on player money when he buys the biz
Reply
#2

Simple change

pawn Код:
PlayerInfo[playerid][pCash] -BizInfo[idx][bPrice];
to

pawn Код:
PlayerInfo[playerid][pCash]=-BizInfo[idx][bPrice];
Reply
#3

Thanks .. it worked...
Reply
#4

Quote:
Originally Posted by _Jake_
Посмотреть сообщение
Simple change

pawn Код:
PlayerInfo[playerid][pCash] -BizInfo[idx][bPrice];
to

pawn Код:
PlayerInfo[playerid][pCash]=-BizInfo[idx][bPrice];
Hmm... I have my concerns about this answer. I thought he was trying to do "deduct BizInfo[idx][bPrice] from PlayerInfo[playerid][pCash]". Your solution does this: "Set PlayerInfo[playerid][pCash] to be the opposite of BizInfo[idx][bPrice]".

-= deducts
=- makes it the opposite

(For those who didn't understand, let's say x = 5 and y = 7)
x -= y is the same as x = x-y and the answer is -2
x =- y is the same as x = -y and the answer is -7 (the opposite of y)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)