Params and redundant test: constant expression is non-zero
#1

I have those weird warnings that actually doesn't effect the code itself in game, it works in game, still i want to erase those warnings and i cant find how ... Helpme

Код:
(29306) : warning 206: redundant test: constant expression is non-zero

(98201) : warning 203: symbol is never used: "params"

(98238) : warning 203: symbol is never used: "params"

(98258) : warning 203: symbol is never used: "params"

(99297) : warning 203: symbol is never used: "params"
The Lines:

Line 29306:

Код:
if(USE_TEXTDRAW_SET == 2)
Line 98201:
Код:
dcmd_placeboombox(playerid, params[])
Line 98238:
Код:
dcmd_turnon(playerid, params[])
Line 98258:
Код:
dcmd_pickupboombox(playerid, params[])
Line 99297:
Код:
dcmd_stopamusic(playerid, params[])
Reply
#2

To the command shows symbol is never used: "params", use:
pawn Код:
#pragma unused params
For the other, I don't understand it too. Even if I use something like:
pawn Код:
if(10 > 2)
It will give that warning instead of giving true.
Reply
#3

The first problem can be solved using
pawn Код:
#if USE_TEXTDRAW_SET == 2 // Your "if"
// Your if code
#elseif SOMETHING > 0 // alternative "else" and "if" (an example, if you are going to use something like this)
// ...
#else // alternative else (an example, if you are going to use something like this)
// ...
#endif // End of your "if"
To the second thing, I wouldn't use this method for searching commands in a script.
Reply
#4

Quote:
Originally Posted by _Zeus
Посмотреть сообщение
To the command shows symbol is never used: "params", use:
pawn Код:
#pragma unused params
For the other, I don't understand it too. Even if I use something like:
pawn Код:
if(10 > 2)
It will give that warning instead of giving true.
Thanks for the fast replay.
After adding the #pragma unused params, I've got an error to the same line i added the unused params.
Код:
 
error 017: undefined symbol "params"
tried the "if(10 > 2)" insted of "if(USE_TEXTDRAW_SET == 2)" and still having the warning :/
Reply
#5

Did you just completly ignore my post?
Reply
#6

Quote:
Originally Posted by BigETI
Посмотреть сообщение
The first problem can be solved using
pawn Код:
#if USE_TEXTDRAW_SET == 2 // Your "if"
// Your if code
#elseif SOMETHING > 0 // alternative "else" and "if" (an example, if you are going to use something like this)
// ...
#else // alternative else (an example, if you are going to use something like this)
// ...
#endif // End of your "if"
To the second thing, I wouldn't use this method for searching commands in a script.
you mean when im using the "#if USE_TESTDRAW_SET == 2" in the end of strcmp i have to add #endif and it wouldn't give an warning? if so :

If i change "if(USE_TEXTDRAW_SET == 2)" to "#if USE_TEXTDRAW_SET == 2"
It would give me an error.
Код:
error 001: expected token: "#endif", but found "-end of file-"
then i added endif and it gave me another error :
Код:
(29312) : error 029: invalid expression, assumed zero
Line 29312
Код:
       else
Код:
        #if USE_TEXTDRAW_SET == 2
        {
            format(string,sizeof(string),"Listening to: ~n~~w~%s",r_RadioInfo[playingid][r_Name]);
            TextDrawSetString(v_VehicleInfo[vehicleid][r_Draw],string);
        }
        else // the error says this invalid expression, assumed zero
        {
            TextDrawSetString(v_VehicleInfo[vehicleid][r_Draw],r_RadioInfo[playingid][r_Name]);
        }
        TextDrawShowForPlayer(playerid,v_VehicleInfo[vehicleid][r_Draw]);
        SetPVarInt(playerid,"ID_HideRadioTextdraw",SetTimerEx("HideRadioTextdraw",TEXTDRAW_DISAPPEAR_TIME,false,"ii",playerid,vehicleid));
        PlayAudioStreamForPlayer(playerid,r_RadioInfo[playingid][r_Link]);
        SetPVarInt(playerid,"ID_OldVehicle",vehicleid);
        }
	#endif
