[Ajuda] intervenзгo no CMD.
#1

Pessoal estou com uma dъvida. Estou querendo fazer um CMD para os policiais do meu servidor. Para eles poder retirar algo do jogador, Exemplo. Armas,Drogas,Materiais. Mais eu quero fazer diferente um exemplo!

pawn Код:
CMD:retirar(playerid)
{

    if(sscanf(params,"s",Variavel)) return SendClientMessage(playerid,VERDE_BEM_CLARO,"USE: /retirar [ARMAS, MATERIAIS, DROGAS, DINAMITE]");
    // O SISTEMA
    return true;
}
Ai tipo o policial irб tem que retirar algo que o bandido tem no caso se for , drogas, dinamite etc...

Ai ele digita o comando

/Retirar [DROGAS] AI AS DROGAS SГO RETIRADAS
OU EM OUTRO CASO /RETIRAR [DINAMITES] AS DINAMITE SГO RETIRAR

COMO NESSE EXEMPLO DO GF.

pawn Код:
if(strcmp(cmd, "/retirar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(!IsACop(playerid))
            {
                SendClientMessage(playerid, COLOR_GREY, "   Vocк nгo й um policial!");
                return 1;
            }
            if(OnDuty[playerid] != 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "   Vocк nгo Bateu o cartгo!");
                return 1;
            }
            if(gTeam[playerid] == 2 || IsACop(playerid) || IsAGOV(playerid))
            {
                if(PlayerInfo[playerid][pCargo] < 2)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   Vocк precisa de cargo 2 para usar este comando !");
                    return 1;
                }
                new x_nr[32];
                x_nr = strtok(cmdtext, idx);
                if(!strlen(x_nr)) {
                    SendClientMessage(playerid, COLOR_WHITE, "{9AC0CD} • • • • • • • • • • • • • • • • • • ( {BFEFFF}Retirar Algo do jogador{9AC0CD} ) • • • • • • • • • • • • • • • • • • ");
                    SendClientMessage(playerid, COLOR_WHITE, "USE: /retirar [nome] [id]");
                    SendClientMessage(playerid, COLOR_GREY, "Nomes Disponнveis: Armas, Drogas, Materiais");
                    return 1;
                }
                else if(strcmp(x_nr,"Armas",true) == 0)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp)) {
                        SendClientMessage(playerid, COLOR_WHITE, "USE: /retirar Armas [id]");
                        return 1;
                    }
                    giveplayerid = ReturnUser(tmp);
                    if(IsPlayerConnected(giveplayerid))
                    {
                        if(giveplayerid != INVALID_PLAYER_ID)
                        {
                            GetPlayerName(giveplayerid, sendername, sizeof(sendername));
                            if (ProxDetectorS(8.0, playerid, giveplayerid))
                            {
                                new cop[MAX_PLAYER_NAME];
                                GetPlayerName(playerid, cop, sizeof(cop));
                                new fudido[MAX_PLAYER_NAME];
                                GetPlayerName(giveplayerid, fudido, sizeof(fudido));
                                format(string, sizeof(string), "* Vocк retirou as Armas de %s.", fudido);
                                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                                format(string, sizeof(string), "* Oficial %s retirou suas Armas.", cop);
                                SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
                                ResetPlayerWeaponsEx(giveplayerid);
                                OnMafiaEquipado[playerid] = 0;
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   O Jogador estб longe de Vocк !");
                                return 1;
                            }
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "   O Jogador Estб Offline !");
                        return 1;
                    }
                }
                else if(strcmp(x_nr,"Drogas",true) == 0)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp)) {
                        SendClientMessage(playerid, COLOR_WHITE, "USE: /retirar Drogas [id]");
                        return 1;
                    }
                    giveplayerid = ReturnUser(tmp);
                    if(IsPlayerConnected(giveplayerid))
                    {
                        if(giveplayerid != INVALID_PLAYER_ID)
                        {
                            GetPlayerName(giveplayerid, sendername, sizeof(sendername));
                            if (ProxDetectorS(8.0, playerid, giveplayerid))
                            {
                                new cop[MAX_PLAYER_NAME];
                                GetPlayerName(playerid, cop, sizeof(cop));
                                new fudido[MAX_PLAYER_NAME];
                                GetPlayerName(giveplayerid, fudido, sizeof(fudido));
                                format(string, sizeof(string), "* Vocк retirou as Drogas de %s.", fudido);
                                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                                format(string, sizeof(string), "* Oficial %s retirou suas Drogas.", cop);
                                SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
                                PlayerInfo[giveplayerid][pDrogas] = 0;
                                PlayerInfo[giveplayerid][pDrogas2] = 0;
                                PlayerInfo[giveplayerid][pDrogas3] = 0;
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   O Jogador estб longe de Vocк !");
                                return 1;
                            }
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "   O Jogador Estб Offline !");
                        return 1;
                    }
                }
                else if(strcmp(x_nr,"Materiais",true) == 0)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp)) {
                        SendClientMessage(playerid, COLOR_WHITE, "USE: /retirar Materiais [id]");
                        return 1;
                    }
                    giveplayerid = ReturnUser(tmp);
                    if(IsPlayerConnected(giveplayerid))
                    {
                        if(giveplayerid != INVALID_PLAYER_ID)
                        {
                            GetPlayerName(giveplayerid, sendername, sizeof(sendername));
                            if (ProxDetectorS(8.0, playerid, giveplayerid))
                            {
                                new cop[MAX_PLAYER_NAME];
                                GetPlayerName(playerid, cop, sizeof(cop));
                                new fudido[MAX_PLAYER_NAME];
                                GetPlayerName(giveplayerid, fudido, sizeof(fudido));
                                format(string, sizeof(string), "* Vocк retirou os Materiais de %s.", fudido);
                                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                                format(string, sizeof(string), "* Oficial %s Retirou seus Materiais.", cop);
                                SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
                                PlayerInfo[giveplayerid][pMats] = 0;
                            }
                            else
                            {
                                SendClientMessage(playerid, COLOR_GREY, "   O Jogador estб longe de Vocк !");
                                return 1;
                            }
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "   O Jogador Estб Offline !");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   Nome invбlido !");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Vocк nгo e COP !");
                return 1;
            }
        }
        return 1;
    }
