Problem With Chat -
V_LOPE - 15.12.2011
When I Use This CODE in My GM.
I can't chat.
PHP код:
if(text[0] == '!')
{
new name[24], string[256];
GetPlayerName(playerid, name, 24);
format(string, sizeof(string), "{AD855C}[Team Chat]%s: %s", name, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerTeam(playerid) == GetPlayerTeam(i))
SendClientMessage(i,yellow, string);
}
}
}
return 0;
Re: Problem With Chat -
Celson - 15.12.2011
Is anything at all coming up?
Re: Problem With Chat -
V_LOPE - 15.12.2011
Quote:
Originally Posted by Celson
Is anything at all coming up?
|
yes..nothing Appear when i chat
Re: Problem With Chat -
[ABK]Antonio - 15.12.2011
pawn Код:
if(GetPlayerTeam(playerid) == GetPlayerTeam(i))
SendClientMessage(i,yellow, string);
change to
pawn Код:
if(GetPlayerTeam(playerid) == GetPlayerTeam(i)) SendClientMessage(i,yellow, string);
or
pawn Код:
if(GetPlayerTeam(playerid) == GetPlayerTeam(i))
{
SendClientMessage(i,yellow, string);
}
If that doesn't work, check your GetPlayerTeam shit
Re: Problem With Chat -
V_LOPE - 15.12.2011
Still the Problem
i can't chat
Re: Problem With Chat -
Rob_Maate - 15.12.2011
pawn Код:
format(string, sizeof(string), "{AD855C}[Team Chat]%s: %s", name, text[1]);
Why are you using 'text[1]'?
just use 'text'. Specifying an index in the array will return a number (the strval) and won't display because you've defined it in your format as a string (%s)
Re: Problem With Chat -
[ABK]Antonio - 15.12.2011
Quote:
Originally Posted by Rob_Maate
pawn Код:
format(string, sizeof(string), "{AD855C}[Team Chat]%s: %s", name, text[1]);
Why are you using 'text[1]'?
just use 'text'. Specifying an index in the array will return a number (the strval) and won't display because you've defined it in your format as a string (%s)
|
The reason he would use text[1] is to strip text[0] from the output....text[0] represents ! and text[1] represents the rest
Re: Problem With Chat - suhrab_mujeeb - 15.12.2011
Remember OnPlayerText always returns true to be able to chat. So the code should be:
pawn Код:
public OnPlayerText(playerid, text[])
{
// Rest of the code
return 1;
}
So maybe try this
pawn Код:
//
if(text[0] == '!')
{
new name[24], string[256];
GetPlayerName(playerid, name, 24);
format(string, sizeof(string), "{AD855C}[Team Chat]%s: %s", name, text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerTeam(playerid) == GetPlayerTeam(i))
SendClientMessage(i,yellow, string);
}
}
}
return 1;
Re: Problem With Chat -
Rob_Maate - 15.12.2011
Nope. In pawno, a string array is not stored as a string.
The reason we MUST specify the array size to be one cell larger than the string itself, is because the last member of the array must carry the value 0 for it to be compiled as a string.
Because pawn is like this, you can actually create string arrays like this:
pawn Код:
new weird[6];
weird[0] = 68;
weird[1] = 65;
weird[2] = 73;
weird[3] = 86;
weird[4] = 68;
weird[5] = 0;
printf("%s", weird);
The output would be "DAVID"
EDIT: Try this
pawn Код:
if(text[0] == 33)
{
new name[MAX_PLAYER_NAME];
string[256];
GetPlayerName(playerid, name, 24);
new modifier[128];
for(new i=1; i<sizeof(text); i++)
{
modifier[i-1] = text[i];
}
format(string, sizeof(string), "{AD855C}[Team Chat]%s: %s", name, modifier);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerTeam(playerid) == GetPlayerTeam(i))
{
SendClientMessage(i,yellow, string);
}
}
}
return 1;
}
Re: Problem With Chat -
[ABK]Antonio - 15.12.2011
Rob, please look at this before you reply again....
https://sampwiki.blast.hk/wiki/OnPlayerText
playerid The ID of the player who typed the text.
text[] The text the player typed.
Returns Returning 0 in this callback will stop the text from being sent
So text[0] would be the first letter typed, text[1] would be the second, and so forth.