Why unknown command?
#1

Hey guyz ,
for this two commands it says unknown command :
Код:
if (strcmp("/yes", cmdtext, true, 10) == 0)
{
if(porter[player[playerid]] == -1)
{
SendClientMessage(player[playerid],0xFFFFFFFF,"[ERROR]There is noone who wants to teleport to you!");
}
else{
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s (ID:%i) has accepted your teleport inquiry.", name,playerid);
SendClientMessage(porter[playerid],0xFFFFFFFF,string);
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
if(IsPlayerInAnyVehicle(player[playerid])){
SetVehiclePos(GetPlayerVehicleID(player[playerid]),x+5,y,z+2);
}else{
SetPlayerPos(player[playerid],x+3,y,z+2);
}
}
porter[playerid] = -1;
}
return 1;
}
if(!strcmp(cmdtext,"/cancel",true,9))
{
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s (ID:%i) has canceled the teleport inquiry.", name,playerid);
SendClientMessage(porter[playerid],0xFFFFFFFF,string);
porter[playerid] = -1;
player[porter[playerid]] = -1;
return 1;
}
but all my other commands work!
Reply
#2

Maybe you forgot a return 0;
Reply
#3

Quote:
Originally Posted by cοοp
Maybe you forgot a return 0;
the only return 0; is at the end of OnPlayerCommand
Reply
#4

Then try to remove the bracket after "SetPlayerPos(player[playerid],x+3,y,z+2);".

Like this:

pawn Код:
if (strcmp("/yes", cmdtext, true, 10) == 0)
{
if(porter[player[playerid]] == -1)
{
SendClientMessage(player[playerid],0xFFFFFFFF,"[ERROR]There is noone who wants to teleport to you!");
}
else
{
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s (ID:%i) has accepted your teleport inquiry.", name,playerid);
SendClientMessage(porter[playerid],0xFFFFFFFF,string);
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
if(IsPlayerInAnyVehicle(player[playerid])){
SetVehiclePos(GetPlayerVehicleID(player[playerid]),x+5,y,z+2);
}
else
{
SetPlayerPos(player[playerid],x+3,y,z+2);
}
porter[playerid] = -1;
}
return 1;
}
pawn Код:
if(!strcmp(cmdtext,"/cancel",true,9))
{
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s (ID:%i) has canceled the teleport inquiry.", name,playerid);
SendClientMessage(porter[playerid],0xFFFFFFFF,string);
porter[playerid] = -1;
player[porter[playerid]] = -1;
return 1;
}


EDIT: Another suggestion for "/yes":

pawn Код:
if (strcmp("/yes", cmdtext, true, 10) == 0)
{
if(porter[player[playerid]] == -1)
{
SendClientMessage(player[playerid],0xFFFFFFFF,"[ERROR]There is noone who wants to teleport to you!");
}
else
{
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s (ID:%i) has accepted your teleport inquiry.", name,playerid);
SendClientMessage(porter[playerid],0xFFFFFFFF,string);
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
if(IsPlayerInAnyVehicle(player[playerid])){
SetVehiclePos(GetPlayerVehicleID(player[playerid]),x+5,y,z+2);
}
else
{
SetPlayerPos(player[playerid],x+3,y,z+2);
}
porter[playerid] = -1;
return 1;
}
Reply
#5

hhhmm both dont work and i canґt remove the bracket ... the commands worked untill i added 2 dcmdґs...should i post them?
Reply
#6

Quote:
Originally Posted by SEC
should i post them?
Yes. That could maybe be the solution of this problem...
Reply
#7

pawn Код:
if(!strcmp(cmdtext, "/yes", true))
Reply
#8

Код:
dcmd_register(playerid,params[])
{
  if (PlayeridLogged[playerid]) return SendClientMessage(playerid,0xFFFFFFFF,"[ERROR]You are already logged in"); //If the player is already logged in
  if (AccountExists(PlayerName(playerid))) return SendClientMessage(playerid,0xFFFFFFFF,"[ERROR]Account already exists, please use '/login password'.");//If account already exists
  if (strlen(params)==0) return SendClientMessage(playerid,0xFFFFFFFF,"[ERROR]USAGE:/register password");//If no password was specified
  if (AccountCreate(PlayerName(playerid),params))//We create the account with the password specified by the player
    {
      GivePlayerMoney(playerid,300); //we give the player some bonus money
      AccountSetInt(PlayerName(playerid),"money",300);//we save the player's money
      AccountSetFloat(PlayerName(playerid),"X",1674);//We save the player's position (default)
      AccountSetFloat(PlayerName(playerid),"Y",1447);
      AccountSetFloat(PlayerName(playerid),"Z",11);
      AccountSetFloat(PlayerName(playerid),"IP",11);
      new string[200];
  		format(string, 100, "> You succesfully registered the nickname %s with password %s", PlayerName(playerid), params);
  		SendClientMessage(playerid,0xFFFFFFFF,string);
  		new Hour, Minute, Second;
			gettime(Hour, Minute, Second);
			new string2[200];
  		format(string2, sizeof(string2), "[%02d:%02d:%02d] %s has registered with password %s ",Hour,Minute,Second, PlayerName(playerid), params);
  		printf(string2);
			return SendClientMessage(playerid,0xFFFFFFFF,"Login with '/login password' now.");
		}
  return true;
}
dcmd_login(playerid,params[])
{
  if (PlayeridLogged[playerid]) return SendClientMessage(playerid,0xFFFFFFFF," You are already logged in");//If the player is already logged in
  if (!AccountExists(PlayerName(playerid))) return SendClientMessage(playerid,0xFFFFFFFF,"> Account does not exist, please use '/register password'.");//If the account does not exist
  if (strlen(params)==0) return SendClientMessage(playerid,0xFFFFFFFF,"[ERROR]USAGE: /login password");//If no password was specified
  if (AccountCheckLogin(PlayerName(playerid),params))//we verify if the login was correct
	{
    PlayeridLogged[playerid] = 1;
    GivePlayerMoney(playerid,AccountGetInt(PlayerName(playerid),"money"));//we give the player's money from when he last disconected
	  return SendClientMessage(playerid,0xFFFFFFFF,"Successfully logged in!");
  }
  return SendClientMessage(playerid,0xFFFFFFFF,"[ERROR]Login failed!");
}
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(register, 8, cmdtext);
dcmd(login, 5, cmdtext);
return 0;
}
(Iґm using this include http://forum.sa-mp.com/index.php?topic=84762.0 )


Reply
#9

Quote:
Originally Posted by [_PGB_
Spatrik ]
pawn Код:
if(!strcmp(cmdtext, "/yes", true))
does not work too
Reply
#10

pawn Код:
if(!strcmp(cmdtext, "/yes", true == 0))
pawn Код:
if(!strcmp(cmdtext, "/cancel", true == 0))

Just some suggestions. I think that your problem maybe is that include that you've downloaded. Try to ask in the include's thread to find a solution.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)