warning 225: unreachable code
#1

pawn Код:
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\tadmin.pwn(193) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Line:
pawn Код:
return 1;
Anyone know?
Reply
#2

Код:
else {
return 1;
}
or just delete the whole else statement if you're not going to use it.
Reply
#3

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..

pawn Код:
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;
}
Reply
#4

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.
Reply
#5

Use:

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

I am Brazilian, Reputation if I helped ^ ^
Reply
#6

pawn Код:
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.
}
Reply
#7

Quote:
Originally Posted by FireScript
Посмотреть сообщение
Use:

PHP код:
CMD:makeadmin(playeridparams[])
{
    new 
targetid;
      new 
adminlevel;
      if (
PlayerInfo[playerid][AdminLevel] < 5) return SendClientMessage(playeridCOLOR_RED"Error ~ You are not an administrator with the required level");
      if (
sscanf(params"ud"targetidadminlevel)) return SendClientMessage(playeridCOLOR_RED"Usage ~ /makeadmin [PlayerID/PartOfName] [AdminLevel]");
      if (!
IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_RED"Error ~ Player not Connected");
      if (
adminlevel == PlayerInfo[targetid][AdminLevel]) return SendClientMessage(playeridCOLOR_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?!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)