Unreachable Code - 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: Unreachable Code (
/showthread.php?tid=266281)
Unreachable Code -
EdeniaGaming - 04.07.2011
Код:
if(strcmp(cmd, "/travel", true) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 13.0, -4429.944824, 905.032470, 987.078186))
{
if(PlayerInfo[playerid][pDonateRank] > 0)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new x_nr[256];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /travel [location]");
SendClientMessage(playerid, COLOR_GRAD1, "Locations: LS");
return 1;
}
if(strcmp(x_nr,"ls",true) == 0)
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 1529.6,-1691.2,13.3);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
SendClientMessage(playerid, COLOR_YELLOW, "VIP: You have traveled to Los Santos with your vehicle.");
SetPlayerInterior(playerid,0);
PlayerInfo[playerid][pInt] = 0;
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pLocal] = 255;
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " You are not in a vehicle!");
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not a VIP!");
return 1;
}
}
return 1;
}
Unreachable Code ? happens right here if(strcmp(x_nr,"ls",true) == 0) any solution ?
Re: Unreachable Code -
Jochemd - 04.07.2011
Are you really sure? Your code seems fine... Try to remove the return before the line of the warning, maybe it's fixed.
Btw, I've optimized your code.
pawn Код:
if(strcmp(cmd, "/travel", true) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 13.0, -4429.944824, 905.032470, 987.078186))
{
if(PlayerInfo[playerid][pDonateRank] > 0)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new x_nr[120];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /travel [location]");
SendClientMessage(playerid, COLOR_GRAD1, "Locations: LS");
return 1;
}
if(strcmp(x_nr,"ls",true) == 0)
{
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, 1529.6,-1691.2,13.3);
TelePos[playerid][0] = 0.0;
TelePos[playerid][1] = 0.0;
SendClientMessage(playerid, COLOR_YELLOW, "VIP: You have traveled to Los Santos with your vehicle.");
SetPlayerInterior(playerid,0);
PlayerInfo[playerid][pInt] = 0;
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pLocal] = 255;
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " You are not in a vehicle!");
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not a VIP!");
return 1;
}
}
return 1;
}
Never use [256] again in suck cases. Max input = 128, but since it's everything after the command, no more than 120 is necessary.