SA-MP Forums Archive
error 029: invalid expression, assumed zero - 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)
+--- Thread: error 029: invalid expression, assumed zero (/showthread.php?tid=566260)



error 029: invalid expression, assumed zero - SHFaCeBook - 04.03.2015

Hello

Help i get this error , when i compile mod


i get this error :
Код:
***********(29575) : error 029: invalid expression, assumed zero
line 29575
pawn Код:
else
Code
pawn Код:
CMD:duty(playerid, params[])
{
    new group = playerVariables[playerid][pGroup];
    if(groupVariables[group][gGroupType] == 1)
    if(GetPVarInt(playerid,"AntiFlood") > gettime()){ SendClientMessage(playerid, 0xFFD5BBAA, "Do Not Spam!"); return false; }
    SetPVarInt(playerid,"AntiFlood",gettime() + 1);
    {
       for(new x = 0; x < MAX_GROUPS; x++)
       {
           if(IsAtDuty(playerid) || IsPlayerInRangeOfPoint(playerid, 100.0, groupVariables[x][gGroupInteriorPos][0], groupVariables[x][gGroupInteriorPos][1], groupVariables[x][gGroupInteriorPos][2]) && GetPlayerVirtualWorld(playerid) == GROUP_VIRTUAL_WORLD+x)
           {
               GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
               if(playerVariables[playerid][pPoliceDuty] == 0)
               {
                   playerVariables[playerid][pPoliceDuty] = 1;
                   format(szMessage, sizeof(szMessage), "%s took his equipment out of his locker.", szPlayerName);
                   nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
                   givePlayerValidWeapon(playerid, 24);
                   givePlayerValidWeapon(playerid, 31);
                   givePlayerValidWeapon(playerid, 29);
                   givePlayerValidWeapon(playerid, 41);
                   playerVariables[playerid][pArmour] = 100;
                   playerVariables[playerid][pHealth] = 100;
                   SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
                   SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
                }
               else
                {
                    playerVariables[playerid][pPoliceDuty] = 0;
                    format(szMessage, sizeof(szMessage), "%s put his equipment in his locker.", szPlayerName);
                    nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
                    validResetPlayerWeapons(playerid);
                    playerVariables[playerid][pArmour] = 0;
                    playerVariables[playerid][pHealth] = 100;
                    SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
                    SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
                }
            }
            else
            {
               SCM(playerid, COLOR_GREY, "You need to be in your HQ!");
            }
         }
         else
         {
             SCM(playerid, COLOR_GREY, "You are not a cop!");
         }
     }
     return 1;
}
https://sampforum.blast.hk/showthread.php?tid=566255


Re: error 029: invalid expression, assumed zero - MikE1990 - 04.03.2015

Код:
CMD:duty(playerid, params[])
{
	new group = playerVariables[playerid][pGroup];
	if(groupVariables[group][gGroupType] == 1)
	if(GetPVarInt(playerid,"AntiFlood") > gettime()){ SendClientMessage(playerid, 0xFFD5BBAA, "Do Not Spam!"); return false; }
	SetPVarInt(playerid,"AntiFlood",gettime() + 1);
       for(new x = 0; x < MAX_GROUPS; x++)
		{
		   if(IsAtDuty(playerid) || IsPlayerInRangeOfPoint(playerid, 100.0, groupVariables[x][gGroupInteriorPos][0], groupVariables[x][gGroupInteriorPos][1], groupVariables[x][gGroupInteriorPos][2]) && GetPlayerVirtualWorld(playerid) == GROUP_VIRTUAL_WORLD+x)
 			{
			   GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
			   if(playerVariables[playerid][pPoliceDuty] == 0)
			   {
				   playerVariables[playerid][pPoliceDuty] = 1;
				   format(szMessage, sizeof(szMessage), "%s took his equipment out of his locker.", szPlayerName);
			       nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				   givePlayerValidWeapon(playerid, 24);
				   givePlayerValidWeapon(playerid, 31);
				   givePlayerValidWeapon(playerid, 29);
				   givePlayerValidWeapon(playerid, 41);
				   playerVariables[playerid][pArmour] = 100;
				   playerVariables[playerid][pHealth] = 100;
				   SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				   SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
				}
		       else
			    {
				    playerVariables[playerid][pPoliceDuty] = 0;
				    format(szMessage, sizeof(szMessage), "%s put his equipment in his locker.", szPlayerName);
				    nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				    validResetPlayerWeapons(playerid);
				    playerVariables[playerid][pArmour] = 0;
				    playerVariables[playerid][pHealth] = 100;
				    SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				    SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
		        }
		    }
		    else
		    {
		       SCM(playerid, COLOR_GREY, "You need to be in your HQ!");
		    }
	   	 }

     return 1;
}
Try this code


