help with warning 206
#1

warning 206: redundant test: constant expression is non-zero


Heres the line of code it tells me it is:

Код:
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 10,1)

Now i thought that if i made two of thos elines it would fix the warning which it did but it made the line dorment within the script liek i would do:

Код:
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 10)
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
instead
Reply
#2

try
pawn Код:
if(PlayerInfo[playerid][pFaction] != 255 && (DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 10 || DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
{
Reply
#3

like this?

Код:
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 10)
{
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
Reply
#4

This is the code in full when i do it with the warnings


Код:
if(strcmp(cmd, "/government", true) == 0 || strcmp(cmd, "/gov", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 10,1)
			{
				if(PlayerInfo[playerid][pRank] != 1)
				{
				    SendClientMessage(playerid, COLOR_GREY, "(ERROR) Only the leader can use this");
				    return 1;
				}
				new length = strlen(cmdtext);
				while ((idx < length) && (cmdtext[idx] <= ' '))
				{
					idx++;
				}
				new offset = idx;
				new result[64];
				while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
				{
					result[idx - offset] = cmdtext[idx];
					idx++;
				}
				result[idx - offset] = EOS;
				if(!strlen(result))
				{
					SendClientMessage(playerid, COLOR_WHITE, "(USAGE) [/gov]ernment [text]");
					return 1;
				}
				if(CopOnDuty[playerid])
				{
					new faction = PlayerInfo[playerid][pFaction];
					SendClientMessageToAll(COLOR_GREEN, "|_________ Government Announcement _________|");
					format(string, sizeof(string), "%s %s: %s", DynamicFactions[faction][fRank1],GetPlayerNameEx(playerid), result);
					SendClientMessageToAll(COLOR_LIGHTRED, string);
					SendClientMessageToAll(COLOR_GREEN, "|_________ Government Announcement _________|");
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "(ERROR) You are not on duty");
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "(ERROR) Invalid faction");
			}
		}
		return 1;
	}
Reply
#5

Код:
if(strcmp(cmd, "/government", true) == 0 || strcmp(cmd, "/gov", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 10)
			{
				if(PlayerInfo[playerid][pRank] != 1)
				{
				    SendClientMessage(playerid, COLOR_GREY, "(ERROR) Only the leader can use this");
				    return 1;
				}
				new length = strlen(cmdtext);
				while ((idx < length) && (cmdtext[idx] <= ' '))
				{
					idx++;
				}
				new offset = idx;
				new result[64];
				while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
				{
					result[idx - offset] = cmdtext[idx];
					idx++;
				}
				result[idx - offset] = EOS;
				if(!strlen(result))
				{
					SendClientMessage(playerid, COLOR_WHITE, "(USAGE) [/gov]ernment [text]");
					return 1;
				}
				if(CopOnDuty[playerid])
				{
					new faction = PlayerInfo[playerid][pFaction];
					SendClientMessageToAll(COLOR_GREEN, "|_________ Government Announcement _________|");
					format(string, sizeof(string), "%s %s: %s", DynamicFactions[faction][fRank1],GetPlayerNameEx(playerid), result);
					SendClientMessageToAll(COLOR_LIGHTRED, string);
					SendClientMessageToAll(COLOR_GREEN, "|_________ Government Announcement _________|");
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "(ERROR) You are not on duty");
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "(ERROR) Invalid faction");
			}
		}
		return 1;
	}
try this
Reply
#6

i would but it needs faction type 1 and 10



SO WHAT DO I DO?
Reply
#7

Код:
if(strcmp(cmd, "/government", true) == 0 || strcmp(cmd, "/gov", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 10 || DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
			{
				if(PlayerInfo[playerid][pRank] != 1)
				{
				    SendClientMessage(playerid, COLOR_GREY, "(ERROR) Only the leader can use this");
				    return 1;
				}
				new length = strlen(cmdtext);
				while ((idx < length) && (cmdtext[idx] <= ' '))
				{
					idx++;
				}
				new offset = idx;
				new result[64];
				while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
				{
					result[idx - offset] = cmdtext[idx];
					idx++;
				}
				result[idx - offset] = EOS;
				if(!strlen(result))
				{
					SendClientMessage(playerid, COLOR_WHITE, "(USAGE) [/gov]ernment [text]");
					return 1;
				}
				if(CopOnDuty[playerid])
				{
					new faction = PlayerInfo[playerid][pFaction];
					SendClientMessageToAll(COLOR_GREEN, "|_________ Government Announcement _________|");
					format(string, sizeof(string), "%s %s: %s", DynamicFactions[faction][fRank1],GetPlayerNameEx(playerid), result);
					SendClientMessageToAll(COLOR_LIGHTRED, string);
					SendClientMessageToAll(COLOR_GREEN, "|_________ Government Announcement _________|");
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "(ERROR) You are not on duty");
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "(ERROR) Invalid faction");
			}
		}
		return 1;
	}
Reply
#8

Ok i get that,

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)