"SERVER: Unknown command." -
daimon567 - 09.08.2012
Right, so I've read through some threads on the forums about this topic, but I still haven't found an answer.. Here's the script..
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kill", cmdtext, true, 5) == 0)
{
SetPlayerHealth (playerid, 0);
SendClientMessage (playerid, 0x4D34B3FF, "You have killed yourself, idiot.");
return 1;
}
Doesn't matter what I do, I just keep on getting no message. I've scripted some more commands, and they all have the same problem, or they just say "SERVER: Unknown Command.". I'm a rookie in scripting, and I'm just playing around. I just don't get what I'm doing wrong. Since the rest of my "commands" gets the same message, I'm clueless on what I'm doing wrong. I could post another "command" later on, if needed.. Please help me!
Re: "SERVER: Unknown command." -
phillip875 - 09.08.2012
pawn Код:
format (string, sizeof(string), "There are currently %d players online.", playersconnected;
You are forgetting a );
Re: "SERVER: Unknown command." -
daimon567 - 09.08.2012
Sorry, wrong code.. EDITED.
Re: "SERVER: Unknown command." -
daimon567 - 09.08.2012
But thanks for noticing that, helped!
Re: "SERVER: Unknown command." -
phillip875 - 09.08.2012
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth (playerid, 0);
SendClientMessage (playerid, 0x4D34B3FF, "You have killed yourself, idiot.");
return 1;
}
return 1;
}
Try that.
Re: "SERVER: Unknown command." -
Dubya - 09.08.2012
ok well.. ZCMD is better.
Re: "SERVER: Unknown command." -
FalconX - 09.08.2012
Quote:
Originally Posted by Dubya
ok well.. ZCMD is better.
|
True;
phillip875: The OnPlayerCommandText callback returns 0 not 1;
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth (playerid, 0);
SendClientMessage (playerid, 0x4D34B3FF, "You have killed yourself, idiot.");
return 1;
}
return 0;// it should be 0 not 1..
// Returning 0 informs the server that the command hasn't been processed by this script.
// OnPlayerCommandText will be called in other scripts until one returns 1.
// If no scripts return 1, the 'SERVER: Unknown Command' message will be shown.
}
Wiki:
https://sampwiki.blast.hk/wiki/OnPlayerCommandText
Regards,
FalconX
Re: "SERVER: Unknown command." -
daimon567 - 09.08.2012
Quote:
Originally Posted by phillip875
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp("/kill", cmdtext, true, 10) == 0) { SetPlayerHealth (playerid, 0); SendClientMessage (playerid, 0x4D34B3FF, "You have killed yourself, idiot."); return 1; } return 1; }
Try that.
|
Tried it, I still get no message when I use /kill. :/
Quote:
Originally Posted by FalconX
True;
phillip875: The OnPlayerCommandText callback returns 0 not 1;
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp("/kill", cmdtext, true, 10) == 0) { SetPlayerHealth (playerid, 0); SendClientMessage (playerid, 0x4D34B3FF, "You have killed yourself, idiot."); return 1; } return 0;// it should be 0 not 1.. // Returning 0 informs the server that the command hasn't been processed by this script. // OnPlayerCommandText will be called in other scripts until one returns 1. // If no scripts return 1, the 'SERVER: Unknown Command' message will be shown. }
Wiki: https://sampwiki.blast.hk/wiki/OnPlayerCommandText
Regards,
FalconX
|
Tried that too, same result.
Re: "SERVER: Unknown command." -
FalconX - 09.08.2012
Quote:
Originally Posted by daimon567
Tried it, I still get no message when I use /kill. :/
Tried that too, same result.
|
Hmm, are you using ZCMD with it or other command processor? if yes then you will have to use one ZCMD or STRCMP based command processor.
Or I think you should try by removing all the filterscripts and then see if the commands working, if they works when you unload all of them then you have to check the OnPlayerCommandText callback in them.
Re: "SERVER: Unknown command." -
daimon567 - 10.08.2012
Quote:
Originally Posted by FalconX
Hmm, are you using ZCMD with it or other command processor? if yes then you will have to use one ZCMD or STRCMP based command processor.
Or I think you should try by removing all the filterscripts and then see if the commands working, if they works when you unload all of them then you have to check the OnPlayerCommandText callback in them.
|
Nope, I'm only using Pawno when I'm scripting. I tried removing all the filterscripts and try it out, but I still get the same result. When I use "/kill", I get no message at all, but I die. When I try "/heal", which is basicly the same type of command, but with a "SendPlayerMessage" after it, which should say "You've healed yourself.". But it just says "SERVER: Unknown Command." I don't get healed by it either.
Do I do something wrong when I save the PWN file?; I save the PWN in "gamemodes", as "test" and I've set the "gamemode0" to "test" in the "Server.CFG" to make the server use the "test" on startup.
As I said, I'm pretty much as newbie as you can get on scripting, and it would not suprise me if I save it wrongfully..
Re: "SERVER: Unknown command." -
grand.Theft.Otto - 10.08.2012
Use ZCMD / DCMD or YCMD and all your problems shall be solved.
Re: "SERVER: Unknown command." -
daimon567 - 10.08.2012
Will try it out