SA-MP Forums Archive
help with warning 206 - 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: help with warning 206 (/showthread.php?tid=193622)



help with warning 206 - mtywe - 26.11.2010

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


Re: help with warning 206 - Bessensap - 26.11.2010

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



Re: help with warning 206 - mtywe - 26.11.2010

like this?

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



Re: help with warning 206 - mtywe - 26.11.2010

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;
	}



Re: help with warning 206 - ExEx - 26.11.2010

Код:
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


Re: help with warning 206 - mtywe - 26.11.2010

i would but it needs faction type 1 and 10



SO WHAT DO I DO?


Re: help with warning 206 - ExEx - 27.11.2010

Код:
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;
	}



Re: help with warning 206 - mtywe - 27.11.2010

Ok i get that,

Thanks