Reply
#7

Quote:
Originally Posted by BigETI
Посмотреть сообщение
Did you just completly ignore my post?
I posted replay for you'r post after compiling and seen errors/warnings.

Quote:
Originally Posted by _Zeus
Посмотреть сообщение
Is it like this?
pawn Код:
// For example:
dcmd_kill(playerid, params[])
{
    #pragma unused params
    SetPlayerHealth(playerid, 0.0);
    return 1;
}
I know it's giving the same warning for even a check (10 > 2), but you can try what BigETI said!



I believe he was typing more than 2 minutes and he didn't see your post until he posted a reply.
Код:
(266) : error 017: undefined symbol "params"
Line 266
Код:
#pragma unused params
Eample of the one of the dcmd params that gives me an warning:
Код:
dcmd_placeboombox(playerid, params[])
{
	if(PlayerInfo[playerid][pBoomBox] == 0) return SendClientMessage(playerid, COLOR_WHITE, "You don't have a BoomBox");
	if(GetPVarType(playerid, "pDynamicBB")) return SendClientMessage(playerid, COLOR_WHITE, "You already have a boombox out, use /pickupboombox.");

	foreach(Player, i)
	{
 		if(GetPVarType(i, "pDynamicBB"))
   		{
  			if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "pDynamicBBX"), GetPVarFloat(i, "pDynamicBBY"), GetPVarFloat(i, "pDynamicBBZ")))
			{
   				SendClientMessage(playerid, COLOR_WHITE, "You cannot put your boombox in this Radius");
			    return 1;
			}
		}
		new string[128];
		format(string, sizeof(string), "%s has placed a boombox on the floor!", SenderName(playerid));
		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);

	    new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerPos(playerid, x, y, z);
	    GetPlayerFacingAngle(playerid, a);
	    ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
	    x += (2 * floatsin(-a, degrees));
    	y += (2 * floatcos(-a, degrees));
    	z -= 1.0;

	    SetPVarInt(playerid, "pDynamicBB", CreateDynamicObject(2226, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
	    SetPVarFloat(playerid, "pDynamicBBX", x); SetPVarFloat(playerid, "pDynamicBBY", y); SetPVarFloat(playerid, "pDynamicBBZ", z);
		format(string, sizeof(string), "{00FF00}Boombox Owner:{FFFFFF}%s\n{FF0000}/turnon{FFFFFF} to set your boombox \n{FFFF00}or\n{FF0000}/pickupboombox", SenderName(playerid));
	    SetPVarInt(playerid, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, COLOR_WHITE, x, y, z+0.6, 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
		SetPVarInt(playerid, "pDynamicBBArea", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
		SetPVarInt(playerid, "pDynamicBBInt", GetPlayerInterior(playerid));
		SetPVarInt(playerid, "pDynamicBBVW", GetPlayerVirtualWorld(playerid));
	}
	return 1;
}
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
It will give the warning AND true - warnings still compile. The reason it comes up is that "if" is evaluated at run-time, so takes time while your code is executing. That check "10 > 2" is ALWAYS true, so you are wasting time testing something that can never fail! That's why the warning exists.
This solved me that problem
pawn Код:
#if USE_TEXTDRAW_SET == 2
format(string,sizeof(string),"Listening to: ~n~~w~%s",r_RadioInfo[playingid][r_Name]);
TextDrawSetString(v_VehicleInfo[vehicleid][r_Draw],string);
#else
TextDrawSetString(v_VehicleInfo[vehicleid][r_Draw],r_RadioInfo[playingid][r_Name]);
#endif
TextDrawShowForPlayer(playerid,v_VehicleInfo[vehicleid][r_Draw]);
SetPVarInt(playerid,"ID_HideRadioTextdraw",SetTimerEx("HideRadioTextdraw",TEXTDRAW_DISAPPEAR_TIME,false,"ii",playerid,vehicleid));
PlayAudioStreamForPlayer(playerid,r_RadioInfo[playingid][r_Link]);
SetPVarInt(playerid,"ID_OldVehicle",vehicleid);
But still can you tell why i added:
Line 266
Код:
#pragma unused params
and it gives me an error:
Код:
(266) : error 017: undefined symbol "params"
Perhaps the params warnings are still there.
Код:
warning 203: symbol is never used: "params"
warning 203: symbol is never used: "params"
warning 203: symbol is never used: "params"
warning 203: symbol is never used: "params"
Quote:
Originally Posted by _Zeus
Посмотреть сообщение
Is it like this?
pawn Код:
// For example:
dcmd_kill(playerid, params[])
{
    #pragma unused params
    SetPlayerHealth(playerid, 0.0);
    return 1;
}
No, i added the #pragma unused params at the top of the script. [Line 266]
Reply
#9

Quote:
Originally Posted by maxpain43
Посмотреть сообщение
Eample of the one of the dcmd params that gives me an warning:
Код:
dcmd_placeboombox(playerid, params[])
{
	if(PlayerInfo[playerid][pBoomBox] == 0) return SendClientMessage(playerid, COLOR_WHITE, "You don't have a BoomBox");
	if(GetPVarType(playerid, "pDynamicBB")) return SendClientMessage(playerid, COLOR_WHITE, "You already have a boombox out, use /pickupboombox.");

	foreach(Player, i)
	{
 		if(GetPVarType(i, "pDynamicBB"))
   		{
  			if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "pDynamicBBX"), GetPVarFloat(i, "pDynamicBBY"), GetPVarFloat(i, "pDynamicBBZ")))
			{
   				SendClientMessage(playerid, COLOR_WHITE, "You cannot put your boombox in this Radius");
			    return 1;
			}
		}
		new string[128];
		format(string, sizeof(string), "%s has placed a boombox on the floor!", SenderName(playerid));
		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);

	    new Float:x, Float:y, Float:z, Float:a;
	    GetPlayerPos(playerid, x, y, z);
	    GetPlayerFacingAngle(playerid, a);
	    ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
	    x += (2 * floatsin(-a, degrees));
    	y += (2 * floatcos(-a, degrees));
    	z -= 1.0;

	    SetPVarInt(playerid, "pDynamicBB", CreateDynamicObject(2226, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
	    SetPVarFloat(playerid, "pDynamicBBX", x); SetPVarFloat(playerid, "pDynamicBBY", y); SetPVarFloat(playerid, "pDynamicBBZ", z);
		format(string, sizeof(string), "{00FF00}Boombox Owner:{FFFFFF}%s\n{FF0000}/turnon{FFFFFF} to set your boombox \n{FFFF00}or\n{FF0000}/pickupboombox", SenderName(playerid));
	    SetPVarInt(playerid, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, COLOR_WHITE, x, y, z+0.6, 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
		SetPVarInt(playerid, "pDynamicBBArea", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
		SetPVarInt(playerid, "pDynamicBBInt", GetPlayerInterior(playerid));
		SetPVarInt(playerid, "pDynamicBBVW", GetPlayerVirtualWorld(playerid));
	}
	return 1;
}
I don't see anywhere to use pragma..

Quote:
Originally Posted by maxpain43
Посмотреть сообщение
No, i added the #pragma unused params at the top of the script. [Line 266]
Use it inside the command.

Quote:
Originally Posted by ******
Посмотреть сообщение
It will give the warning AND true - warnings still compile. The reason it comes up is that "if" is evaluated at run-time, so takes time while your code is executing. That check "10 > 2" is ALWAYS true, so you are wasting time testing something that can never fail! That's why the warning exists.
Hm, interesting! Thanks for the information.
Reply
#10

Quote:
Originally Posted by _Zeus
Посмотреть сообщение
Use it inside the command.
Jesus! thanks _Zeus and BigETI for fast replays and for the help i though those warnings would never go +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)