[Ajuda] Chat
#1

Fiz este comando :
pawn Code:
CMD:radio(playerid, params[])
{
if(!strlen(params)) return SendClientMessage(playerid, -1, "Use: /radio [texto]");
new string[80],Nome[MAX_PLAYER_NAME];
for(new i; i<MAX_PLAYERS; i++)
{
format(string, sizeof(string), "{CHAT GANG} Jogador %s diz: %s, cвmbio!",Nome,params[0]);
if(IsPlayerConnected(i) && EquipeGG[i] == EquipeGG[playerid])
{
SendClientMessage(i,-1, string);
}
}
return 1;
}
O comando funciona.
So tem um erro...
O Nome do jogador nгo apareзe.
Exemplo :
{CHAT GANG} Jogador diz: EAE, cвmbio!
Reply
#2

pawn Code:
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
Reply
#3

Ver se pega ai.
Reply
#4

pawn Code:
CMD:radio(playerid, params[])
{
    if(!strlen(params)) return SendClientMessage(playerid, -1, "Use: /radio [texto]");
    new string[80],Nome;
    GetPlayerName(playerid,Nome,MAX_PLAYER_NAME);
    for(new i; i<MAX_PLAYERS; i++)
    {
        format(string, sizeof(string), "{CHAT GANG} Jogador %s diz: %s, cвmbio!",Nome,params[0]);
        if(IsPlayerConnected(i) && EquipeGG[i] == EquipeGG[playerid])
        {
            SendClientMessage(i,-1, string);
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Don_Speed
View Post
pawn Code:
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
Aff,tinha esqueзido disso .-.

Ai pode me ajudar em outra coisa aqui :
tipo
Se eu digito so /radio,queria q apareзe : Use: /radio [texto]
Mas quando eu digito /radio, apareзe no chat : {GANG CHAT} Jogador TAL diz: , cвmbio!
Como arrumo?
Reply
#6

pawn Code:
CMD:radio(playerid, params[])
{
    new string[80],Nome, wText[128];
    if(sscanf(params, "s[128]",wText)) return SendClientMessage(playerid, -1, "Use: /radio [texto]");
    GetPlayerName(playerid,Nome,MAX_PLAYER_NAME);
    for(new i; i<MAX_PLAYERS; i++)
    {
        format(string, sizeof(string), "{CHAT GANG} Jogador %s diz: %s, cвmbio!",Nome,wText);
        if(IsPlayerConnected(i) && EquipeGG[i] == EquipeGG[playerid])
        {
            SendClientMessage(i,-1, string);
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by WagnerPM
View Post
pawn Code:
CMD:radio(playerid, params[])
{
    new string[80],Nome, wText[128];
    if(sscanf(params, "s[128]",wText)) return SendClientMessage(playerid, -1, "Use: /radio [texto]");
    GetPlayerName(playerid,Nome,MAX_PLAYER_NAME);
    for(new i; i<MAX_PLAYERS; i++)
    {
        format(string, sizeof(string), "{CHAT GANG} Jogador %s diz: %s, cвmbio!",Nome,wText);
        if(IsPlayerConnected(i) && EquipeGG[i] == EquipeGG[playerid])
        {
            SendClientMessage(i,-1, string);
        }
    }
    return 1;
}
Nesse jeito
so fica aparecendo : Use: /radio [texto]
Reply
#8

pawn Code:
CMD:radio(playerid, params[])
{
    new string[80],Nome, wText[128];
    if(sscanf(params, "s[128]",wText)) return SendClientMessage(playerid, -1, "Use: /radio [texto]");
    GetPlayerName(playerid,Nome,MAX_PLAYER_NAME);
    for(new i; i<MAX_PLAYERS; i++)
    {
        format(string, sizeof(string), "{CHAT GANG} Jogador %s diz: %s, cвmbio!",Nome,params);
        if(IsPlayerConnected(i) && EquipeGG[i] == EquipeGG[playerid])
        {
            SendClientMessage(i,-1, string);
        }
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by WagnerPM
View Post
pawn Code:
CMD:radio(playerid, params[])
{
    new string[80],Nome, wText[128];
    if(sscanf(params, "s[128]",wText)) return SendClientMessage(playerid, -1, "Use: /radio [texto]");
    GetPlayerName(playerid,Nome,MAX_PLAYER_NAME);
    for(new i; i<MAX_PLAYERS; i++)
    {
        format(string, sizeof(string), "{CHAT GANG} Jogador %s diz: %s, cвmbio!",Nome,params);
        if(IsPlayerConnected(i) && EquipeGG[i] == EquipeGG[playerid])
        {
            SendClientMessage(i,-1, string);
        }
    }
    return 1;
}
Mesma coisa.
Reply
#10

pawn Code:
CMD:radio(playerid, params[])
{
     new Nome[24], Texto[128], String[100];
     if(sscanf(params, "s[128]", Texto)) return SendClientMessage(playerid, -1, "Use: /radio [Texto]");
     GetPlayerName(playerid, Nome, 24);
     format(String, sizeof(String), "[CHAT GANG]: Jogador %s Diz: %s, Cambio", Nome, Texto);
     for(new i = 0; i < MAX_PLAYERS; i++)
     {
           if(EquipeGG[i] == EquipeGG[playerid])
           {
                  SendClientMessage(i, -1, String);
           }
      }
      return 1;
}
Dei uma baseada no seu Code, Tenta aн. :S
Reply
#11

Quote:
Originally Posted by .FuneraL.
View Post
pawn Code:
CMD:radio(playerid, params[])
{
     new Nome[24], Texto[128], String[100];
     if(sscanf(params, "s[128]", Texto)) return SendClientMessage(playerid, -1, "Use: /radio [Texto]");
     GetPlayerName(playerid, Nome, 24);
     format(String, sizeof(String), "[CHAT GANG]: Jogador %s Diz: %s, Cambio", Nome, Texto);
     for(new i = 0; i < MAX_PLAYERS; i++)
     {
           if(EquipeGG[i] == EquipeGG[playerid])
           {
                  SendClientMessage(i, -1, String);
           }
      }
      return 1;
}

Dei uma baseada no seu Code, Tenta aн. :S
vai retornar a mensagem Use: /radio [Texto]
Pois se ele digitar o texto certo, entre 128 cйlulas como esta ali no parametro, ira retornar o que vem apуs..

Entao use assim:

pawn Code:
CMD:radio(playerid, params[])
{
     new Nome[24], Texto[128], String[100];
     if(sscanf(params, "s", Texto)) return SendClientMessage(playerid, -1, "Use: /radio [Texto]");
     GetPlayerName(playerid, Nome, 24);
     format(String, sizeof(String), "[CHAT GANG]: Jogador %s Diz: %s, Cambio", Nome, Texto);
     for(new i = 0; i < MAX_PLAYERS; i++)
     {
           if(EquipeGG[i] == EquipeGG[playerid])
           {
                  SendClientMessage(i, -1, String);
           }
      }
      return 1;
}
Deixe sу "s" e retornando a mensagem...
ve se da certo.
Reply
#12

Quote:
Originally Posted by EditPawn
View Post
vai retornar a mensagem Use: /radio [Texto]
Pois se ele digitar o texto certo, entre 128 cйlulas como esta ali no parametro, ira retornar o que vem apуs..

Entao use assim:

pawn Code:
CMD:radio(playerid, params[])
{
     new Nome[24], Texto[128], String[100];
     if(sscanf(params, "s", Texto)) return SendClientMessage(playerid, -1, "Use: /radio [Texto]");
     GetPlayerName(playerid, Nome, 24);
     format(String, sizeof(String), "[CHAT GANG]: Jogador %s Diz: %s, Cambio", Nome, Texto);
     for(new i = 0; i < MAX_PLAYERS; i++)
     {
           if(EquipeGG[i] == EquipeGG[playerid])
           {
                  SendClientMessage(i, -1, String);
           }
      }
      return 1;
}
Deixe sу "s" e retornando a mensagem...
Se deixar apenas "S" o SSCANF irб retornar um Warning no Console. jб aconteceu isto comigo em outras vezes, Porque o "128" que hб ali, й sу o numero de characteres que tem a Variбvel.
Reply
#13

Quote:
Originally Posted by EditPawn
View Post
vai retornar a mensagem Use: /radio [Texto]
Pois se ele digitar o texto certo, entre 128 cйlulas como esta ali no parametro, ira retornar o que vem apуs..

Entao use assim:

pawn Code:
CMD:radio(playerid, params[])
{
     new Nome[24], Texto[128], String[100];
     if(sscanf(params, "s", Texto)) return SendClientMessage(playerid, -1, "Use: /radio [Texto]");
     GetPlayerName(playerid, Nome, 24);
     format(String, sizeof(String), "[CHAT GANG]: Jogador %s Diz: %s, Cambio", Nome, Texto);
     for(new i = 0; i < MAX_PLAYERS; i++)
     {
           if(EquipeGG[i] == EquipeGG[playerid])
           {
                  SendClientMessage(i, -1, String);
           }
      }
      return 1;
}
Deixe sу "s" e retornando a mensagem...
ve se da certo.
Ae funcionou *-*.


+rep pra todos

@.FuneraL.
Nao deu warning. '-'

@EditPawn && @Don_Speed
Nao vou poder dar rep,pq dei esses tempos,e agora da erro
Reply
#14

Quote:
Originally Posted by .FuneraL.
View Post
Se deixar apenas "S" o SSCANF irб retornar um Warning no Console. jб aconteceu isto comigo em outras vezes, Porque o "128" que hб ali, й sу o numero de characteres que tem a Variбvel.
mas ja esta definido na string logo acima.
E nгo vai retornar a nenhum warning, pois sempre usei dessa forma, mas se vc quer definir as cйlulas no parametro, use:

pawn Code:
CMD:radio(playerid, params[])
{
    new Nome[24], Texto[128], String[100];
    if(sscanf(params, "s[128]", Texto))
    {
        GetPlayerName(playerid, Nome, 24);
        format(String, sizeof(String), "[CHAT GANG]: Jogador %s Diz: %s, Cambio", Nome, Texto);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(EquipeGG[i] == EquipeGG[playerid]) SendClientMessage(i, -1, String);
        }
        return 1;
    }
    else SendClientMessage(playerid, -1, "Use: /radio [Texto]");
    return 1;
}
Reply
#15

EditPawn, acho vocк estб errado. No sscanf vocк tem que fazer assim
PHP Code:
s[128
.
Eu uso assim, olha um cmd meu:

PHP Code:
CMD:av(playeridparams[])
{
    if(
BrunoInfo[playerid][pAdmin] < 1)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo tem permissгo para usar esse comando!");
    if(
AdminModo[playerid] == 0)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo pode usar esse comando enquanto estб jogando!");
    if(
AdminModo[playerid] == 0)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo pode usar comando de admin enquanto joga.");
    if(
sscanf(params"s[100]"corda[playerid]))
        return 
SCM(playeridCOR_CINZA1"Use: /aviso [mensagem]");
    
SCMTA(COR_BRANCO"|_______________| AVISO DA ADMINISTRAЗГO |_______________| ");
    
format(String100"Admin %s: %s"pNome(playerid), corda[playerid]);
    
SCMTA(COR_AZULZAOString);
    return 
1;

Que eu saiba, tem que definir o nъmero de cйlulas, nгo importa se a variбvel jб esta definida, posso estar errado :P
Reply
#16

Quote:
Originally Posted by Bruno Pereira
View Post
EditPawn, acho vocк estб errado. No sscanf vocк tem que fazer assim
PHP Code:
s[128
.
Eu uso assim, olha um cmd meu:

PHP Code:
CMD:av(playeridparams[])
{
    if(
BrunoInfo[playerid][pAdmin] < 1)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo tem permissгo para usar esse comando!");
    if(
AdminModo[playerid] == 0)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo pode usar esse comando enquanto estб jogando!");
    if(
AdminModo[playerid] == 0)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo pode usar comando de admin enquanto joga.");
    if(
sscanf(params"s[100]"corda[playerid]))
        return 
SCM(playeridCOR_CINZA1"Use: /aviso [mensagem]");
    
SCMTA(COR_BRANCO"|_______________| AVISO DA ADMINISTRAЗГO |_______________| ");
    
format(String100"Admin %s: %s"pNome(playerid), corda[playerid]);
    
SCMTA(COR_AZULZAOString);
    return 
1;

Que eu saiba, tem que definir o nъmero de cйlulas, nгo importa se a variбvel jб esta definida, posso estar errado :P
Estб certo bruno, tente vocк mesmo retirar o numero de cйlulas do sscanf , e use o mesmo comando in game, o sscanf darб um warning no console, pela falta de cйlulas na definiзгo do sscanf.
Reply
#17

Quote:
Originally Posted by Bruno Pereira
View Post
EditPawn, acho vocк estб errado. No sscanf vocк tem que fazer assim
PHP Code:
s[128
.
Eu uso assim, olha um cmd meu:

PHP Code:
CMD:av(playeridparams[])
{
    if(
BrunoInfo[playerid][pAdmin] < 1)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo tem permissгo para usar esse comando!");
    if(
AdminModo[playerid] == 0)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo pode usar esse comando enquanto estб jogando!");
    if(
AdminModo[playerid] == 0)
        return 
SCM(playeridCOR_CINZA1"Vocк nгo pode usar comando de admin enquanto joga.");
    if(
sscanf(params"s[100]"corda[playerid]))
        return 
SCM(playeridCOR_CINZA1"Use: /aviso [mensagem]");
    
SCMTA(COR_BRANCO"|_______________| AVISO DA ADMINISTRAЗГO |_______________| ");
    
format(String100"Admin %s: %s"pNome(playerid), corda[playerid]);
    
SCMTA(COR_AZULZAOString);
    return 
1;

Que eu saiba, tem que definir o nъmero de cйlulas, nгo importa se a variбvel jб esta definida, posso estar errado :P
Bom, na verdade eu uso "s", sempre que fiz com "s[128]" retornava a funзгo a seguir.
um exemplo й esse tutorial do BlueX
https://sampforum.blast.hk/showthread.php?tid=277842
Reply
#18

Quote:
Originally Posted by EditPawn
View Post
Bom, na verdade eu uso "s", sempre que fiz com "s[128]" retornava a funзгo a seguir.
um exemplo й esse tutorial do BlueX
https://sampforum.blast.hk/showthread.php?tid=277842
o "Texto" definido aн , nгo hб definiзгo de cйlulas, de uma olhada aн , ele estб definido assim:

pawn Code:
new texto;
Por isso a nгo colocaзгo de [128] ou seja lб a string no sscanf.
Reply
#19

Quote:
Originally Posted by .FuneraL.
View Post
o "Texto" definido aн , nгo hб definiзгo de cйlulas, de uma olhada aн , ele estб definido assim:

pawn Code:
new texto;
Por isso a nгo colocaзгo de [128] ou seja lб a string no sscanf.
bom, entao se vc define as cйlulas na var e no params, vai retornar a true, no caso a funзгo a seguir....
era o que estava acontecendo no caso do nosso amigo xPaulista.
Pode ver esse post dele.


Quote:
Originally Posted by xPaulistaa
View Post
Ae funcionou *-*.


+rep pra todos

@.FuneraL.
Nao deu warning. '-'

@EditPawn && @Don_Speed
Nao vou poder dar rep,pq dei esses tempos,e agora da erro
ja fiz teste definindo nos 2 locais, e me retornou a funcao a seguir.
espero que voces faзam o mesmo teste '-'
Reply
#20

Tenho praticamente certeza que esta errado, uso assim:
PHP Code:
new corda[SLOTS][128];
CMD:av(playeridparams[])
{
    if(
sscanf(params"s[128]"corda[playerid]))
        return 
SCM(playeridCOR_CINZA1"Use: /aviso [mensagem]");
    
SCMTA(COR_BRANCO"|_______________| AVISO DA ADMINISTRAЗГO |_______________| ");
    
format(String100"Admin %s: %s"pNome(playerid), corda[playerid]);
    
SCMTA(COR_AZULZAOString);
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)