Re: error 029: invalid expression, assumed zero - SHFaCeBook - 04.03.2015

Quote:
Originally Posted by MikE1990
Посмотреть сообщение
Код:
CMD:duty(playerid, params[])
{
	new group = playerVariables[playerid][pGroup];
	if(groupVariables[group][gGroupType] == 1)
	if(GetPVarInt(playerid,"AntiFlood") > gettime()){ SendClientMessage(playerid, 0xFFD5BBAA, "Do Not Spam!"); return false; }
	SetPVarInt(playerid,"AntiFlood",gettime() + 1);
       for(new x = 0; x < MAX_GROUPS; x++)
		{
		   if(IsAtDuty(playerid) || IsPlayerInRangeOfPoint(playerid, 100.0, groupVariables[x][gGroupInteriorPos][0], groupVariables[x][gGroupInteriorPos][1], groupVariables[x][gGroupInteriorPos][2]) && GetPlayerVirtualWorld(playerid) == GROUP_VIRTUAL_WORLD+x)
 			{
			   GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
			   if(playerVariables[playerid][pPoliceDuty] == 0)
			   {
				   playerVariables[playerid][pPoliceDuty] = 1;
				   format(szMessage, sizeof(szMessage), "%s took his equipment out of his locker.", szPlayerName);
			       nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				   givePlayerValidWeapon(playerid, 24);
				   givePlayerValidWeapon(playerid, 31);
				   givePlayerValidWeapon(playerid, 29);
				   givePlayerValidWeapon(playerid, 41);
				   playerVariables[playerid][pArmour] = 100;
				   playerVariables[playerid][pHealth] = 100;
				   SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				   SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
				}
		       else
			    {
				    playerVariables[playerid][pPoliceDuty] = 0;
				    format(szMessage, sizeof(szMessage), "%s put his equipment in his locker.", szPlayerName);
				    nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				    validResetPlayerWeapons(playerid);
				    playerVariables[playerid][pArmour] = 0;
				    playerVariables[playerid][pHealth] = 100;
				    SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				    SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
		        }
		    }
		    else
		    {
		       SCM(playerid, COLOR_GREY, "You need to be in your HQ!");
		    }
	   	 }

     return 1;
}
Try this code
and why u removed this ? :3
pawn Код:
SCM(playerid, COLOR_GREY, "You are not a cop!");



Re: error 029: invalid expression, assumed zero - MikE1990 - 04.03.2015

Because you use else after for loop but else is only for if
Код:
CMD:duty(playerid, params[])
{
	new group = playerVariables[playerid][pGroup];
	if(groupVariables[group][gGroupType] == 1) // if gGroupType == 1 then What ?
	if(GetPVarInt(playerid,"AntiFlood") > gettime()){ SendClientMessage(playerid, 0xFFD5BBAA, "Do Not Spam!"); return false; }
	SetPVarInt(playerid,"AntiFlood",gettime() + 1);
   	{// Why you use here brackets ??
       for(new x = 0; x < MAX_GROUPS; x++)
	   {
		   if(IsAtDuty(playerid) || IsPlayerInRangeOfPoint(playerid, 100.0, groupVariables[x][gGroupInteriorPos][0], groupVariables[x][gGroupInteriorPos][1], groupVariables[x][gGroupInteriorPos][2]) && GetPlayerVirtualWorld(playerid) == GROUP_VIRTUAL_WORLD+x)
		   {
			   GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
			   if(playerVariables[playerid][pPoliceDuty] == 0)
			   {
				   playerVariables[playerid][pPoliceDuty] = 1;
				   format(szMessage, sizeof(szMessage), "%s took his equipment out of his locker.", szPlayerName);
			       nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				   givePlayerValidWeapon(playerid, 24);
				   givePlayerValidWeapon(playerid, 31);
				   givePlayerValidWeapon(playerid, 29);
				   givePlayerValidWeapon(playerid, 41);
				   playerVariables[playerid][pArmour] = 100;
				   playerVariables[playerid][pHealth] = 100;
				   SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				   SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
                }
		       else
			    {
				    playerVariables[playerid][pPoliceDuty] = 0;
				    format(szMessage, sizeof(szMessage), "%s put his equipment in his locker.", szPlayerName);
				    nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				    validResetPlayerWeapons(playerid);
				    playerVariables[playerid][pArmour] = 0;
				    playerVariables[playerid][pHealth] = 100;
				    SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				    SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
		        }
		    }
		    else
		    {
		       SCM(playerid, COLOR_GREY, "You need to be in your HQ!");
		    }
	     }
	     else // Else after for loop
	     {
		     SCM(playerid, COLOR_GREY, "You are not a cop!");
	     }
	 }
     return 1;
}
Look comments i made.


