Its the "else"
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 5.0, Meslek[i][meslekX], Meslek[i][meslekY], Meslek[i][meslekZ]))
{
//...
} else return Hata(playerid, "There isn't a job near you.");
As soon as the first range check fails, it returns and the function ends.
Put the message and the return after the for-loop, and instead return when a job was found, so the "There isn't a job near you." message is only shown when the whole loop failed.
pawn Код:
YCMD:yakin(playerid, params[], help)
{
new sMeslek[128+1];
for(new i = 0; i < MAKSIMUM_MESLEK; i++) // Meslek ID - Job ID
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, Meslek[i][meslekX], Meslek[i][meslekY], Meslek[i][meslekZ]))
{
format(sMeslek, sizeof(sMeslek), "Nearest job's SQLID: %d", Meslek[i][meslekID]);
SendClientMessage(playerid, -1, sMeslek);
return 1; // Stop the loop, no more need to check other jobs
}
}
// Loop finished, no job found
Hata(playerid, "There isn't a job near you.");
return 1;
}