MAIS EU NГO SEI FAZER ISSO EM ZCMD ESSE Й O PROBLEMA
Reply
#2

Da pra fazer com strcmp tente:
pawn Код:
if(strcmp(params[0], "Drogas", true, 10) == 0){
     // Cуdigo
     return 1;
}
if(strcmp(params[0], "Armas", true, 10) == 0){
     // Cуdigo
     return 1;
}
Reply
#3

Quote:
Originally Posted by CLANdok
Посмотреть сообщение
Da pra fazer com strcmp tente:
pawn Код:
if(strcmp(params[0], "Drogas", true, 10) == 0){
     // Cуdigo
     return 1;
}
if(strcmp(params[0], "Armas", true, 10) == 0){
     // Cуdigo
     return 1;
}
Meu filho eu uso ZCMD, E Quero usar os argumentos em sу um COMANDO!
Quero usar o /retirar em todos argumentos exemplos

/Retirar [DROGAS, ARMAS, DINAMITE ETC..]
Reply
#4

- Nгo sou seu filho

pawn Код:
CMD:filho(playerid, params[]){
if(strcmp(params[0], "Filho", true, 10) == 0){
     // Sou seu filho
     return 1;
}
if(strcmp(params[0], "NaoFilho", true, 10) == 0){
     // Nгo sou seu filho
     return 1;
}
}
Reply
#5

Quote:
Originally Posted by CLANdok
Посмотреть сообщение
- Nгo sou seu filho

pawn Код:
CMD:filho(playerid, params[]){
if(strcmp(params[0], "Filho", true, 10) == 0){
     // Sou seu filho
     return 1;
}
if(strcmp(params[0], "NaoFilho", true, 10) == 0){
     // Nгo sou seu filho
     return 1;
}
}
Pai, tu esta usando STRCMP em zcmd, esse zcmd nгo irб dar erro!
Reply
#6

