warning 225: unreachable code
#1

hello help me with warning 225: unreachable code i edit LuxAdmin /goto script but i got warning

Код:
LuxAdmin.pwn(4727) : warning 225: unreachable code
pawn Код:
dcmd_goto(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
    {
        if(!strlen(params)) return
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
        SendClientMessage(playerid, orange, "Function: Will Go to specified player");
        new player1;
        new string[128];
        if(!IsNumeric(params))
        player1 = ReturnPlayerID(params);
        else player1 = strval(params);
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)
        if(NotAllowedGoto[player1] == 1) return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");
         {
            SendCommandToAdmins(playerid,"Goto");
            new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
            SetPlayerInterior(playerid,GetPlayerInterior(player1));
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
            if(GetPlayerState(playerid) == 2)
            {
            SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
            SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
            }
            else SetPlayerPos(playerid,x+2,y,z);
            format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
            return SendClientMessage(playerid,BlueMsg,string);
        }
       return ErrorMessages(playerid, 4);//line 4727
    }
    else return ErrorMessages(playerid, 1);
}
Reply
#2

Try it Might work not sure tho

Код:
dcmd_goto(playerid,params[])
{
	if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
 	{
        if(!strlen(params)) return
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
        SendClientMessage(playerid, orange, "Function: Will Go to specified player");
        new player1;
        new string[128];
        if(!IsNumeric(params))
        player1 = ReturnPlayerID(params);
        else player1 = strval(params);
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)
        if(NotAllowedGoto[player1] == 1) return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");
        {
            SendCommandToAdmins(playerid,"Goto");
            new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
            SetPlayerInterior(playerid,GetPlayerInterior(player1));
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
            if(GetPlayerState(playerid) == 2)
            {
            SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
            SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
            }
            else SetPlayerPos(playerid,x+2,y,z);
            format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
            return SendClientMessage(playerid,BlueMsg,string);
        }
        return ErrorMessages(playerid, 4);//line 4727
    }
    else return ErrorMessages(playerid, 1);
}
Reply
#3

Quote:
Originally Posted by OpticKiller
Посмотреть сообщение
Try it Might work not sure tho

Код:
dcmd_goto(playerid,params[])
{
	if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
 	{
        if(!strlen(params)) return
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
        SendClientMessage(playerid, orange, "Function: Will Go to specified player");
        new player1;
        new string[128];
        if(!IsNumeric(params))
        player1 = ReturnPlayerID(params);
        else player1 = strval(params);
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)
        if(NotAllowedGoto[player1] == 1) return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");
        {
            SendCommandToAdmins(playerid,"Goto");
            new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
            SetPlayerInterior(playerid,GetPlayerInterior(player1));
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
            if(GetPlayerState(playerid) == 2)
            {
            SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
            SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
            }
            else SetPlayerPos(playerid,x+2,y,z);
            format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
            return SendClientMessage(playerid,BlueMsg,string);
        }
        return ErrorMessages(playerid, 4);//line 4727
    }
    else return ErrorMessages(playerid, 1);
}
...
nothing changed
Reply
#4

indent your code and you shall see your issue:
pawn Код:
dcmd_goto(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
    {
        if(!strlen(params))
            return;
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
        SendClientMessage(playerid, orange, "Function: Will Go to specified player");
       
        new player1;
        new string[128];

        if(!IsNumeric(params))
            player1 = ReturnPlayerID(params);
        else
            player1 = strval(params);

        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)
            if(NotAllowedGoto[player1] == 1)
                return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");
       
        {//you are creating an additional scope, this will always be entered
            SendCommandToAdmins(playerid,"Goto");
            new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
            SetPlayerInterior(playerid,GetPlayerInterior(player1));
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
            if(GetPlayerState(playerid) == 2)
            {
                SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
                LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
                SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
            }
            else
                SetPlayerPos(playerid,x+2,y,z);
            format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
            //this will always be run:
            return SendClientMessage(playerid,BlueMsg,string);
        }
        //so this will never get executed:
        return ErrorMessages(playerid, 4);//line 4727
    }
    //but this will:
    else
        return ErrorMessages(playerid, 1);
}
what you in fact have scripted, is this:
pawn Код:
dcmd_goto(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
    {
        if(!strlen(params))
        {
            return;
        }

        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
        SendClientMessage(playerid, orange, "Function: Will Go to specified player");
       
        new player1;
        new string[128];

        if(!IsNumeric(params))
        {
            player1 = ReturnPlayerID(params);
        }
        else
        {
            player1 = strval(params);
        }

        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)
        {
            if(NotAllowedGoto[player1] == 1)
            {
                return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");
            }
        }
       
        SendCommandToAdmins(playerid,"Goto");
        new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
        SetPlayerInterior(playerid,GetPlayerInterior(player1));
        SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
        if(GetPlayerState(playerid) == 2)
        {
            SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
            SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
        }
        else
        {
            SetPlayerPos(playerid,x+2,y,z);
        }
        format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
        //see? two returns:
        return SendClientMessage(playerid,BlueMsg,string);
        return ErrorMessages(playerid, 4);
    }
    else
    {
        return ErrorMessages(playerid, 1);
    }
}
I think you ment to do this:

