No suspects in range.
#1

HI!

I have a problem with my gm,when i press '2' (key submission) i give the error "No suspects in range" but i have a suspect at 2 meters from me.
Why?

Code:
if((newkeys == KEY_SUBMISSION) && isLEO(playerid))
    {
        foreach(new i : Player)
        {
            new msg[100];
            if(GetDistanceBetweenPlayers(playerid, i) < 7.0 && Player[i][playerWanted] < 6 && Player[i][playerWanted] != 0)
            {
                format(msg, 100, "/ticket %d", i);
            	return OnPlayerCommandReceived(playerid, msg);
			}
			if(GetDistanceBetweenPlayers(playerid, i) < 7.0 && Player[i][playerWanted] > 5)
			{
			    format(msg, 100, "/arrest %d", i);
			    return OnPlayerCommandReceived(playerid, msg);
			}
			else
			{
				SendClientMessage(playerid, COLOR_RED, "No supects in range.");
				return 1;
			}
        }
    }
Reply
#2

If it's more than 5 and less than 6 what's it's gonna be then?

Code:
Player[i][playerWanted] < 6

Player[i][playerWanted] > 5
That's never gonna work.
Reply
#3

Quote:
Originally Posted by Cypress
View Post
If it's more than 5 and less than 6 what's it's gonna be then?

Code:
Player[i][playerWanted] < 6

Player[i][playerWanted] > 5
That's never gonna work.
is:

Code:
Player[i][playerWanted] < 6 && Player[i][playerWanted] != 0
It can be 0.
Reply
#4

Quote:
Originally Posted by Longover
View Post
is:

Code:
Player[i][playerWanted] < 6 && Player[i][playerWanted] != 0
It can be 0.
But how to solve?
Reply
#5

Quote:
Originally Posted by Longover
View Post
But how to solve?
modify your query to have common sense.
Reply
#6

PHP Code:
if((newkeys KEY_SUBMISSION/*&& isLEO(playerid)*/// You don't check for a key using == but &, also you should have posted your IsLEO code as well
    
{
        foreach(new 
Player)
        {
            new 
msg[16], FloatDistance// msg[100], you allocate 100 cells for a command of less than 12 cells
            
Distance GetDistanceBetweenPlayers(playeridi); // should have posted this function's code too, maybe there is something wrong there?
            // Are you sure the players who were you talking about had playerWanted > 0?
            
printf("Playerid %d has playerWanted variable to %d"iPlayer[i][playerWanted]); // Debug to check for it
            
if(Distance 7.0 && Player[i][playerWanted] <= && Player[i][playerWanted] != 0
            {
                
format(msg100"/ticket %d"i);
                
// DEBUG
                
printf("Trying to ticket playerid %d"i);
                return 
OnPlayerCommandReceived(playeridmsg); // I don't really know if this correctly sends a command to zcmd
            
}
            if(
Distance 7.0 && Player[i][playerWanted] > 5)
            {
                
format(msg100"/arrest %d"i);
                
// DEBUG
                
printf("Trying to arrest playerid %d"i); 
                return 
OnPlayerCommandReceived(playeridmsg);
            }
            else
            {
                
SendClientMessage(playeridCOLOR_RED"No supects in range.");
                return 
1;
            }
        }
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)