SA-MP Forums Archive
Warning - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Warning (/showthread.php?tid=197450)



Warning - marinov - 09.12.2010

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/exit", cmdtext, true, 10) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
            RemovePlayerFromVehicle(playerid);
            SCM(playerid,0xFFFF00AA,"* You left the vehicle.");
            TogglePlayerControllable(playerid,1);
            }else{
            SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
            }
        }
        return 1;
    }
    if(strcmp("/afill", cmdtext, true, 11) == 0)
    IsPlayerAdmin(playerid);
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
        new VID = GetPlayerVehicleID(playerid);
        if(Vgas[VID] < 100)
        {
            ShowMenuForPlayer(Gas,playerid);
            }else{
            SCM(playerid,0xFFFF00AA,"* Your vehicle is full!");
            }
                }else{
                SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
            }
    return 1;
    }
    if(strcmp("/fill", cmdtext, true, 10) == 0) // <-------------- this is the line
    {
        if(IsAtGasStation(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new VID = GetPlayerVehicleID(playerid);
                if(Vgas[VID] < 100)
                {
                ShowMenuForPlayer(Gas,playerid);
                }else{
                SCM(playerid,0xFFFF00AA,"* Your vehicle is full!");
                }
            }else{
            SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
            }
        }else{
        SCM(playerid,0xFFFF00AA,"* You are not at a gas station!");
        }
        return 1;
    }
    return 0;
}

pawn Код:
C:\Users\Marino Varesio\Desktop\zombie outbreak\filterscripts\fuelsystem.pwn(90) : warning 225: unreachable code
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.



Re: Warning - Lynn - 09.12.2010

So I could be 100% wrong,
But if it goes,
10, 11, should it not go, 12?
if(strcmp("/fill", cmdtext, true, 12) == 0)


Re: Warning - marinov - 09.12.2010

lol 100 % wrong xD didn't work


Re: Warning - willsuckformoney - 09.12.2010

pawn Код:
if(strcmp(cmdtext, "/fill", true) == 0)
That should work..


Re: Warning - Scenario - 09.12.2010

I could be wrong, but having good indentation skills are key to being a successful scripter.

Try this:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/exit", cmdtext, true)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                RemovePlayerFromVehicle(playerid);
                SCM(playerid,0xFFFF00AA,"* You left the vehicle.");
                TogglePlayerControllable(playerid,1);
            }
            else SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
        }
        return 1;
    }
    if(strcmp("/afill", cmdtext, true)
    {
        if(IsPlayerAdmin(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new VID = GetPlayerVehicleID(playerid);
                if(Vgas[VID] < 100) ShowMenuForPlayer(Gas,playerid);
                else SCM(playerid, 0xFFFF00AA, "* Your vehicle is full!");
            }
            else SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
        }
        return 1;
    }
    if(strcmp("/fill", cmdtext, true) // <-------------- this is the line
    {
        if(IsAtGasStation(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new VID = GetPlayerVehicleID(playerid);
                if(Vgas[VID] < 100) ShowMenuForPlayer(Gas,playerid);
                else SCM(playerid,0xFFFF00AA,"* Your vehicle is full!");
            }
            else SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
        }
        else SCM(playerid,0xFFFF00AA,"* You are not at a gas station!");
        return 1;
    }
    return 0;
}



Re: Warning - XePloiT - 09.12.2010

pawn Код:
if(!strcmp(cmdtext,"/fill", true, 10))
try this


Re: Warning - marinov - 09.12.2010

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
I could be wrong, but having good indentation skills are key to being a successful scripter.

Try this:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/exit", cmdtext, true)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                RemovePlayerFromVehicle(playerid);
                SCM(playerid,0xFFFF00AA,"* You left the vehicle.");
                TogglePlayerControllable(playerid,1);
            }
            else SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
        }
        return 1;
    }
    if(strcmp("/afill", cmdtext, true)
    {
        if(IsPlayerAdmin(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new VID = GetPlayerVehicleID(playerid);
                if(Vgas[VID] < 100) ShowMenuForPlayer(Gas,playerid);
                else SCM(playerid, 0xFFFF00AA, "* Your vehicle is full!");
            }
            else SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
        }
        return 1;
    }
    if(strcmp("/fill", cmdtext, true) // <-------------- this is the line
    {
        if(IsAtGasStation(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new VID = GetPlayerVehicleID(playerid);
                if(Vgas[VID] < 100) ShowMenuForPlayer(Gas,playerid);
                else SCM(playerid,0xFFFF00AA,"* Your vehicle is full!");
            }
            else SCM(playerid,0xFFFF00AA,"* You are not in a vehicle!");
        }
        else SCM(playerid,0xFFFF00AA,"* You are not at a gas station!");
        return 1;
    }
    return 0;
}

It fixed, thx


Re: Warning - Hal - 09.12.2010

Many people do not realize how important indentation is. I've talked to people who go about w/o indenting. I would find it confusing as hell. I OVER indent so i don't get confused


Re: Warning - Scenario - 09.12.2010

Quote:
Originally Posted by Hal
Посмотреть сообщение
Many people do not realize how important indentation is. I've talked to people who go about w/o indenting. I would find it confusing as hell. I OVER indent so i don't get confused
When you don't indent correctly it makes it very difficult to find missing brackets and always makes your code look like crap. People do this sort of thing:

pawn Код:
}
else
{
     print("Just An Example");
}
Which makes the code look unclean and unorganized. People could simply do this:

pawn Код:
}
else print("Just An Example");
I know most people do that, but why? The " ; " serves the same purpose as the last " } " in that case.