SA-MP Forums Archive
Unknown Commands? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Unknown Commands? (/showthread.php?tid=99707)



Unknown Commands? - [NYRP]Mike. - 29.09.2009

Well at Advanced Gaming, we are currently creating a new type of Gamemode, as i added a couple of commands i went ingame to test them, but all i get is 'Unknown Command' heres my OnPlayerCommandText

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{

    if (strcmp("/test", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, 3354.339844, -2152.024902, 705.970459);
        SetPlayerInterior(playerid, 0);
        FreezePlayer(playerid, 2000);
        return 1;
    }

    if (strcmp("/objective", cmdtext, true, 10) == 0)
    {
        if(TEAM_COP[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_YELLOW, " You are a Cop ");
            SendClientMessage(playerid, COLOR_YELLOW, " Your objective is to guard the prisoners ");
            SendClientMessage(playerid, COLOR_YELLOW, " And stop the from escaping at all means! ");
            SendClientMessage(playerid, COLOR_YELLOW, " You can gain weapons + Ammo at the store room");
            SendClientMessage(playerid, COLOR_YELLOW, " For help type /help");
            return 1;
        }
        if (strcmp("/opensec", cmdtext, true, 10) == 0)
        {
        if(PlayerToPoint(2.0,playerid,2651.119873, -2745.723877, 4.287249))
        if(TEAM_COP[playerid] == 1)
            {
                SetObjectRot(Sec, 0.0000, 0.0000, 18.9076);
            }
            return 1;
        }
        if (strcmp("/closesec", cmdtext, true, 10) == 0)
        {
            if(PlayerToPoint(2.0,playerid,2651.119873, -2745.723877, 4.287249))
            if(TEAM_COP[playerid] == 1)
            {
                SetObjectRot(Sec, 0.0000, 0.0000, 89.3814);
            }
            return 1;
        }
        if (strcmp("/lockdown", cmdtext, true, 10) == 0)
            {
                if(PlayerToPoint(1.0,playerid,2653.1077,-2742.4539,5.2934))
                if(TEAM_COP[playerid] == 1)
                {
                    MoveObject(LD, 2651.496582, -2745.657959, 6.613323, 2);
                    GameTextForAll("~P~Prison ~R~LOCKDOWN!",500,1);
                    SetTimer("Alarm1", 3500, 1);
                    Locked[playerid] = 1;
                }
                return 1;
        }
    if (strcmp("/lockdownO", cmdtext, true, 10) == 0)
    {
        if(PlayerToPoint(1.0,playerid,2653.1077,-2742.4539,5.2934))
        if(TEAM_COP[playerid] == 1)
        {
            MoveObject(LD, 2640.496582, -2745.657959, 0.713324, 2);
            GameTextForAll("~P~Prison ~R~LOCKDOWN ~P~OVER",500,1);
            Locked[playerid] = 0;
        }
        return 1;
    }
    }
    return 0;
}
Thanks for looking.

-Mike.


Re: Unknown Commands? - silvan - 29.09.2009

change the last " return 0 " to return 1 "


Re: Unknown Commands? - [NYRP]Mike. - 29.09.2009

Thanks, i've done that but now i dont even get 'Unknown Command' it just doesnt do anything.

-Mike.


Re: Unknown Commands? - ded - 29.09.2009

