[REP+] Warning 225: Unreachable Code
#1

I add 'custom' locking system by SEnergy https://sampforum.blast.hk/showthread.php?tid=363742

Unfortunately, I got warning like in the topic said.

Quote:

C:\Users\sofie's\Desktop\SKCNRV3\gamemodes\CNR.pwn (3661) : warning 225: unreachable code

This is the locking code. Line 3661 - 3740

Quote:
Код:
    if(!strcmp(cmdtext, "/lock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle."); // player has to be in a vehicle
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver."); // player has to be a driver
        if(PlayerCar[playerid] != -1)
        {
            LockedCar[PlayerCar[playerid]] = 0; // if player has any locked vehicle it will unlock it, allowing him to lock current vehicle - every player can have only one locked vehicle
        }
        PlayerCar[playerid] = GetPlayerVehicleID(playerid); // bounds vehicle to a player
        LockedCar[GetPlayerVehicleID(playerid)] = 1; // locks vehicle
        return 1;
    }
    if(!strcmp(cmdtext, "/unlock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle.");
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver.");
        PlayerCar[playerid] = -1; // tells server that this player don't have any locked vehicle
        LockedCar[GetPlayerVehicleID(playerid)] = 0; // unlocks current vehicle
        return 1;
    }
    return 0;
	
	if(strcmp(cmd, "/heal", true) == 0)
	{
	    tmp = strtok(cmdtext, idx);
	    new Float:health;
	    if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /heal [ID]");
	    else
	    {
            GetPlayerHealth(strlen(tmp), health);
		    if(IsPlayerSpawned(playerid))
		    {
				if(gTeam[playerid] == Medic)
				{
                    if(strval(tmp) != playerid)
				    {
						if(!IsPlayerInAnyVehicle(playerid))
						{
						    if(!IsPlayerInAnyVehicle(strval(tmp)))
						    {
						        if(IsPlayerConnected(strval(tmp)))
					        	{
						                if(GetPlayerMoney(strval(tmp) > 499))
						                {
						                    if(GetDistanceBetweenPlayers(playerid, strval(tmp)) <= 3)
						                    {
                                               if(health < 100)
				                               {
												    new string[250], string2[250], healedname[MAX_PLAYER_NAME], medicname[MAX_PLAYER_NAME];
												    GetPlayerName(playerid, medicname, sizeof(medicname));
												    GetPlayerName(strval(tmp), healedname, sizeof(healedname));
												    format(string, sizeof(string), "You have healed from %s (%d)! You give him $ 500!", medicname, playerid);
												    SendClientMessage(strval(tmp), SERVER_COLOR, string);
												    format(string2, sizeof(string2), "You heal %s (%d)! You received $ 500", healedname, strval(tmp));
												    SendClientMessage(playerid, SERVER_COLOR, string2);
													AC_BS_GivePlayerMoney(playerid, 500);
													AC_BS_GivePlayerMoney(strval(tmp), -500);
													SetPlayerHealth(strval(tmp), 100);
													GivePlayerScore(playerid, 1);
												}
				                                else if(health == 100) return SendClientMessage(playerid, ERROR, "You seem OK to me.");
											}
											else
											{
												new string[250], faraway[MAX_PLAYER_NAME];
											    GetPlayerName(strval(tmp), faraway, sizeof(faraway));
											    format(string, sizeof(string), "%s (%d) is too far away.", faraway, strval(tmp));
												return SendClientMessage(playerid, ERROR, string);
											}
										}
										else if(GetPlayerMoney(strval(tmp)) == 0)
										{
										    new string[250], poor[MAX_PLAYER_NAME];
										    GetPlayerName(strval(tmp), poor, sizeof(poor));
										    format(string, sizeof(string), "%s (%d) does not have any money.", poor, strval(tmp));
											return SendClientMessage(playerid, ERROR, string);
										}
									}
								}
								else if(!IsPlayerConnected(strval(tmp)))
								{
									new string[250];
									format(string, sizeof(string), "ID %d is not connected.", strval(tmp));
									return SendClientMessage(playerid, ERROR, string);
								}
							}
							else if(IsPlayerInAnyVehicle(strval(tmp)))
							{
							    new string[250], invehicle[MAX_PLAYER_NAME];
							    GetPlayerName(strval(tmp), invehicle, sizeof(invehicle));
								format(string, sizeof(string), "%s (%d) is in a vehicle. You cannot heal him.", invehicle, strval(tmp));
								return SendClientMessage(playerid, ERROR, string);
							}
						}
						else if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, ERROR, "You cannot heal anyone from inside a vehicle.");
					}
					else return SendClientMessage(playerid, ERROR, "You cannot heal yourself.");
				}
				else return SendClientMessage(playerid, ERROR, "Only Medics can use this command!");
		    }
    return 1;
	}
