SA-MP Forums Archive
Server Unknown Command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Server Unknown Command (/showthread.php?tid=436228)



Server Unknown Command - Stefand - 10.05.2013

Hey,

When I type this command:

pawn Код:
command(hangup, playerid, params[])
{
    new string[128];
    Player[playerid][OnPhoneTime] = 0;
    SCM(playerid, PHONECOLOR, "***BEEP BEEP BEEP***");
    SCM(Player[playerid][CellphoneConsole], PHONECOLOR, "***BEEP BEEP BEEP***");
    Player[Player[playerid][CellphoneConsole]][OnPhoneTime] = 0;
    format(string, sizeof(string), "* %s puts %s cellphone back into %s pocket.", RPName(playerid), SexGender(playerid), SexGender(playerid));
    NearByMessage(playerid, NICESKY, string);
    format(string, sizeof(string), "* %s puts %s cellphone back into %s pocket.", RPName(Player[playerid][CellphoneConsole]), SexGender(Player[playerid][CellphoneConsole]), SexGender(Player[playerid][CellphoneConsole]));
    NearByMessage(Player[playerid][CellphoneConsole], NICESKY, string);
    if(GetPlayerSpecialAction(Player[playerid][CellphoneConsole]) == SPECIAL_ACTION_USECELLPHONE)
    {
        SetPlayerSpecialAction(Player[playerid][CellphoneConsole], SPECIAL_ACTION_STOPUSECELLPHONE);
    }

    if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USECELLPHONE)
    {
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
    }

    if(Player[playerid][CellphoneConsole] != -1)
    {
        Player[Player[playerid][CellphoneConsole]][CellphoneConsole] = -1;
        Player[playerid][CellphoneConsole] = -1;
    }

    return 1;
}
I see BEEP BEEP BEEP but it also says Server Unknown command.


Re: Server Unknown Command - IceBilizard - 10.05.2013

Try this
pawn Код:
command:hangup(playerid, params[])
{
    new string[128];
    Player[playerid][OnPhoneTime] = 0;
    SCM(playerid, PHONECOLOR, "***BEEP BEEP BEEP***");
    SCM(Player[playerid][CellphoneConsole], PHONECOLOR, "***BEEP BEEP BEEP***");
    Player[Player[playerid][CellphoneConsole]][OnPhoneTime] = 0;
    format(string, sizeof(string), "* %s puts %s cellphone back into %s pocket.", RPName(playerid), SexGender(playerid), SexGender(playerid));
    NearByMessage(playerid, NICESKY, string);
    format(string, sizeof(string), "* %s puts %s cellphone back into %s pocket.", RPName(Player[playerid][CellphoneConsole]), SexGender(Player[playerid][CellphoneConsole]), SexGender(Player[playerid][CellphoneConsole]));
    NearByMessage(Player[playerid][CellphoneConsole], NICESKY, string);
    if(GetPlayerSpecialAction(Player[playerid][CellphoneConsole]) == SPECIAL_ACTION_USECELLPHONE)
    {
        SetPlayerSpecialAction(Player[playerid][CellphoneConsole], SPECIAL_ACTION_STOPUSECELLPHONE);
    }

    if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USECELLPHONE)
    {
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
    }

    if(Player[playerid][CellphoneConsole] != -1)
    {
        Player[Player[playerid][CellphoneConsole]][CellphoneConsole] = -1;
        Player[playerid][CellphoneConsole] = -1;
    }

    return 1;
}



Re: Server Unknown Command - ryanhawk31 - 10.05.2013

The error is this
pawn Код:
command(hangup, playerid, params[])
you must change the "(" to a ":" in the middle of "command(hangup"


Re: Server Unknown Command - Stefand - 10.05.2013

No, command( is the same as Command: or CMD: its all zcmd

how else it could send BEEP BEEP BEEP?


AW: Server Unknown Command - Blackazur - 10.05.2013

Use this.

COMMAND:hangup(playerid,params[])

this will work.


Re: Server Unknown Command - Stefand - 10.05.2013

My option and yours are all working It works correct the command but it says Unknown Command.
I want to know why does it say that


Re: Server Unknown Command - Pooh7 - 10.05.2013

Some function returns 0 (it's probably NearByMessage) which causes this error to show up. Check that function.


Re: Server Unknown Command - Stefand - 10.05.2013

pawn Код:
public NearByMessage(playerid, colour, string[])
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GetPlayerPos(playerid, PlayerX, PlayerY, PlayerZ);
            if(IsPlayerInRangeOfPoint(i, 12, PlayerX, PlayerY, PlayerZ))
            {
                if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i) && GetPlayerInterior(playerid) == GetPlayerInterior(i))
                {
                    SendClientMessage(i, colour, string);
                }
            }
        }
    }
    return 1;
}
Can't discover a mistake here @ Pooh7