Re: error 029: invalid expression, assumed zero - SHFaCeBook - 04.03.2015

Quote:
Originally Posted by MikE1990
Посмотреть сообщение
Because you use else after for loop but else is only for if
Код:
CMD:duty(playerid, params[])
{
	new group = playerVariables[playerid][pGroup];
	if(groupVariables[group][gGroupType] == 1) // if gGroupType == 1 then What ?
	if(GetPVarInt(playerid,"AntiFlood") > gettime()){ SendClientMessage(playerid, 0xFFD5BBAA, "Do Not Spam!"); return false; }
	SetPVarInt(playerid,"AntiFlood",gettime() + 1);
   	{// Why you use here brackets ??
       for(new x = 0; x < MAX_GROUPS; x++)
	   {
		   if(IsAtDuty(playerid) || IsPlayerInRangeOfPoint(playerid, 100.0, groupVariables[x][gGroupInteriorPos][0], groupVariables[x][gGroupInteriorPos][1], groupVariables[x][gGroupInteriorPos][2]) && GetPlayerVirtualWorld(playerid) == GROUP_VIRTUAL_WORLD+x)
		   {
			   GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
			   if(playerVariables[playerid][pPoliceDuty] == 0)
			   {
				   playerVariables[playerid][pPoliceDuty] = 1;
				   format(szMessage, sizeof(szMessage), "%s took his equipment out of his locker.", szPlayerName);
			       nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				   givePlayerValidWeapon(playerid, 24);
				   givePlayerValidWeapon(playerid, 31);
				   givePlayerValidWeapon(playerid, 29);
				   givePlayerValidWeapon(playerid, 41);
				   playerVariables[playerid][pArmour] = 100;
				   playerVariables[playerid][pHealth] = 100;
				   SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				   SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
                }
		       else
			    {
				    playerVariables[playerid][pPoliceDuty] = 0;
				    format(szMessage, sizeof(szMessage), "%s put his equipment in his locker.", szPlayerName);
				    nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				    validResetPlayerWeapons(playerid);
				    playerVariables[playerid][pArmour] = 0;
				    playerVariables[playerid][pHealth] = 100;
				    SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				    SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
		        }
		    }
		    else
		    {
		       SCM(playerid, COLOR_GREY, "You need to be in your HQ!");
		    }
	     }
	     else // Else after for loop
	     {
		     SCM(playerid, COLOR_GREY, "You are not a cop!");
	     }
	 }
     return 1;
}
Look comments i made.
i compile ,and is compile norm , mmm is work on normal player /duty .....


Re: error 029: invalid expression, assumed zero - MikE1990 - 04.03.2015

Tell me which group type is police.


Re: error 029: invalid expression, assumed zero - SHFaCeBook - 04.03.2015

is Type ; 1 , and when norm player write /duty , is show Message near player he geted :
Код:
%s took his equipment out of his locker.
Код:
%s put his equipment in his locker.
....

mm he not get guns.


Re: error 029: invalid expression, assumed zero - MikE1990 - 04.03.2015

