SA-MP Forums Archive
[FIXED][DELTE THIS THREAD]possibly unintended assignment - 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: [FIXED][DELTE THIS THREAD]possibly unintended assignment (/showthread.php?tid=589440)



[FIXED][DELTE THIS THREAD]possibly unintended assignment - TheKnown - 19.09.2015

Код:
warning 211: possibly unintended assignment
Код:
CMD:arrest(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
		{
			SendClientMessage(playerid,-1,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
			return 1;
		}
	    new string[128];
    	if(GetPlayerClass[playerid] == COP_CLASS || GetPlayerClass[playerid] == ARMY_CLASS)
    	{
        	if(GetPlayerWantedLevel(i) >= 3)
        	{
        	    if(Cuffed[i] = 1)
        	    {
        	        if(sscanf(params,"ud", i)) return SendClientMessage(playerid, -1,"USAGE: /arrest [player id]");
            		GivePlayerMoney(playerid, 3000);
			  		SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
			  		Jailed[i] = 1;
			  		JailTime[i] = 60;
			  		Cuffed[i] = 0;
			  		SetPlayerSpecialAction(i, 0);
			  		RemovePlayerAttachedObject(i, i);
			  		SetPlayerVirtualWorld(i, 10);
					SetPlayerFacingAngle(i, 360.0);
			  		SetPlayerInterior(i, 3);
			  		SetPlayerPos(i, 197.5662, 175.4800, 1004.0);
			  		SetPlayerWantedLevel(i, 0);
			  		SetPlayerHealth(i,99999);
			  		ResetPlayerWeapons(i);
			  		format(string,sizeof(string),"Police Officer %s(%d) Has arrested wanted suspect %s(%d).",GetNamee(playerid),playerid,GetNamee(i),i);
			  		SendClientMessageToAll(COLOR_ORANGE,string);
			  		return 1;
			  	}
			  	else
			  	{
	  	 			SendClientMessage(playerid, -1, "You Can't Cuff Innocents!");
			  	}
			}
    	}
   }
	return 1;
}
Код:
line: if(Cuffed[i] = 1)



Re: possibly unintended assignment - Emmet_ - 19.09.2015

Change it to:

pawn Код:
if(Cuffed[i])



Re: [FIXED][DELTE THIS THREAD]possibly unintended assignment - khRamin78 - 19.09.2015

if(Cuffed[i] = 1) To if(Cuffed[i] == 1)

PHP код:
CMD:arrest(playeridparams[])
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
        {
            
SendClientMessage(playerid,-1,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
            return 
1;
        }
        new 
string[128];
        if(
GetPlayerClass[playerid] == COP_CLASS || GetPlayerClass[playerid] == ARMY_CLASS)
        {
            if(
GetPlayerWantedLevel(i) >= 3)
            {
                if(
Cuffed[i] == 1)
                {
                    if(
sscanf(params,"ud"i)) return SendClientMessage(playerid, -1,"USAGE: /arrest [player id]");
                    
GivePlayerMoney(playerid3000);
                      
SetPlayerScore(playeridGetPlayerScore(playerid)+1);
                      
Jailed[i] = 1;
                      
JailTime[i] = 60;
                      
Cuffed[i] = 0;
                      
SetPlayerSpecialAction(i0);
                      
RemovePlayerAttachedObject(ii);
                      
SetPlayerVirtualWorld(i10);
                    
SetPlayerFacingAngle(i360.0);
                      
SetPlayerInterior(i3);
                      
SetPlayerPos(i197.5662175.48001004.0);
                      
SetPlayerWantedLevel(i0);
                      
SetPlayerHealth(i,99999);
                      
ResetPlayerWeapons(i);
                      
format(string,sizeof(string),"Police Officer %s(%d) Has arrested wanted suspect %s(%d).",GetNamee(playerid),playerid,GetNamee(i),i);
                      
SendClientMessageToAll(COLOR_ORANGE,string);
                      return 
1;
                  }
                  else
                  {
                       
SendClientMessage(playerid, -1"You Can't Cuff Innocents!");
                  }
            }
        }
   }
    return 
1;