"SERVER: Unknown command."
#1

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(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue5) == 0)
    {
        
SetPlayerHealth (playerid0);
        
SendClientMessage (playerid0x4D34B3FF"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!
Reply
#2

pawn Код:
format (string, sizeof(string), "There are currently %d players online.", playersconnected;
You are forgetting a );
Reply
#3

Sorry, wrong code.. EDITED.
Reply
#4

But thanks for noticing that, helped!
Reply
#5

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.
Reply
#6

ok well.. ZCMD is better.
Reply
#7

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
Reply
#8

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.
Reply
#9

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.
Reply
#10

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..
Reply
#11

Use ZCMD / DCMD or YCMD and all your problems shall be solved.
Reply
#12

Will try it out
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)