if(strcmp(cmdtext, "/eat", true)==0) { for(new x; x<places; x++) { if(IsPlayerInRangeOfPoint(playerid, 2.0,PlesI[x][EnterPos][0],PlesI[x][EnterPos][1d],PlesI[x][EnterPos][2])) { new msg[1200]; format(msg,sizeof(msg),"{0099FF}[>>]{FFFFFF} %s text!",PlesI[x][vietospav]); SetPlayerMapIcon(playerid, 73, PlesI[x][EnterPos][0],PlesI[x][EnterPos][1],PlesI[x][EnterPos][2], 6, 0, MAPICON_GLOBAL); } } return 1; }
if(strcmp(cmdtext, "/eat", true)==0)
{
for(new x; x<places; x++)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0,PlesI[x][EnterPos][0],PlesI[x][EnterPos][1d],PlesI[x][EnterPos][2]))
{
new msg[1200];
format(msg,sizeof(msg),"{0099FF}[>>]{FFFFFF} %s text!",PlesI[x][vietospav]);
SetPlayerMapIcon(playerid, 73, PlesI[x][EnterPos][0],PlesI[x][EnterPos][1],PlesI[x][EnterPos][2], 6, 0, MAPICON_GLOBAL);
}
else return SendClientMessage(playerid, 0xFFFFFF, "You're not in the correct place");
}
return 1;
}
new msg[1200];
for (new x; x < sizeof PlesI; x++)
PlesI[x][EnterPos][1d]
To understand what I've done.. I returned a client message to the player if he's not in the right place instead of returning 0, because returning 0 causes that the server sends you the unknown command error.
|
Which is wrong because unless the loop is finished, you cannot know whether a player is in range or not. He does not return 0 either, but a run time error inside a command will break the code execution and no value will be returned (which will show the unknown command).
|