SA-MP Forums Archive
Else statement problem. - 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: Else statement problem. (/showthread.php?tid=660565)



Else statement problem. - Longover - 06.11.2018

HI!

The problem is:
When i type the key_submission (2), i give the message "No suspects in range." even if is a suspect with 3 wanted near at me,how to solve it?

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



Re: Else statement problem. - PawnFox - 06.11.2018

Try this, not sure if works but you could try.

https://pastebin.com/3fgadv9N