The warning comes from this line (3661)
Quote:
Код:
	if(strcmp(cmd, "/heal", true) == 0)
I'm sick of this warning , please help
Reply
#2

Bump. I need to fix this asap. I still have the warning..
Reply
#3

pawn Код:
if(!strcmp(cmdtext, "/lock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle."); // player has to be in a vehicle
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver."); // player has to be a driver
        if(PlayerCar[playerid] != -1)
        {
            LockedCar[PlayerCar[playerid]] = 0; // if player has any locked vehicle it will unlock it, allowing him to lock current vehicle - every player can have only one locked vehicle
        }
        PlayerCar[playerid] = GetPlayerVehicleID(playerid); // bounds vehicle to a player
        LockedCar[GetPlayerVehicleID(playerid)] = 1; // locks vehicle
        return 1;
    }
    if(!strcmp(cmdtext, "/unlock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle.");
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver.");
        PlayerCar[playerid] = -1; // tells server that this player don't have any locked vehicle
        LockedCar[GetPlayerVehicleID(playerid)] = 0; // unlocks current vehicle
        return 1;
    }
    if(strcmp(cmd, "/heal", true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        new Float:health;
        if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /heal [ID]");
        else
        {
            GetPlayerHealth(strlen(tmp), health);
            if(IsPlayerSpawned(playerid))
            {
                if(gTeam[playerid] == Medic)
                {
                    if(strval(tmp) != playerid)
                    {
                        if(!IsPlayerInAnyVehicle(playerid))
                        {
                            if(!IsPlayerInAnyVehicle(strval(tmp)))
                            {
                                if(IsPlayerConnected(strval(tmp)))
                                {
                                        if(GetPlayerMoney(strval(tmp) > 499))
                                        {
                                            if(GetDistanceBetweenPlayers(playerid, strval(tmp)) <= 3)
                                            {
                                               if(health < 100)
                                               {
                                                    new string[250], string2[250], healedname[MAX_PLAYER_NAME], medicname[MAX_PLAYER_NAME];
                                                    GetPlayerName(playerid, medicname, sizeof(medicname));
                                                    GetPlayerName(strval(tmp), healedname, sizeof(healedname));
                                                    format(string, sizeof(string), "You have healed from %s (%d)! You give him $ 500!", medicname, playerid);
                                                    SendClientMessage(strval(tmp), SERVER_COLOR, string);
                                                    format(string2, sizeof(string2), "You heal %s (%d)! You received $ 500", healedname, strval(tmp));
                                                    SendClientMessage(playerid, SERVER_COLOR, string2);
                                                    AC_BS_GivePlayerMoney(playerid, 500);
                                                    AC_BS_GivePlayerMoney(strval(tmp), -500);
                                                    SetPlayerHealth(strval(tmp), 100);
                                                    GivePlayerScore(playerid, 1);
                                                }
                                                else if(health == 100) return SendClientMessage(playerid, ERROR, "You seem OK to me.");
                                            }
                                            else
                                            {
                                                new string[250], faraway[MAX_PLAYER_NAME];
                                                GetPlayerName(strval(tmp), faraway, sizeof(faraway));
                                                format(string, sizeof(string), "%s (%d) is too far away.", faraway, strval(tmp));
                                                return SendClientMessage(playerid, ERROR, string);
                                            }
                                        }
                                        else if(GetPlayerMoney(strval(tmp)) == 0)
                                        {
                                            new string[250], poor[MAX_PLAYER_NAME];
                                            GetPlayerName(strval(tmp), poor, sizeof(poor));
                                            format(string, sizeof(string), "%s (%d) does not have any money.", poor, strval(tmp));
                                            return SendClientMessage(playerid, ERROR, string);
                                        }
                                    }
                                }
                                else if(!IsPlayerConnected(strval(tmp)))
                                {
                                    new string[250];
                                    format(string, sizeof(string), "ID %d is not connected.", strval(tmp));
                                    return SendClientMessage(playerid, ERROR, string);
                                }
                            }
                            else if(IsPlayerInAnyVehicle(strval(tmp)))
                            {
                                new string[250], invehicle[MAX_PLAYER_NAME];
                                GetPlayerName(strval(tmp), invehicle, sizeof(invehicle));
                                format(string, sizeof(string), "%s (%d) is in a vehicle. You cannot heal him.", invehicle, strval(tmp));
                                return SendClientMessage(playerid, ERROR, string);
                            }
                        }
                        else if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, ERROR, "You cannot heal anyone from inside a vehicle.");
                    }
                    else return SendClientMessage(playerid, ERROR, "You cannot heal yourself.");
                }
                else return SendClientMessage(playerid, ERROR, "Only Medics can use this command!");
            }
    return 1;
    }
