SSGamers - 12 Anos online por você.

#SSGamers - A Comunidade que mais crescer no brasil!

Participe do fórum, é rápido e fácil

SSGamers - 12 Anos online por você.

#SSGamers - A Comunidade que mais crescer no brasil!

SSGamers - 12 Anos online por você.

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.
Chegou o novo tema 6.5.5 - SSGamers - Servidores online de qualidade - Aproveite e entre para nossa comunidade, inscreva-se já! - Ouça nossa web radio - Veja nossas novidades - Participe dos nossos setores de jogos online - Parcerias aberta fale já com um administrador.

    [Tutorial] usando strcmp com zcmd...

    Weslley_Script
    Weslley_Script
    SS - Fundador
    SS - Fundador


    Steam Steam : WeslleySSGames
    Zello : WeslleySSGames
    Mensagens : 11378
    Moedas : 1031967
    Data de inscrição : 06/10/2011
    Idade : 28
    Localização : Brasil

    [Tutorial] usando strcmp com zcmd... Empty [Tutorial] usando strcmp com zcmd...

    Mensagem por Weslley_Script Dom 8 Out 2023 - 17:41

    Vou mostrar como usar OnPlayerCommandText com Zcmd sem ter q converter seu GM...

    Abra a Include ZCMD limpe ela toda e cole isso:
    pawn Код:

    Código:
    /**********************************
     *                                *
     *   @Author:      ZeeX           *
     *   @Version:     0.3.1          *
     *   @Released:    31/10/2009     *
     *                                *
     **********************************/

    #if defined _zcmd_included
        #endinput
    #endif 
    #define _zcmd_included

    #define MAX_FUNC_NAME (32)

    #define COMMAND:%1(%2)          \
                forward cmd_%1(%2); \
                public cmd_%1(%2)      
               
    #define CMD:%1(%2) \
                COMMAND:%1(%2)

    #define command(%1,%2,%3) \
                COMMAND:%1(%2, %3)      
         
    #define cmd(%1,%2,%3) \
                COMMAND:%1(%2, %3)

    #if !defined isnull
        #define isnull(%1) \
                    ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
    #endif


    forward OnPlayerCommandReceived(playerid, cmdtext[]);
    forward OnPlayerCommandPerformed(playerid, cmdtext[], success);
    forward OnCommandText(playerid,cmdtext[]);

    static
        bool:zcmd_g_HasOPCS = false,
        bool:zcmd_g_HasOPCE = false;

    #if defined FILTERSCRIPT

    public OnFilterScriptInit()
    {
        zcmd_g_HasOPCS = funcidx("OnPlayerCommandReceived") != -1;
        zcmd_g_HasOPCE = funcidx("OnPlayerCommandPerformed") != -1;
        return CallLocalFunction("zcmd_OnFilterScriptInit", "");
    }

    #if defined _ALS_OnFilterScriptInit
        #undef OnFilterScriptInit
    #else
        #define _ALS_OnFilterScriptInit
    #endif
    #define OnFilterScriptInit zcmd_OnFilterScriptInit
    forward zcmd_OnFilterScriptInit();

    #else /*not a filterscript*/

    public OnGameModeInit()
    {
        zcmd_g_HasOPCS = funcidx("OnPlayerCommandReceived") != -1;
        zcmd_g_HasOPCE = funcidx("OnPlayerCommandPerformed") != -1;
        if (funcidx("zcmd_OnGameModeInit") != -1)
        {
            return CallLocalFunction("zcmd_OnGameModeInit", "");
        }  
        return 1;
    }

    #if defined _ALS_OnGameModeInit
        #undef OnGameModeInit
    #else
        #define _ALS_OnGameModeInit
    #endif
    #define OnGameModeInit zcmd_OnGameModeInit
    forward zcmd_OnGameModeInit();

    #endif /*if defined FILTERSCRIPT*/

    public OnPlayerCommandText(playerid, cmdtext[])
    {
        if(CallLocalFunction("OnCommandText","is",playerid,cmdtext) == 1) return 1;
        if (zcmd_g_HasOPCS && !CallLocalFunction("OnPlayerCommandReceived", "is", playerid, cmdtext))
        {
            return 1;
        }
        new
            pos,
            funcname[MAX_FUNC_NAME];
        while (cmdtext[++pos] > ' ')
        {
            funcname[pos-1] = tolower(cmdtext[pos]);
        }
        format(funcname, sizeof(funcname), "cmd_%s", funcname);
        while (cmdtext[pos] == ' ') pos++;
        if (!cmdtext[pos])
        {
            if (zcmd_g_HasOPCE)
            {
                return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, "\1"));
            }
            return CallLocalFunction(funcname, "is", playerid, "\1");  
        }
        if (zcmd_g_HasOPCE)
        {
            return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, cmdtext[pos]));
        }
        return CallLocalFunction(funcname, "is", playerid, cmdtext[pos]);
    }

    #if defined _ALS_OnPlayerCommandText
        #undef OnPlayerCommandText
    #else
        #define _ALS_OnPlayerCommandText
    #endif
    #define OnPlayerCommandText OnCommandText


    Caso nao queira modificar a include entao crie um nova(recomendo criar uma nova),outra coisa, sempre coloque return 1; em todos comandos com strcmp, o return 0; do fim da OnPlayerCommandText de Seu GM/FS pode deixar pq o zcmd irб verificar se retornou a 1 caso retorne a 0(ou o valor a ser retornado no fim do OnPlayerCommandtext) veja o teste queu fiz:
    pawn Код:

    Código:
    #include <a_samp>
    #include <zcmd>
    public OnPlayerCommandText(playerid,cmdtext[]){
        if(!strcmp(cmdtext,"/teste",true)){
            SendClientMessage(playerid,-1,"Zcmd & OnPlayerCommandText \"Processando o Comando Em OnPlayerCommandText\"");
            return 1;
        }
        return 0;
    }
    CMD:testee(playerid,params[]){
        SendClientMessage(playerid,-1,"Zcmd Com OnPlayerCommandText \"Processando o Comando em Zcmd\"");
        if(!isnull(params))SendClientMessage(playerid,-1,params);
        return 1;
    }


    Obs: se duplicar um comando, o primeiro a ser executado й o q esta no OnPlayerCommandText
    ObsІ: Nгo Percebi Isso Antes
    pawn Код:

    Código:
    public OnPlayerCommandReceived(playerid,cmdtext[])
    {
        // todos comando do OnPlayerCommandText Aquii
    }
    public OnPlayerCommandPerformed(playerid,cmdtext[],sucess)
    {
        // todos comando do OnPlayerCommandText Aquii
    }


    Isso nгo foi sу falta de antenзгo minha, como de todos q nгo conseguem usar ZCMD em GMs que contйm o OnPlayerCommandText. 



    [Tutorial] usando strcmp com zcmd... D07Xwqb
    [Tutorial] usando strcmp com zcmd... Yjab9HN

      Data/hora atual: Dom 28 Abr 2024 - 9:18