Re: Server Unknown Command - Stefand - 10.05.2013

pawn Код:
command(hangup,playerid, params[])
{
    new string[128];
    printf("Checkpoint 1");
    if(Player[playerid][CellphoneConsole] != -1)
    {
        printf("Checkpoint 2");
        if(Player[playerid][CellphoneConsole] == 911)
        {
            printf("Checkpoint 3.911");
            Player[playerid][OnPhoneTime] = 0;
            printf("Checkpoint 4.911");
            SCM(playerid, PHONECOLOR, "***BEEP BEEP BEEP***");
            printf("Checkpoint 5.911");
            format(string, sizeof(string), "* %s puts %s cellphone back into %s pocket.", RPName(playerid), SexGender(playerid), SexGender(playerid));
            printf("Checkpoint 6.911");
            NearByMessage(playerid, NICESKY, string);
            printf("Checkpoint 7.911");
            if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USECELLPHONE)
            {
                printf("Checkpoint 8.911");
                SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
                printf("Checkpoint 9.911");
            }
            if(Player[playerid][CellphoneConsole] != -1)
            {
                printf("Checkpoint 10.911");
                Player[playerid][CellphoneConsole] = -1;
                printf("Checkpoint 11.911");
            }
        }
        else
        {
            printf("Checkpoint 3");
            Player[playerid][OnPhoneTime] = 0;
            printf("Checkpoint 4");
            SCM(playerid, PHONECOLOR, "***BEEP BEEP BEEP***");
            printf("Checkpoint 5");
            SCM(Player[playerid][CellphoneConsole], PHONECOLOR, "***BEEP BEEP BEEP***");
            printf("Checkpoint 6");
            Player[Player[playerid][CellphoneConsole]][OnPhoneTime] = 0;
            printf("Checkpoint 7");
            format(string, sizeof(string), "* %s puts %s cellphone back into %s pocket.", RPName(playerid), SexGender(playerid), SexGender(playerid));
            printf("Checkpoint 8");
            NearByMessage(playerid, NICESKY, string);
            printf("Checkpoint 9");
            format(string, sizeof(string), "* %s puts %s cellphone back into %s pocket.", RPName(Player[playerid][CellphoneConsole]), SexGender(Player[playerid][CellphoneConsole]), SexGender(Player[playerid][CellphoneConsole]));
            printf("Checkpoint 10");
            NearByMessage(Player[playerid][CellphoneConsole], NICESKY, string);
            printf("Checkpoint 11");
            if(GetPlayerSpecialAction(Player[playerid][CellphoneConsole]) == SPECIAL_ACTION_USECELLPHONE)
            {
                printf("Checkpoint 12");
                SetPlayerSpecialAction(Player[playerid][CellphoneConsole], SPECIAL_ACTION_STOPUSECELLPHONE);
                printf("Checkpoint 13");
            }

            if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USECELLPHONE)
            {
                printf("Checkpoint 14");
                SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
                printf("Checkpoint 15");
            }

            if(Player[playerid][CellphoneConsole] != -1)
            {
                printf("Checkpoint 16");
                Player[Player[playerid][CellphoneConsole]][CellphoneConsole] = -1;
                Player[playerid][CellphoneConsole] = -1;
                printf("Checkpoint 17");
            }
        }
    }
    else
    {
        TextDrawShowForPlayer(playerid, Text:NotCalling);
        SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
        printf("Checkpoint 999");
    }

    return 0;
}
Im not using my phone and did /hangup and I got in my console: Checkpoint 1 & CheckPoint 999.
And still getting unknown command.
What is the problem?


Re: Server Unknown Command - Joe Staff - 10.05.2013

When you're getting unknown command, it's because some how your command is returning '0' to OnPlayerCommandText, which sends the default message.
Change your 'return 0;' to 'return 1;' If you're still getting the message, then you're most likely exceeding an array's index (example: 'new array[50]; array[55]=0;') which causes an error and acts similarly to 'return 0;'