ZCMD -> Strcmp
#1

I converted my /mask command from ZCMD + Sscanf to Strcmp because I had to...
Well is this right way to make command in strcmp or is here any mistake?

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mask", cmdtext, true, 5) == 0)
    {
        if(IsPlayerConnected(playerid))
    {
        if(Masked[playerid] == 0)
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    ShowPlayerNameTagForPlayer(i, playerid, 0);
                }
            }
            ApplyAnimation(playerid, "SHOP", "ROB_Shifty", 4.1,0,0,0,0,0); // Anim to avoid bug when Animations doesn't apply
            Masked[playerid] = 1;
            MaskTimer[playerid] = SetTimerEx("MaskAnim", 100, false, "i", playerid); // Timer for Applying animation and triggering another timer
            msk[0] = SetPlayerAttachedObject(playerid, 1, 19037, 5, 0.067999, 0.030000, 0.026000, 105.800018, 87.500038, 30.699975,1.000000,1.000000,1.000000,0,0); // Mask in left hand, so it's looking cool with Animation..
            SendClientMessage(playerid, COLOR_LIGHTGREEN, "ON");
            return 1;
        }
        else if(Masked[playerid] == 1) // If player will write /mask again his mask will be removed
        {
            if(IsPlayerConnected(playerid))
            {
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(playerid))
                    {
                        ShowPlayerNameTagForPlayer(i, playerid, 1); // Showing player's tag for other player
                    }
                }
                Masked[playerid] = 0;
                ClearAnimations(playerid); // To avoid bugging /mask if player spam /mask CMD
                KillTimer(MaskTimer[playerid]); // To avoid bugging /mask if player spam /mask CMD
                KillTimer(MaskTime[playerid]); // Same as above..
                if(IsPlayerAttachedObjectSlotUsed(playerid, 1)) RemovePlayerAttachedObject(playerid, msk[1]); // Removing his mask
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "OFF");
                return 1;
            }
        }
    }
    return 1;
    }
    return 0;
}
also if I'm using ZCMD + SSCANF and some commands are in strcmp, some commands don't work it says UNKNOWN COMMAND... is this because I'm mixing ZCMD and strcmp?
Reply
#2

Makes no sense to me why your going backwards instead of forwards why can you use ZCMD ?
Reply
#3

Quote:
Originally Posted by Lajko1
Посмотреть сообщение
also if I'm using ZCMD + SSCANF and some commands are in strcmp, some commands don't work it says UNKNOWN COMMAND... is this because I'm mixing ZCMD and strcmp?
Why don't you convert all of your commands to ZCMD ?
Reply
#4

Well I know ZCMD is better but I have request to make this cmd in strcmp ... so any answer on topic please :P
Reply
#5

When you use zcmd, the callback OnPlayerCommandText is not automatically called anymore, so you have to manually implement some code to call it when the command typed is not in zcmd. For this, you need to use the callback OnPlayerCommandPerformed that belongs to zcmd:

pawn Код:
#include <zcmd>

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
        return OnPlayerCommandText(playerid, cmdtext);
    }
    return 1;
}
Reply
#6

It's easier to convert strcmp to zcmd than zcmd to strcmp, have the server owner change it all, he'll like it in the future
Reply
#7

Well thank you guys

Anyway is with my command everything good or you see any mistakes that can be scripted in better way...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)