PDA

View Full Version : Unknown command problem


,TomY'
25/06/2018, 05:49 PM
Hi. Have problem with command. When I use my command in right place - command working correct. But when I use command in random place, where player is not in range of point, server says my: Unknown command. How to make, that if I use that command in random place, server would not write unknown command, just nothing.

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;
}

JasonRiggs
25/06/2018, 06:26 PM
Change ur code into this..

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;
}

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.

Lokii
25/06/2018, 06:43 PM
WOW


new msg[1200];


isnt 40-50 enough

Calisthenics
25/06/2018, 06:51 PM
The value of "place" is probably greater than the size of the PlesI array. Change to:

for (new x; x < sizeof PlesI; x++)


Also what is this?

PlesI[x][EnterPos][1d]

It was supposed to be [1], not sure how it was even compiled.


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).

JasonRiggs
25/06/2018, 06:59 PM
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).

Well as far as I'm concerned that since the player isn't in range of the point, then there is no success, and no success means 0 returning, idk maybe you might be right, but that's my point.

,TomY'
25/06/2018, 08:17 PM
Calisthenics really helps me. Thanks man!