Код:
CMD:duty(playerid, params[])
{
	new group = playerVariables[playerid][pGroup];
	if(groupVariables[group][gGroupType] != 1) return SCM(playerid, COLOR_GREY, "You are not a cop!");
	if(GetPVarInt(playerid,"AntiFlood") > gettime()){ SendClientMessage(playerid, 0xFFD5BBAA, "Do Not Spam!"); return false; }
	SetPVarInt(playerid,"AntiFlood",gettime() + 1);
	for(new x = 0; x < MAX_GROUPS; x++)
	{
		if(IsAtDuty(playerid) || IsPlayerInRangeOfPoint(playerid, 100.0, groupVariables[x][gGroupInteriorPos][0], groupVariables[x][gGroupInteriorPos][1], groupVariables[x][gGroupInteriorPos][2]) && GetPlayerVirtualWorld(playerid) == GROUP_VIRTUAL_WORLD+x)
		{
			GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
			if(playerVariables[playerid][pPoliceDuty] == 0)
			{
				playerVariables[playerid][pPoliceDuty] = 1;
				format(szMessage, sizeof(szMessage), "%s took his equipment out of his locker.", szPlayerName);
				nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				givePlayerValidWeapon(playerid, 24);
				givePlayerValidWeapon(playerid, 31);
				givePlayerValidWeapon(playerid, 29);
				givePlayerValidWeapon(playerid, 41);
				playerVariables[playerid][pArmour] = 100;
				playerVariables[playerid][pHealth] = 100;
				SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
			}
			else
			{
				playerVariables[playerid][pPoliceDuty] = 0;
				format(szMessage, sizeof(szMessage), "%s put his equipment in his locker.", szPlayerName);
				nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				validResetPlayerWeapons(playerid);
				playerVariables[playerid][pArmour] = 0;
				playerVariables[playerid][pHealth] = 100;
				SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
			}
		}
		else
		{
			SCM(playerid, COLOR_GREY, "You need to be in your HQ!");
		}
	}
     return 1;
}
That worked ?


Re: error 029: invalid expression, assumed zero - SHFaCeBook - 04.03.2015

Quote:
Originally Posted by MikE1990
Посмотреть сообщение
Код:
CMD:duty(playerid, params[])
{
	new group = playerVariables[playerid][pGroup];
	if(groupVariables[group][gGroupType] != 1) return SCM(playerid, COLOR_GREY, "You are not a cop!");
	if(GetPVarInt(playerid,"AntiFlood") > gettime()){ SendClientMessage(playerid, 0xFFD5BBAA, "Do Not Spam!"); return false; }
	SetPVarInt(playerid,"AntiFlood",gettime() + 1);
	for(new x = 0; x < MAX_GROUPS; x++)
	{
		if(IsAtDuty(playerid) || IsPlayerInRangeOfPoint(playerid, 100.0, groupVariables[x][gGroupInteriorPos][0], groupVariables[x][gGroupInteriorPos][1], groupVariables[x][gGroupInteriorPos][2]) && GetPlayerVirtualWorld(playerid) == GROUP_VIRTUAL_WORLD+x)
		{
			GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
			if(playerVariables[playerid][pPoliceDuty] == 0)
			{
				playerVariables[playerid][pPoliceDuty] = 1;
				format(szMessage, sizeof(szMessage), "%s took his equipment out of his locker.", szPlayerName);
				nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				givePlayerValidWeapon(playerid, 24);
				givePlayerValidWeapon(playerid, 31);
				givePlayerValidWeapon(playerid, 29);
				givePlayerValidWeapon(playerid, 41);
				playerVariables[playerid][pArmour] = 100;
				playerVariables[playerid][pHealth] = 100;
				SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
			}
			else
			{
				playerVariables[playerid][pPoliceDuty] = 0;
				format(szMessage, sizeof(szMessage), "%s put his equipment in his locker.", szPlayerName);
				nearByMessage(playerid, COLOR_PURPLE, szMessage, 10.0);
				validResetPlayerWeapons(playerid);
				playerVariables[playerid][pArmour] = 0;
				playerVariables[playerid][pHealth] = 100;
				SetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
				SetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
			}
		}
		else
		{
			SCM(playerid, COLOR_GREY, "You need to be in your HQ!");
		}
	}
     return 1;
}
That worked ?
Not work

Bump! any one...


Re: error 029: invalid expression, assumed zero - MikE1990 - 04.03.2015

Explain what not work.