SERVER: Unknown Command
#1

I have two commands on the top of my OnPlayerCommandText which work perfectly in game, and have no errors, but in-game they do what they are supposed to do but SERVER: Unknown Command comes up.

This is the commands:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(busy[playerid] == 1) return SendClientMessage(playerid,0xAA3333AA,"You cannot use that command here");
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/dm1", true) == 0)
    {
    new rand = random(sizeof(RandomSpawn));
    new pname[MAX_PLAYER_NAME], string[40 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    busy[playerid] = 1;
    format(string, sizeof(string), "** %s has entered a DM arena using /dm1", pname);
    SendClientMessageToAll(0xFF9400FF, string);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 27, 500);
    GivePlayerWeapon(playerid, 24, 500);
    GivePlayerWeapon(playerid, 16, 5);
    }
    if(strcmp(cmd, "/brawl", true) == 0)
    {
    new pname[MAX_PLAYER_NAME], string[40 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    SetPlayerPos(playerid, -179.8903,1883.0837,115.7031);
    busy[playerid] = 1;
    format(string, sizeof(string), "** %s has used /brawl to go into the brawling area", pname);
    SendClientMessageToAll(0xFF9400FF, string);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 5, 1);
    }
Reply
#2

if thats your only cmd it should be
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(busy[playerid] == 1) return SendClientMessage(playerid,0xAA3333AA,"You cannot use that command here");
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/dm1", true) == 0)
    {
    new rand = random(sizeof(RandomSpawn));
    new pname[MAX_PLAYER_NAME], string[40 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    busy[playerid] = 1;
    format(string, sizeof(string), "** %s has entered a DM arena using /dm1", pname);
    SendClientMessageToAll(0xFF9400FF, string);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 27, 500);
    GivePlayerWeapon(playerid, 24, 500);
    GivePlayerWeapon(playerid, 16, 5);
    }
    if(strcmp(cmd, "/brawl", true) == 0)
    {
    new pname[MAX_PLAYER_NAME], string[40 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    SetPlayerPos(playerid, -179.8903,1883.0837,115.7031);
    busy[playerid] = 1;
    format(string, sizeof(string), "** %s has used /brawl to go into the brawling area", pname);
    SendClientMessageToAll(0xFF9400FF, string);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 5, 1);
    return 1;
    }
Reply
#3

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(busy[playerid] == 1) return SendClientMessage(playerid,0xAA3333AA,"You cannot use that command here");
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/dm1", true) == 0)
    {
    new rand = random(sizeof(RandomSpawn));
    new pname[MAX_PLAYER_NAME], string[40 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    busy[playerid] = 1;
    format(string, sizeof(string), "** %s has entered a DM arena using /dm1", pname);
    SendClientMessageToAll(0xFF9400FF, string);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 27, 500);
    GivePlayerWeapon(playerid, 24, 500);
    GivePlayerWeapon(playerid, 16, 5);
    return 1;
    }
    if(strcmp(cmd, "/brawl", true) == 0)
    {
    new pname[MAX_PLAYER_NAME], string[40 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    SetPlayerPos(playerid, -179.8903,1883.0837,115.7031);
    busy[playerid] = 1;
    format(string, sizeof(string), "** %s has used /brawl to go into the brawling area", pname);
    SendClientMessageToAll(0xFF9400FF, string);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 5, 1);
    return 1;
}
return SendClientMessage(playerid,0x0,"SERVER:Invalid Command");
}
You need to use returns..

You need to return 1; ...return 0; or nothing
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)