[Ajuda] Chat -
xPaulistaa - 16.06.2012
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!
Re: [Ajuda] Chat -
Don_Speed - 16.06.2012
pawn Code:
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
Re: [Ajuda] Chat -
Rick_FusioN - 16.06.2012
Ver se pega ai.
Re: [Ajuda] Chat -
WagnerPM - 16.06.2012
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;
}
Re: [Ajuda] Chat -
xPaulistaa - 16.06.2012
Quote:
Originally Posted by Don_Speed
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?
Re: [Ajuda] Chat -
WagnerPM - 16.06.2012
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;
}
Re: [Ajuda] Chat -
xPaulistaa - 17.06.2012
Quote:
Originally Posted by WagnerPM
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]
Re: [Ajuda] Chat -
WagnerPM - 17.06.2012
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;
}
Re: [Ajuda] Chat -
xPaulistaa - 17.06.2012
Quote:
Originally Posted by WagnerPM
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.
Re: [Ajuda] Chat -
.FuneraL. - 17.06.2012
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
Re: [Ajuda] Chat -
EditPawn - 17.06.2012
Quote:
Originally Posted by .FuneraL.
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.
Re: [Ajuda] Chat -
.FuneraL. - 17.06.2012
Quote:
Originally Posted by EditPawn
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.
Re: [Ajuda] Chat -
xPaulistaa - 17.06.2012
Quote:
Originally Posted by EditPawn
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
Re: [Ajuda] Chat -
EditPawn - 17.06.2012
Quote:
Originally Posted by .FuneraL.
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;
}
Re: [Ajuda] Chat -
Bruno Pereira - 17.06.2012
EditPawn, acho vocк estб errado. No sscanf vocк tem que fazer assim
.
Eu uso assim, olha um cmd meu:
PHP Code:
CMD:av(playerid, params[])
{
if(BrunoInfo[playerid][pAdmin] < 1)
return SCM(playerid, COR_CINZA1, "Vocк nгo tem permissгo para usar esse comando!");
if(AdminModo[playerid] == 0)
return SCM(playerid, COR_CINZA1, "Vocк nгo pode usar esse comando enquanto estб jogando!");
if(AdminModo[playerid] == 0)
return SCM(playerid, COR_CINZA1, "Vocк nгo pode usar comando de admin enquanto joga.");
if(sscanf(params, "s[100]", corda[playerid]))
return SCM(playerid, COR_CINZA1, "Use: /aviso [mensagem]");
SCMTA(COR_BRANCO, "|_______________| AVISO DA ADMINISTRAЗГO |_______________| ");
format(String, 100, "Admin %s: %s", pNome(playerid), corda[playerid]);
SCMTA(COR_AZULZAO, String);
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
Re: [Ajuda] Chat -
.FuneraL. - 17.06.2012
Quote:
Originally Posted by Bruno Pereira
EditPawn, acho vocк estб errado. No sscanf vocк tem que fazer assim .
Eu uso assim, olha um cmd meu:
PHP Code:
CMD:av(playerid, params[])
{
if(BrunoInfo[playerid][pAdmin] < 1)
return SCM(playerid, COR_CINZA1, "Vocк nгo tem permissгo para usar esse comando!");
if(AdminModo[playerid] == 0)
return SCM(playerid, COR_CINZA1, "Vocк nгo pode usar esse comando enquanto estб jogando!");
if(AdminModo[playerid] == 0)
return SCM(playerid, COR_CINZA1, "Vocк nгo pode usar comando de admin enquanto joga.");
if(sscanf(params, "s[100]", corda[playerid]))
return SCM(playerid, COR_CINZA1, "Use: /aviso [mensagem]");
SCMTA(COR_BRANCO, "|_______________| AVISO DA ADMINISTRAЗГO |_______________| ");
format(String, 100, "Admin %s: %s", pNome(playerid), corda[playerid]);
SCMTA(COR_AZULZAO, String);
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.
Re: [Ajuda] Chat -
EditPawn - 17.06.2012
Quote:
Originally Posted by Bruno Pereira
EditPawn, acho vocк estб errado. No sscanf vocк tem que fazer assim .
Eu uso assim, olha um cmd meu:
PHP Code:
CMD:av(playerid, params[])
{
if(BrunoInfo[playerid][pAdmin] < 1)
return SCM(playerid, COR_CINZA1, "Vocк nгo tem permissгo para usar esse comando!");
if(AdminModo[playerid] == 0)
return SCM(playerid, COR_CINZA1, "Vocк nгo pode usar esse comando enquanto estб jogando!");
if(AdminModo[playerid] == 0)
return SCM(playerid, COR_CINZA1, "Vocк nгo pode usar comando de admin enquanto joga.");
if(sscanf(params, "s[100]", corda[playerid]))
return SCM(playerid, COR_CINZA1, "Use: /aviso [mensagem]");
SCMTA(COR_BRANCO, "|_______________| AVISO DA ADMINISTRAЗГO |_______________| ");
format(String, 100, "Admin %s: %s", pNome(playerid), corda[playerid]);
SCMTA(COR_AZULZAO, String);
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
Re: [Ajuda] Chat -
.FuneraL. - 17.06.2012
Quote:
Originally Posted by EditPawn
|
o "Texto" definido aн , nгo hб definiзгo de cйlulas, de uma olhada aн , ele estб definido assim:
Por isso a nгo colocaзгo de [128] ou seja lб a string no sscanf.
Re: [Ajuda] Chat -
EditPawn - 17.06.2012
Quote:
Originally Posted by .FuneraL.
o "Texto" definido aн , nгo hб definiзгo de cйlulas, de uma olhada aн , ele estб definido assim:
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
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 '-'
Re: [Ajuda] Chat -
Bruno Pereira - 17.06.2012
Tenho praticamente certeza que esta errado, uso assim:
PHP Code:
new corda[SLOTS][128];
CMD:av(playerid, params[])
{
if(sscanf(params, "s[128]", corda[playerid]))
return SCM(playerid, COR_CINZA1, "Use: /aviso [mensagem]");
SCMTA(COR_BRANCO, "|_______________| AVISO DA ADMINISTRAЗГO |_______________| ");
format(String, 100, "Admin %s: %s", pNome(playerid), corda[playerid]);
SCMTA(COR_AZULZAO, String);
return 1;
}