Criei esse comando agora para vocк e jб testei funcional sem bugs, Espero ter ajudado!

@Editado para melhoria do CMD

Modo de uso: /retirar [playerid] [ARMAS, MATERIAIS, DROGAS, DINAMITE]

° Comando:
PHP код:
CMD:retirar(playeridparams[])
{
    new 
idplayertext[15], aname[2][MAX_PLAYER_NAME], string[120];
    if(
sscanf(params"is"idplayertext)) return SendClientMessage(playerid,-1,"[ ERRO ] {FF0000}USE: /retirar [playerid] [ARMAS, MATERIAIS, DROGAS, DINAMITE]");
    if(!
IsPlayerConnected(idplayer)) return SendClientMessage(playerid, -1"[ ERRO ] {FF0000}Este player nгo estб conectado!");
    
GetPlayerName(playeridaname[0], MAX_PLAYER_NAME);
    
GetPlayerName(idplayeraname[1], MAX_PLAYER_NAME);
    if(
strcmp(text"armas"true) == 0)
    {
        
format(string120,"| INFO | O(A) policial %s retirou as armas do(a) bandido(a) %s!"aname[0] ,aname[1]);
        
SendClientMessageToAll(0x00FF80AAstring);
        return 
1;
    }
    else if(
strcmp(text"materiais"true) == 0)
    {
        
format(string120,"| INFO | O(A) policial %s retirou os materiais do(a) bandido(a) %s!"aname[0] ,aname[1]);
        
SendClientMessageToAll(0x00FF80AAstring);
        return 
1;
    }
    else if(
strcmp(text"drogas"true) == 0)
    {
        
format(string120,"| INFO | O(A) policial %s retirou as drogas do(a) bandido(a) %s!"aname[0] ,aname[1]);
        
SendClientMessageToAll(0x00FF80AAstring);
        return 
1;
    }
    else if(
strcmp(text"dinamite"true) == 0)
    {
        
format(string120,"| INFO | O(A) policial %s retirou as dinamites do(a) bandido(a) %s!"aname[0] ,aname[1]);
        
SendClientMessageToAll(0x00FF80AAstring);
        return 
1;
    }
    return 
1;

Reply
#7

Quote:
Originally Posted by [BOPE]Seu._.Madruga
Посмотреть сообщение
Espero ter ajudado!

PHP код:
CMD:retirar(playeridparams[])
{
    if(
strcmp(params"armas"true) == 0)
    {
        
SendClientMessage(playerid, -1"armas");
        return 
1;
    }
    else if(
strcmp(params"materiais"true) == 0)
    {
        
SendClientMessage(playerid, -1"materiais");
        return 
1;
    }
    else if(
strcmp(params"drogas"true) == 0)
    {
        
SendClientMessage(playerid, -1"drogas");
        return 
1;
    }
    else if(
strcmp(params"dinamite"true) == 0)
    {
        
SendClientMessage(playerid, -1"dinamite");
        return 
1;
    }
    else
    {
        
SendClientMessage(playerid,-1,"[ ERRO ] {FF0000}USE: /retirar [ARMAS, MATERIAIS, DROGAS, DINAMITE]");
    }
    return 
1;

Й disto que eu estou falando =D, filho ruim, nota 0, strcmp nгo da erro em ZCMD, isso й muito simples de saber, apenas tente
Reply
#8

Valeu obrigado, Madruga Pai e CLANdok Filho!!!
Reply
#9

Como o amigo acima falou usando strcmp da pra fazer.
Exemplo:
pawn Код:
CMD:retirar(playerid,params[])
{
    new var[10],ID;
    if(sscanf(params,"us"ID,var) return SendClientMessage(playerid,-1,"/retirar [id] [itens]");
    if(strcmp(var,"armas",true) == 0)
    {
        ResetPlayerWeapons(ID);
        SendClientMessage(ID,-1,"Retiraram tuas armas!");
    }
    else if(strcmp(var,"drogas",true) == 0)
    {
        //etc...
    }
    else SendClientMessage(playerid,-1,"itens:drogas,armas");
    return 1;
}
@Edit
tava fazendo antes de postarem foi mau .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)