sit and lay command
#1

Hello everyone.
What's wrong with these two commands?

When I use them in my server, I type /sit or /lay and it tells me to do /sit [1-4] or /lay [1-9].
So I will then type /sit1 or /sit 1 and it will say Unknown Command.

So is there something wrong with these commands?

pawn Код:
// Animations
new BackOut[MAX_PLAYERS];
new animation[200];
new gPlayerUsingLoopingAnim[MAX_PLAYERS];
pawn Код:
BackAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp,animback)
{
    BackOut[playerid] = animback;
    ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
    animation[playerid]++;
}
LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
{
    gPlayerUsingLoopingAnim[playerid] = 1;
    ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
    animation[playerid]++;
}
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmd, "/sit", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) { return 1; }
        if (!strlen(cmdtext[5])) return SendClientMessage(playerid,COLOR_USAGE,"TIP: /sit [1-4]");
        switch (cmdtext[5])
        {
            case '1': BackAnim(playerid,"PED","SEAT_down",4.1,0,1,1,1,0,8);
            case '2': LoopingAnim(playerid,"MISC","seat_lr",2.0,1,0,0,0,0);
            case '3': LoopingAnim(playerid,"MISC","seat_talk_01",2.0,1,0,0,0,0);
            case '4': LoopingAnim(playerid,"MISC","seat_talk_02",2.0,1,0,0,0,0);
            default: SendClientMessage(playerid,COLOR_USAGE,"TIP: /sit [1-4]");
        }
        return 1;
    }
if(strcmp(cmd, "/lay", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) { return 1; }
        if (!strlen(cmdtext[5])) return SendClientMessage(playerid,COLOR_USAGE,"TIP: /lay [1-9]");
        switch (cmdtext[5])
        {
            case '1': LoopingAnim(playerid,"BEACH", "bather", 4.0, 1, 0, 0, 0, 0);
            case '2': LoopingAnim(playerid,"BEACH", "parksit_w_loop", 4.0, 1, 0, 0, 0, 0);
            case '3': LoopingAnim(playerid,"BEACH","parksit_m_loop", 4.0, 1, 0, 0, 0, 0);
            case '4': LoopingAnim(playerid,"BEACH","lay_bac_loop", 4.0, 1, 0, 0, 0, 0);
            case '5': LoopingAnim(playerid,"BEACH","sitnwait_loop_w", 4.0, 1, 0, 0, 0, 0);
            case '6': BackAnim(playerid,"SUNBATHE","Lay_Bac_in",3.0,0,1,1,1,0,5);
            case '7': LoopingAnim(playerid,"SUNBATHE","batherdown",3.0,0,1,1,1,0);
            case '8': BackAnim(playerid,"SUNBATHE","parksit_m_in",3.0,0,1,1,1,0,1);
            case '9': LoopingAnim(playerid,"CAR", "Fixn_Car_Loop", 4.0, 1, 0, 0, 0, 0);
            default: SendClientMessage(playerid,COLOR_USAGE,"TIP: /lay [1-9]");
        }
        return 1;
    }
        return 0;
}
Reply
#2

Код:
cmdtext[]	The command that was executed (including the slash).
It doesn't just return 1, 2, 3, 4 etc. you'll have to use strtok.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)