pawn Код:
dcmd_goto(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
    {
        if(!strlen(params))
            return;

        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
        SendClientMessage(playerid, orange, "Function: Will Go to specified player");
       
        new player1;
        new string[128];

        if(!IsNumeric(params))
            player1 = ReturnPlayerID(params);
        else
            player1 = strval(params);

        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)
        {
            if(NotAllowedGoto[player1] == 1)
                return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");
            SendCommandToAdmins(playerid,"Goto");
            new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
            SetPlayerInterior(playerid,GetPlayerInterior(player1));
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
            if(GetPlayerState(playerid) == 2)
            {
                SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
                LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
                SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
            }
            else
            {
                SetPlayerPos(playerid,x+2,y,z);
            }
            format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
            return SendClientMessage(playerid,BlueMsg,string);
        }  
        return ErrorMessages(playerid, 4);
    }
    return ErrorMessages(playerid, 1);
}
but to avoid errors in the future, I would suggest you to change your coding style to this:

pawn Код:
dcmd_goto(playerid,params[])
{
    if(AccInfo[playerid][Level] < 2 && !IsPlayerAdmin(playerid))
        return ErrorMessages(playerid, 1);
    if(!strlen(params))
        return;

    SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
    SendClientMessage(playerid, orange, "Function: Will Go to specified player");
       
    new player1;
    new string[128];

    if(!IsNumeric(params))
        player1 = ReturnPlayerID(params);
    else
        player1 = strval(params);

    if(!IsPlayerConnected(player1) || player1 != INVALID_PLAYER_ID || player1 != playerid)
        return ErrorMessages(playerid, 4);
   
    if(NotAllowedGoto[player1] == 1)
        return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");
   
    SendCommandToAdmins(playerid,"Goto");
    new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
    SetPlayerInterior(playerid,GetPlayerInterior(player1));
    SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
    if(GetPlayerState(playerid) == 2)
    {
        SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
        LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
        SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
    }
    else
    {
        SetPlayerPos(playerid,x+2,y,z);
    }
    format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
    return SendClientMessage(playerid,BlueMsg,string);
}
in this code you can exactly tell when the code is going to stop,what is getting executed and avoids confusion like your coding.
Reply
#5

pawn Код:
dcmd_goto(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
    {
        if(!strlen(params)) return
            SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
                SendClientMessage(playerid, orange, "Function: Will Go to specified player");

        new player1;
        new string[128];

        if(!IsNumeric(params))
            player1 = ReturnPlayerID(params);
        else player1 = strval(params);

        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)

            if(NotAllowedGoto[player1] == 1) return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");

            //{ //Invalid brace
        SendCommandToAdmins(playerid,"Goto");
        new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
        SetPlayerInterior(playerid,GetPlayerInterior(player1));
        SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));

        if(GetPlayerState(playerid) == 2)
        {
            SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
            SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
        }
        else SetPlayerPos(playerid,x+2,y,z);

        format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
        return SendClientMessage(playerid,BlueMsg,string); //This is end
            //} //Invalid brace
        return ErrorMessages(playerid, 4);//line 4727 //After the end
    }
    else return ErrorMessages(playerid, 1);
}
Indenting your code properly showed where your problem is (near the end)


EDIT: Gamer_Z beat me to it.
Reply
#6

Quote:
Originally Posted by Joe Staff
Посмотреть сообщение
pawn Код:
dcmd_goto(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
    {
        if(!strlen(params)) return
            SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
                SendClientMessage(playerid, orange, "Function: Will Go to specified player");

        new player1;
        new string[128];

        if(!IsNumeric(params))
            player1 = ReturnPlayerID(params);
        else player1 = strval(params);

        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)

            if(NotAllowedGoto[player1] == 1) return SendClientMessage(playerid, red, "ERROR: This player is not allowing players to teleport to them");

            //{ //Invalid brace
        SendCommandToAdmins(playerid,"Goto");
        new Float:x, Float:y, Float:z;  GetPlayerPos(player1,x,y,z);
        SetPlayerInterior(playerid,GetPlayerInterior(player1));
        SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));

        if(GetPlayerState(playerid) == 2)
        {
            SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
            SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
        }
        else SetPlayerPos(playerid,x+2,y,z);

        format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
        return SendClientMessage(playerid,BlueMsg,string); //This is end
            //} //Invalid brace
        return ErrorMessages(playerid, 4);//line 4727 //After the end
    }
    else return ErrorMessages(playerid, 1);
}
Indenting your code properly showed where your problem is (near the end)


EDIT: Gamer_Z beat me to it.
Those breaces are not really incorrect (from programming perspective), this is totally valid programming, for example:

pawn Код:
dcmd_x(playerid,params[])
{
    new a = 0;
    {
        new b = 1;
        printf("%d%d",a,b);
        //b gets destroyed
    }
    {
        new b = 2;//no error, totally valid
        printf("%d%d",a,b);
    }
    //prints:
    //01
    //02
    printf("%d%d",a,b); //error, undefined symbol "b"
    return 0
}
Reply
#7

I knew when I chose that word you would say something.
Reply
#8

Quote:
Originally Posted by Joe Staff
Посмотреть сообщение
I knew when I chose that word you would say something.
/off:
haha you know me too good xD(?)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)