Another function error
#1

Error:
pawn Код:
D:\Lucru\1.3 samp 0.3e\gamemodes\inaintedetaxi2.pwn(56166) : warning 225: unreachable code
Line:
pawn Код:
56166:  if(strcmp(cmd, "/contract", true) == 0)
Reply
#2

Dude, the error is self explanatory. Simply check whats above it, see if it's unreachable *for example, placing a return 0; above the command wouldn't allow it to process, considering that stops it from continuing.

Should work.
Reply
#3

Well we can't really help when you only give this line.

This error simply means that the code at this line is unreachable, which means it can never be reached during execution so it's useless code.

Therefore the problem is not with this line.
Reply
#4

pawn Код:
if(strcmp(cmd, "/contract", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /contract [playerid/PartOfName] [amount]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /contract [playerid/PartOfName] [amount]");
                return 1;
            }
            moneys = strval(tmp);
            if(moneys < 1000 || moneys > 1000000) { SendClientMessage(playerid, COLOR_GREY, "   Contract money must be atleast $1000, and not more then $1000000!"); return 1; }
            if(PlayerInfo[playerid][pLevel] < 2)
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You must be level 2 to place a Contract.");
                return 1;
            }
            if (IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    if(PlayerInfo[giveplayerid][pMember] == 8 && PlayerInfo[playerid][pMember] == 8)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* Cannot place Contracts on your own Agency!");
                        return 1;
                    }
                    else if(PlayerInfo[giveplayerid][pLeader] == 8 && PlayerInfo[playerid][pMember] == 8)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* Cannot place Contracts on your own Agency!");
                        return 1;
                    }
                    else if(PlayerInfo[giveplayerid][pMember] == 8||PlayerInfo[giveplayerid][pLeader] == 8)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* Can't contract a Hitman !");
                        return 1;
                    }
                    if(PlayerInfo[playerid][pAdmin] == 1)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* You may not place a contract on admin/testers on duty");
                        return 1;
                    }
                    if(IsACop(giveplayerid) && moneys < 30000)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* Only $30000 or above can be placed as a Contract on Cops !");
                        return 1;
                    }
                    if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "* You cannot Contract yourself!"); return 1; }
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    playermoney = GetPlayerMoney(playerid);
                    if (moneys > 0 && playermoney >= moneys)
                    {
                        SafeGivePlayerMoney(playerid, (0 - moneys));
                        PlayerInfo[giveplayerid][pHeadValue]+=moneys;
                        format(string, sizeof(string), "%s has placed a contract on %s, for $%d.",sendername, giveplayer, moneys);
                        SendFamilyMessage(8, COLOR_YELLOW, string);
                        format(string, sizeof(string), "* You placed a contract on %s, for $%d.",giveplayer, moneys);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        format(string, sizeof(string), "[INFO]: %s (%d) has placed a contract on %s (%d) for $%d", sendername, playerid, giveplayer,giveplayerid, moneys);
                        SendAdminMessage(COLOR_YELLOW,string);
                        SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "* Someone has placed a hit contract on you, you might want protection!");
                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   Invalid transaction amount.");
                    }
                }
            }
            else
            {
                format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_GRAD1, string);
            }
        }
        return 1;
    }
    SendClientMessage(playerid,COLOR_GREY, "SERVER: You have Typed An Unknown Command, Type /help or /atalk if you need Help!");
    return 1;
}
This is the continuation, and is continuing with
pawn Код:
//------------------------------------------------------------------------------------------------------
public HouseLevel(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new h = PlayerInfo[playerid][pPhousekey];
        if(h == 999) { return 0; }
        if(h <= 4) { return 1; }
        if(h >= 5 && h <= 9)  { return 2; }
        if(h >= 10 && h <= 18) { return 3; }
        if(h >= 19 && h <= 22) { return 4; }
        if(h >= 23 && h <= 25) { return 5; }
        if(h == 26) { return 6; }
        if(h == 27) { return 7; }
        if(h >= 28 && h <= 31) { return 7; }
    }
    return 0;
}
Reply
#5

Well that still doesn't tell us anything. The error is that the first line in your snippet is unreachable because the preceding code does not have a path where that line will ever be reached.

Therefore we need to see the code before it gets to the line that cannot be reached in order to find out what's making the line unreachable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)