Unknown command problem
#1

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;
 }
Reply
#2

Change ur code into this..

PHP код:
     if(strcmp(cmdtext"/eat"true)==0)
    {
    for(new 
xx<placesx++) 
    {
    if(
IsPlayerInRangeOfPoint(playerid2.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(playerid73PlesI[x][EnterPos][0],PlesI[x][EnterPos][1],PlesI[x][EnterPos][2], 60MAPICON_GLOBAL);
     }
        else return 
SendClientMessage(playerid0xFFFFFF"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.
Reply
#3

WOW

Код:
new msg[1200];
isnt 40-50 enough
Reply
#4

The value of "place" is probably greater than the size of the PlesI array. Change to:
pawn Код:
for (new x; x < sizeof PlesI; x++)
Also what is this?
pawn Код:
PlesI[x][EnterPos][1d]
It was supposed to be [1], not sure how it was even compiled.

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
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).
Reply
#5

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
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.
Reply
#6

Calisthenics really helps me. Thanks man!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)