try this . .
Reply
#4

Quote:
Originally Posted by Devilxz97
Посмотреть сообщение
pawn Код:
if(!strcmp(cmdtext, "/lock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle."); // player has to be in a vehicle
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver."); // player has to be a driver
        if(PlayerCar[playerid] != -1)
        {
            LockedCar[PlayerCar[playerid]] = 0; // if player has any locked vehicle it will unlock it, allowing him to lock current vehicle - every player can have only one locked vehicle
        }
        PlayerCar[playerid] = GetPlayerVehicleID(playerid); // bounds vehicle to a player
        LockedCar[GetPlayerVehicleID(playerid)] = 1; // locks vehicle
        return 1;
    }
    if(!strcmp(cmdtext, "/unlock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle.");
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver.");
        PlayerCar[playerid] = -1; // tells server that this player don't have any locked vehicle
        LockedCar[GetPlayerVehicleID(playerid)] = 0; // unlocks current vehicle
        return 1;
    }
    if(strcmp(cmd, "/heal", true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        new Float:health;
        if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /heal [ID]");
        else
        {
            GetPlayerHealth(strlen(tmp), health);
            if(IsPlayerSpawned(playerid))
            {
                if(gTeam[playerid] == Medic)
                {
                    if(strval(tmp) != playerid)
                    {
                        if(!IsPlayerInAnyVehicle(playerid))
                        {
                            if(!IsPlayerInAnyVehicle(strval(tmp)))
                            {
                                if(IsPlayerConnected(strval(tmp)))
                                {
                                        if(GetPlayerMoney(strval(tmp) > 499))
                                        {
                                            if(GetDistanceBetweenPlayers(playerid, strval(tmp)) <= 3)
                                            {
                                               if(health < 100)
                                               {
                                                    new string[250], string2[250], healedname[MAX_PLAYER_NAME], medicname[MAX_PLAYER_NAME];
                                                    GetPlayerName(playerid, medicname, sizeof(medicname));
                                                    GetPlayerName(strval(tmp), healedname, sizeof(healedname));
                                                    format(string, sizeof(string), "You have healed from %s (%d)! You give him $ 500!", medicname, playerid);
                                                    SendClientMessage(strval(tmp), SERVER_COLOR, string);
                                                    format(string2, sizeof(string2), "You heal %s (%d)! You received $ 500", healedname, strval(tmp));
                                                    SendClientMessage(playerid, SERVER_COLOR, string2);
                                                    AC_BS_GivePlayerMoney(playerid, 500);
                                                    AC_BS_GivePlayerMoney(strval(tmp), -500);
                                                    SetPlayerHealth(strval(tmp), 100);
                                                    GivePlayerScore(playerid, 1);
                                                }
                                                else if(health == 100) return SendClientMessage(playerid, ERROR, "You seem OK to me.");
                                            }
                                            else
                                            {
                                                new string[250], faraway[MAX_PLAYER_NAME];
                                                GetPlayerName(strval(tmp), faraway, sizeof(faraway));
                                                format(string, sizeof(string), "%s (%d) is too far away.", faraway, strval(tmp));
                                                return SendClientMessage(playerid, ERROR, string);
                                            }
                                        }
                                        else if(GetPlayerMoney(strval(tmp)) == 0)
                                        {
                                            new string[250], poor[MAX_PLAYER_NAME];
                                            GetPlayerName(strval(tmp), poor, sizeof(poor));
                                            format(string, sizeof(string), "%s (%d) does not have any money.", poor, strval(tmp));
                                            return SendClientMessage(playerid, ERROR, string);
                                        }
                                    }
                                }
                                else if(!IsPlayerConnected(strval(tmp)))
                                {
                                    new string[250];
                                    format(string, sizeof(string), "ID %d is not connected.", strval(tmp));
                                    return SendClientMessage(playerid, ERROR, string);
                                }
                            }
                            else if(IsPlayerInAnyVehicle(strval(tmp)))
                            {
                                new string[250], invehicle[MAX_PLAYER_NAME];
                                GetPlayerName(strval(tmp), invehicle, sizeof(invehicle));
                                format(string, sizeof(string), "%s (%d) is in a vehicle. You cannot heal him.", invehicle, strval(tmp));
                                return SendClientMessage(playerid, ERROR, string);
                            }
                        }
                        else if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, ERROR, "You cannot heal anyone from inside a vehicle.");
                    }
                    else return SendClientMessage(playerid, ERROR, "You cannot heal yourself.");
                }
                else return SendClientMessage(playerid, ERROR, "Only Medics can use this command!");
            }
    return 1;
    }
try this . .
Thanks man! I'll rep+ you
Reply
#5

need 50+ Post to rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)