Unreachable Code
#1

This Whole Command looks fucked up to me but i get a error.. if anything else wrong with it please fix it would be quite helpful

ERRORS:
Код:
C:\Documents and Settings\Adrian\My Documents\Samp Servers\EXRP\gamemodes\EXRPu16.pwn(35417) : warning 225: unreachable code
C:\Documents and Settings\Adrian\My Documents\Samp Servers\EXRP\gamemodes\EXRPu16.pwn(35417) : error 029: invalid expression, assumed zero
CODE:
pawn Код:
CMD:setentrancefee(playerid, params[])
{
    new string28[128], string2[128], bizid;
    for(new biz = 0; biz < MAX_BIZ; biz++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, BizInfo[biz][IXCoord], BizInfo[biz][IYCoord], BizInfo[biz][IZCoord]))
        {
            if(GetPlayerVirtualWorld(playerid) == BizInfo[biz][VW])
            {
                if(!strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true))
                {
                    if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /setentrancefee [fee]");
                    if(params[0] < 0 || params[0] > 50)
                    {
                        SendClientMessageEx(playerid, COLOR_GRAD1, "Entrance Fee can not be below 0 or above 50!");
                        return 1;
                    }
                    BizInfo[PlayerInfo[playerid][pBizKey]][EntranceFee] = params[0];
                    SaveBizInfo(PlayerInfo[playerid][pBizKey]);
                    format(string2,sizeof(string2),"You have changed your Business Entrance Fee to %d", params);
                    SendClientMessageEx(playerid, COLOR_GRAD3, string2);
                    Delete3DTextLabel(Text3D:BizLabel[bizid]);
                    format(string28,sizeof(string28),"%s\nOwner: %s\nType: %s\nEntrance Fee: %d\nID: %d", BizInfo[bizid][Name], BizInfo[bizid][Owner],GetBizType(bizid), BizInfo[bizid][EntranceFee], bizid);
                    BizLabel[bizid] = Create3DTextLabel(string28, COLOR_BIZ, BizInfo[bizid][XCoord], BizInfo[bizid][YCoord], BizInfo[bizid][ZCoord], 10, 0, 0);
                    return 1;
                    else // Unreachable Code error
                    {
                        SendClientMessageEx(playerid, COLOR_GRAD2, "You are not in your business.");
                    }
                }
            }
        }
    }
    return 1;
}
Reply
#2

There was a "return 1;" above the else statement.
pawn Код:
CMD:setentrancefee(playerid, params[])
{
    new string28[128], string2[128], bizid;
    for(new biz = 0; biz < MAX_BIZ; biz++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, BizInfo[biz][IXCoord], BizInfo[biz][IYCoord], BizInfo[biz][IZCoord]))
        {
            if(GetPlayerVirtualWorld(playerid) == BizInfo[biz][VW])
            {
                if(!strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true))
                {
                    if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /setentrancefee [fee]");
                    if(params[0] < 0 || params[0] > 50)
                    {
                        SendClientMessageEx(playerid, COLOR_GRAD1, "Entrance Fee can not be below 0 or above 50!");
                        return 1;
                    }
                    BizInfo[PlayerInfo[playerid][pBizKey]][EntranceFee] = params[0];
                    SaveBizInfo(PlayerInfo[playerid][pBizKey]);
                    format(string2,sizeof(string2),"You have changed your Business Entrance Fee to %d", params);
                    SendClientMessageEx(playerid, COLOR_GRAD3, string2);
                    Delete3DTextLabel(Text3D:BizLabel[bizid]);
                    format(string28,sizeof(string28),"%s\nOwner: %s\nType: %s\nEntrance Fee: %d\nID: %d", BizInfo[bizid][Name], BizInfo[bizid][Owner],GetBizType(bizid), BizInfo[bizid][EntranceFee], bizid);
                    BizLabel[bizid] = Create3DTextLabel(string28, COLOR_BIZ, BizInfo[bizid][XCoord], BizInfo[bizid][YCoord], BizInfo[bizid][ZCoord], 10, 0, 0);
                }
                else // Unreachable Code error
                {
                    SendClientMessageEx(playerid, COLOR_GRAD2, "You are not in your business.");
                }
            }
        }
    }
    return 1;
}
Reply
#3

Works but its not updating the 3d Text Label - Please help..

pawn Код:
CMD:setentrancefee(playerid, params[])
{
    new string28[128], string2[128], bizid;
    for(new biz = 0; biz < MAX_BIZ; biz++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, BizInfo[biz][IXCoord], BizInfo[biz][IYCoord], BizInfo[biz][IZCoord]))
        {
            if(GetPlayerVirtualWorld(playerid) == BizInfo[biz][VW])
            {
                if(!strcmp(BizInfo[biz][Owner], GetPlayerNameEx(playerid), true))
                {
                    if(sscanf(params, "i", params[0])) return SendClientMessageEx(playerid, COLOR_GRAD3, "USAGE: /setentrancefee [fee]");
                    if(params[0] < 0 || params[0] > 50)
                    {
                        SendClientMessageEx(playerid, COLOR_GRAD1, "Entrance Fee can not be below 0 or above 50!");
                        return 1;
                    }
                    BizInfo[PlayerInfo[playerid][pBizKey]][EntranceFee] = params[0];
                    SaveBizInfo(PlayerInfo[playerid][pBizKey]);
                    format(string2,sizeof(string2),"You have changed your Business Entrance Fee to %d", params);
                    SendClientMessageEx(playerid, COLOR_GRAD3, string2);
                    Delete3DTextLabel(Text3D:BizLabel[bizid]);
                    format(string28,sizeof(string28),"%s\nOwner: %s\nType: %s\nEntrance Fee: %d\nID: %d", BizInfo[bizid][Name], BizInfo[bizid][Owner],GetBizType(bizid), BizInfo[bizid][EntranceFee], bizid);
                    BizLabel[bizid] = Create3DTextLabel(string28, COLOR_BIZ, BizInfo[bizid][XCoord], BizInfo[bizid][YCoord], BizInfo[bizid][ZCoord], 10, 0, 0);
                }
                else
                {
                    SendClientMessageEx(playerid, COLOR_GRAD2, "You are not in your business.");
                }
            }
        }
    }
    return 1;
}
Reply
#4

Use Update3DTextLabelText instead of delete/create combo.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)