PDA

View Full Version : warning 225: unreachable code


Torran
11/03/2010, 04:35 PM
CMD:makeadmin(playerid, params[])
{
new targetid;
new adminlevel;

if (PlayerInfo[playerid][AdminLevel] < 5) return SendClientMessage(playerid, COLOR_RED, "Error ~ You are not an administrator with the required level");
if (sscanf(params, "ud", targetid, adminlevel)) return SendClientMessage(playerid, COLOR_RED, "Usage ~ /makeadmin [PlayerID/PartOfName] [AdminLevel]");
if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player not Connected");
if (adminlevel == PlayerInfo[targetid][AdminLevel]) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player is already this Level");
else {
}
return 1;
}


C:\Users\Torran\Desktop\tRoleplay\filterscripts\ta dmin.pwn(193) : warning 225: unreachable code
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.


Line:
return 1;

Anyone know?

westre
11/03/2010, 04:40 PM
else {
return 1;
}

or just delete the whole else statement if you're not going to use it.

Torran
11/03/2010, 04:44 PM
Im going to use it i just always leave the else empty until i edit later,
Anyway i fixed it!
It just needed a code in between the brackets..

CMD:makeadmin(playerid, params[])
{
new targetid;
new adminlevel;

if (PlayerInfo[playerid][AdminLevel] < 5) return SendClientMessage(playerid, COLOR_RED, "Error ~ You are not an administrator with the required level");
if (sscanf(params, "ud", targetid, adminlevel)) return SendClientMessage(playerid, COLOR_RED, "Usage ~ /makeadmin [PlayerID/PartOfName] [AdminLevel]");
if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player not Connected");
if (adminlevel == PlayerInfo[targetid][AdminLevel]) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player is already this Level");
else {
print("Makeadmin command");
}
return 1;
}

kLx
11/03/2010, 04:46 PM
if you use return on the other checks, you don't need to use else {
just delete it, and write the code.

SORRY DID'NT NOTICED U FIXED IT.

FireScript
07/01/2012, 12:06 AM
Use:

CMD:makeadmin(playerid, params[])
{
new targetid;
new adminlevel;
if (PlayerInfo[playerid][AdminLevel] < 5) return SendClientMessage(playerid, COLOR_RED, "Error ~ You are not an administrator with the required level");
if (sscanf(params, "ud", targetid, adminlevel)) return SendClientMessage(playerid, COLOR_RED, "Usage ~ /makeadmin [PlayerID/PartOfName] [AdminLevel]");
if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player not Connected");
if (adminlevel == PlayerInfo[targetid][AdminLevel]) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player is already this Level");
else
{
print("Makeadmin command");
return 1;
}
}

I am Brazilian, Reputation if I helped ^ ^

Snowman12
28/01/2012, 03:53 AM
CMD:makeadmin(playerid, params[])
{
new targetid;
new adminlevel;
if (PlayerInfo[playerid][AdminLevel] < 5) return SendClientMessage(playerid, COLOR_RED, "Error ~ You are not an administrator with the required level");
if (sscanf(params, "ud", targetid, adminlevel)) return SendClientMessage(playerid, COLOR_RED, "Usage ~ /makeadmin [PlayerID/PartOfName] [AdminLevel]");
if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player not Connected");
if (adminlevel == PlayerInfo[targetid][AdminLevel]) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player is already this Level");
else
{
print("Makeadmin command");
return 1; // Would clearly fail.
}
//return 1 here or BAM SERVER: Unknown command.
}

2KY
28/01/2012, 04:16 AM
Use:

CMD:makeadmin(playerid, params[])
{
new targetid;
new adminlevel;
if (PlayerInfo[playerid][AdminLevel] < 5) return SendClientMessage(playerid, COLOR_RED, "Error ~ You are not an administrator with the required level");
if (sscanf(params, "ud", targetid, adminlevel)) return SendClientMessage(playerid, COLOR_RED, "Usage ~ /makeadmin [PlayerID/PartOfName] [AdminLevel]");
if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player not Connected");
if (adminlevel == PlayerInfo[targetid][AdminLevel]) return SendClientMessage(playerid, COLOR_RED, "Error ~ Player is already this Level");
else
{
print("Makeadmin command");
return 1;
}
}

I am Brazilian, Reputation if I helped ^ ^

You bumped a two year old thread. HOW?!