SA-MP Forums Archive
[Ajuda] Comando sу funciona no ID 0 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Comando sу funciona no ID 0 (/showthread.php?tid=473494)



Comando sу funciona no ID 0 - bombomloko - 03.11.2013

Fiz esse comando mas se eu tento usar no id 15 por exemplo, seta no 0, sempre seta no 0

pawn Код:
if(strcmp(cmd, "/requisitarprisaoteste", true) == 0 || strcmp(cmd, "/rprisaoteste", true) == 0)
    {
        if (PlayerInfo[playerid][pLider] == 7 || PlayerInfo[playerid][pCargo] == 200 || PlayerInfo[playerid][pCargo] == 100)
        {
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[64];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USE: /rprisao [ID][Motivo]");
                    return true;
                }
                if(giveplayerid == playerid)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Vocк nгo pode mandar prender a si mesmo");
                    return 1;
                }
                SetPlayerCriminal(giveplayerid,playerid, result);
                format(string, sizeof(string), "O Prefeito requisitou a prisгo imediata de %s. Orgs policiais entrarгo em aзгo...", giveplayer);
                SendClientMessageToAll(COLOR_GRAD1, string);
                return true;
            }
        }
        return true;
    }



Respuesta: Comando sу funciona no ID 0 - Nost - 03.11.2013

pawn Код:
if(strcmp(cmd, "/requisitarprisaoteste", true) || strcmp(cmd, "/rprisaoteste", true ) )
    {
        if (PlayerInfo[playerid][pLider] == 7 || PlayerInfo[playerid][pCargo] == 200 || PlayerInfo[playerid][pCargo] == 100)
        {
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[64];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USE: /rprisao [ID][Motivo]");
                    return true;
                }
                if(giveplayerid == playerid)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Vocк nгo pode mandar prender a si mesmo");
                    return 1;
                }
                SetPlayerCriminal(giveplayerid,playerid, result);
                format(string, sizeof(string), "O Prefeito requisitou a prisгo imediata de %s. Orgs policiais entrarгo em aзгo...", giveplayer);
                SendClientMessageToAll(COLOR_GRAD1, string);
                return true;
            }
        }
        return true;
    }
Tenta assim...


Re: Respuesta: Comando sу funciona no ID 0 - bombomloko - 03.11.2013

Quote:
Originally Posted by Nost
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/requisitarprisaoteste", true) || strcmp(cmd, "/rprisaoteste", true ) )
    {
        if (PlayerInfo[playerid][pLider] == 7 || PlayerInfo[playerid][pCargo] == 200 || PlayerInfo[playerid][pCargo] == 100)
        {
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[64];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USE: /rprisao [ID][Motivo]");
                    return true;
                }
                if(giveplayerid == playerid)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Vocк nгo pode mandar prender a si mesmo");
                    return 1;
                }
                SetPlayerCriminal(giveplayerid,playerid, result);
                format(string, sizeof(string), "O Prefeito requisitou a prisгo imediata de %s. Orgs policiais entrarгo em aзгo...", giveplayer);
                SendClientMessageToAll(COLOR_GRAD1, string);
                return true;
            }
        }
        return true;
    }
Tenta assim...
o que essa linha q vc alterou tem a ver? e.e


Respuesta: Comando sу funciona no ID 0 - Nost - 03.11.2013

tirei a base do meu GM uso assim e pega


Re: Respuesta: Comando sу funciona no ID 0 - bombomloko - 03.11.2013

Quote:
Originally Posted by Nost
Посмотреть сообщение
tirei a base do meu GM uso assim e pega
nгo sei em que alterar o strcmp tem a ver


Respuesta: Comando sу funciona no ID 0 - Nost - 03.11.2013

custa nada tentar..
sou novo em PAWN dai nao sei muito...


Re: Comando sу funciona no ID 0 - bombomloko - 03.11.2013

o comando nгo vai funcionar se eu tirar o == 0

alguйm sabe como resolvo?


Re: Comando sу funciona no ID 0 - zSuYaNw - 03.11.2013

Eu particularmente nunca gostei deste tal de "strtok" (pawn)...


Entгo criei algo muito alйm disto...


pawn Код:
if(!strfind(cmdtext, "/requisitarprisaoteste", true) || !strfind(cmdtext, "/rprisaoteste", true)){
   
   
        // Cria variбveis e arrays..
        new
            string[100],
            fr[60],
            _size,
            id
        ;
       
       
        // pega o tamanho da array "cmdtext"
        _size = strlen(cmdtext);
       
       
        // Deletaremos a parte "/rprisaoteste ", assim sу sobrando os parвmetros
        strdel(cmdtext, 0, strfind(cmdtext, " ") + 1);

        // Caso tiver somente 1 parвmetro, retornar em forma de erro
        if(!~strfind(cmdtext, " ")){
       
            return SendClientMessage(playerid, -1, "Sintax: /req <id> <frase>");
           
        }

        // Na funзгo strmid, extraнmos a parte do texto da frase, e deixando de lado a parte do id.
        strmid(fr, cmdtext, strfind(cmdtext, " ") + 1, _size);
       
       
        // Agora deletaremos a frase sobrando o id.
        strdel(cmdtext, strfind(cmdtext, " "), _size);
       
        // Armazenaremos o id em uma variбvel
        id = strval(cmdtext);
       
       
        // Verificamos se o player estб conectado
        if(!IsPlayerConnected(id)){
       
            return SendClientMessage(playerid, -1, "Player nгo conectado Chaampz!");
        }


        // Imprimimos :D
        format(string, 100, "Frase: %s, para quкm: %d", fr, id);
        SendClientMessage(playerid, -1, string);
       
       
        return true;
    }

Expliquei passo-a-passo, espero que aprenda algo com isto.


Cheers.


Re: Comando sу funciona no ID 0 - bombomloko - 03.11.2013

Obrigado zSuYaNw, consegui, se possнvel, teria como me ajudar nesse tуpico tambйm?

https://sampforum.blast.hk/showthread.php?pid=2767462#pid2767462