[Pedido]Comando /a
#1

eae galera, tipo eu queria que no /a que й o chat de admin, que quando o admin digitasse aparecese o level de admin de cada player admin que fala algo ex: "1|ADMINCHAT|:E assim " ai aparecese o level de adm, no meu server o nivel de adm vai de 1 ate 8000 se puderem me ajudar ae valeus
cmd /a:
pawn Код:
if(strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "/a", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
          new nome[24];
          GetPlayerName(playerid, nome, sizeof nome);
          if(PlayerInfo[playerid][pAdmin] >= 1 || strfind(nome, ADMPLAYER, true) == 0 || strfind(nome, ADMPLAYER2, true) == 0)
          {
            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_RED, "USO: (/a)dmin [admin chat]");
                return 1;
            }
            if(strfind(nome, ADMPLAYER, true) == 0 || strfind(nome, ADMPLAYER2, true) == 0)
            {
             format(string, sizeof(string), "|ADMIN| %s: %s", ADMMASTER, result);
             SendAdminMessage(GOLDENROD1,string);
             printf("|ADMIN-CHAT|%s: %s", sendername, result);
            }
            else
            {
             format(string, sizeof(string), "|ADMIN-CHAT| %s: %s", sendername, result);
             SendAdminMessage(GOLDENROD1,string);
             printf("|ADMIN-CHAT| %s: %s", sendername, result);
            }
          }
        }
        return 1;
    }
Reply
#2

PHP код:
if(strcmp(cmd"/admin"true) == || strcmp(cmd"/a"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
          new 
nome[24];
          
GetPlayerName(playeridnomesizeof nome);
          if(
PlayerInfo[playerid][pAdmin] >= || strfind(nomeADMPLAYERtrue) == || strfind(nomeADMPLAYER2true) == 0)
          {
            
GetPlayerName(playeridsendernamesizeof(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(playeridCOLOR_RED"USO: (/a)dmin [admin chat]");
                return 
1;
            }
            if(
strfind(nomeADMPLAYERtrue) == || strfind(nomeADMPLAYER2true) == 0)
            {
             
format(stringsizeof(string), "|ADMIN| %s[%i]: %s"PlayerInfo[playerid][pAdmin],ADMMASTERresult);
             
SendAdminMessage(GOLDENROD1,string);
             
printf("|ADMIN-CHAT|%s: %s"sendernameresult);
            }
            else
            {
             
format(stringsizeof(string), "|ADMIN-CHAT| %s[%i]: %s"PlayerInfo[playerid][pAdmin],sendernameresult);
             
SendAdminMessage(GOLDENROD1,string);
             
printf("|ADMIN-CHAT| %s: %s"sendernameresult);
            }
          }
        }
        return 
1;
    } 
Reply
#3

pra que usar strtok nestes comandos ??

pawn Код:
if(!strcmp(cmd, "/a", 1,true))
    {
        if(PlayerInfo[playerid][pAdmin] < 1)
            return SendClientMessage(playerid, -1,"ERRO: vocк nгo tem nivel suficiente para realizar este comando.");
        if(!strlen(cmdtext[3]))
            return SendClientMessage(playerid, -1,"ERRO: /a Mensagem (CHAT ADMIN)");
        if(strlen(cmdtext[3]) > 128)
            return SendClientMessage(playerid, -1,"Tamanho do texto exedido, Resuma!");
        static iStr[200];
        GetPlayerName(playerid, iStr, 24);
        format(iStr, 128,"[ADMIN SHAT] %s[ID:%i Nivel: %d]:%s", iStr, playerid, PlayerInfo[playerid][pAdmin],cmdtext[3]);
        for(new i; i < MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i))
            {
                if(PlayerInfo[i][pAdmin] > 0)
                {
                    SendClientMessage(i, -1, iStr);
                }
            }
        }
    }
    return 1;
}

PS: nгo mecha nesta linha:
pawn Код:
if(strlen(cmdtext[3]) > 128)
            return SendClientMessage(playerid, -1,"Tamanho do texto exedido, Resuma!");
Reply
#4

Por que cmdtext[3] ? '-'
Reply
#5

Tipo os dois comandos que postaram ai aqui nгo deu nao ;s.
Reply
#6

PHP код:
if(strcmp(cmd"/admin"true) == || strcmp(cmd"/a"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
          new 
nome[24];
          
GetPlayerName(playeridnomesizeof nome);
          if(
PlayerInfo[playerid][pAdmin] >= || strfind(nomeADMPLAYERtrue) == || strfind(nomeADMPLAYER2true) == 0)
          {
            
GetPlayerName(playeridsendernamesizeof(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(playeridCOLOR_RED"USO: (/a)dmin [admin chat]");
                return 
1;
            }
            if(
strfind(nomeADMPLAYERtrue) == || strfind(nomeADMPLAYER2true) == 0)
            {
             
format(stringsizeof(string), "|ADMIN| %s[%i]: %s"ADMMASTER,PlayerInfo[playerid][pAdmin], result);
             
SendAdminMessage(GOLDENROD1,string);
             
printf("|ADMIN-CHAT|%s: %s"sendernameresult);
            }
            else
            {
             
format(stringsizeof(string), "|ADMIN-CHAT| %s[%i]: %s"sendername,PlayerInfo[playerid][pAdmin], result);
             
SendAdminMessage(GOLDENROD1,string);
             
printf("|ADMIN-CHAT| %s: %s"sendernameresult);
            }
          }
        }
        return 
1;
    } 
Reply
#7

Agora deu valeu um reputation for you
Reply
#8

Quote:
Originally Posted by Shadoww5
Посмотреть сообщение
Por que cmdtext[3] ? '-'
Й o cmd...

"/a"

/ 1
a 1
EOS 1

cmdtext[3]

EOS = end of string (tambйm conta como char)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)