Quote:
Originally Posted by silvan
change the last " return 0 " to return 1 "
No .. that's pointless unless you don't want players to know they have entred a wrong command.

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{

    if (strcmp("/test", cmdtext, true) == 0)
    {
        SetPlayerPos(playerid, 3354.339844, -2152.024902, 705.970459);
        SetPlayerInterior(playerid, 0);
        FreezePlayer(playerid, 2000);
        return 1;
    }

    if (strcmp("/objective", cmdtext, true) == 0)
    {
        if(TEAM_COP[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_YELLOW, " You are a Cop ");
            SendClientMessage(playerid, COLOR_YELLOW, " Your objective is to guard the prisoners ");
            SendClientMessage(playerid, COLOR_YELLOW, " And stop the from escaping at all means! ");
            SendClientMessage(playerid, COLOR_YELLOW, " You can gain weapons + Ammo at the store room");
            SendClientMessage(playerid, COLOR_YELLOW, " For help type /help");
            return 1;
        }
        if (strcmp("/opensec", cmdtext, true) == 0)
        {
        if(PlayerToPoint(2.0,playerid,2651.119873, -2745.723877, 4.287249))
        if(TEAM_COP[playerid] == 1)
            {
                SetObjectRot(Sec, 0.0000, 0.0000, 18.9076);
            }
            return 1;
        }
        if (strcmp("/closesec", cmdtext, true) == 0)
        {
            if(PlayerToPoint(2.0,playerid,2651.119873, -2745.723877, 4.287249))
            if(TEAM_COP[playerid] == 1)
            {
                SetObjectRot(Sec, 0.0000, 0.0000, 89.3814);
            }
            return 1;
        }
        if (strcmp("/lockdown", cmdtext, true) == 0)
            {
                if(PlayerToPoint(1.0,playerid,2653.1077,-2742.4539,5.2934))
                if(TEAM_COP[playerid] == 1)
                {
                    MoveObject(LD, 2651.496582, -2745.657959, 6.613323, 2);
                    GameTextForAll("~P~Prison ~R~LOCKDOWN!",500,1);
                    SetTimer("Alarm1", 3500, 1);
                    Locked[playerid] = 1;
                }
                return 1;
        }
    if (strcmp("/lockdownO", cmdtext, true) == 0)
    {
        if(PlayerToPoint(1.0,playerid,2653.1077,-2742.4539,5.2934))
        if(TEAM_COP[playerid] == 1)
        {
            MoveObject(LD, 2640.496582, -2745.657959, 0.713324, 2);
            GameTextForAll("~P~Prison ~R~LOCKDOWN ~P~OVER",500,1);
            Locked[playerid] = 0;
        }
        return 1;
    }
    }
    return 0;
}
Try that.


Re: Unknown Commands? - Peter_Corneile - 29.09.2009

Every command should have a return 1; or it will work but still show the Unkown Command thing .. And a return 0; is needed at the last of OnPlayerCommandText


Re: Unknown Commands? - agusfn20 - 29.09.2009

try this
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{

    if (strcmp("/test", cmdtext, true) == 0)
    {
        SetPlayerPos(playerid, 3354.339844, -2152.024902, 705.970459);
        SetPlayerInterior(playerid, 0);
        FreezePlayer(playerid, 2000);
        return 1;
    }

    if (strcmp("/objective", cmdtext, true) == 0)
    {
        if(TEAM_COP[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_YELLOW, " You are a Cop ");
            SendClientMessage(playerid, COLOR_YELLOW, " Your objective is to guard the prisoners ");
            SendClientMessage(playerid, COLOR_YELLOW, " And stop the from escaping at all means! ");
            SendClientMessage(playerid, COLOR_YELLOW, " You can gain weapons + Ammo at the store room");
            SendClientMessage(playerid, COLOR_YELLOW, " For help type /help");
        }
        return 1;
    }

    if (strcmp("/opensec", cmdtext, true) == 0)
    {
        if(PlayerToPoint(2.0,playerid,2651.119873, -2745.723877, 4.287249))
        {
            if(TEAM_COP[playerid] == 1)
            {
                SetObjectRot(Sec, 0.0000, 0.0000, 18.9076);
            }
        }
        return 1;
    }

    if (strcmp("/closesec", cmdtext, true) == 0)
    {
        if(PlayerToPoint(2.0,playerid,2651.119873, -2745.723877, 4.287249))
        {
            if(TEAM_COP[playerid] == 1)
            {
                SetObjectRot(Sec, 0.0000, 0.0000, 89.3814);
            }
        }
        return 1;
    }

    if (strcmp("/lockdown", cmdtext, true) == 0)
    {
        if(PlayerToPoint(1.0,playerid,2653.1077,-2742.4539,5.2934))
        {
            if(TEAM_COP[playerid] == 1)
            {
                MoveObject(LD, 2651.496582, -2745.657959, 6.613323, 2);
                GameTextForAll("~P~Prison ~R~LOCKDOWN!",500,1);
                SetTimer("Alarm1", 3500, 1);
                Locked[playerid] = 1;
            }
        }
        return 1;
    }
   
    if (strcmp("/lockdownO", cmdtext, true) == 0)
    {
        if(PlayerToPoint(1.0,playerid,2653.1077,-2742.4539,5.2934))
        {
            if(TEAM_COP[playerid] == 1)
            {
                MoveObject(LD, 2640.496582, -2745.657959, 0.713324, 2);
                GameTextForAll("~P~Prison ~R~LOCKDOWN ~P~OVER",500,1);
                Locked[playerid] = 0;
            }
        }
        return 1;
    }
   
    return 0;
}