Chat problem onPlayerText
#1

Sup guys i got those codes
@ symbol is The global chat
normal typing ls like Whisper
but when i tpye normaly
hello
it appear only
ello
my codes
hope you can help me guys

pawn Код:
public OnPlayerText(playerid,text[])
{
    if(text[0] == '@') {
    new string[128]; GetPlayerName(playerid,string,sizeof(string));
    format(string,sizeof(string),"@|%s: %s",string,text[1]); SendClientMessageToAll(COLOR_YELLOW,string);}else{
    new Float: x ,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
    if(IsPlayerConnected(i))
    {
    if(IsPlayerInRangeOfPoint(i,10.0,x,y,z))
    {
    new string[128]; GetPlayerName(playerid,string,sizeof(string));
    format(string,sizeof(string),"%s Says:%s",string,text[1]); SendClientMessage(i,-1,string);
}
}
}
}
}
Reply
#2

Hello!

PHP код:
format(string,sizeof(string),"%s Says:%s",string,text[1]); SendClientMessage(i,-1,string); 
to
PHP код:
format(string,sizeof(string),"%s Says:%s",string,text); SendClientMessage(i,-1,string); 
EDIT:
Thanks! I forgot it!

- Mencent
Reply
#3

text[x] should show only the first line of string, you should remove the []s..
pawn Код:
public OnPlayerText(playerid,text[])
{
    if(text[0] == '@') {
    new string[128]; GetPlayerName(playerid,string,sizeof(string));
    format(string,sizeof(string),"@|%s: %s",string,text[1]); SendClientMessageToAll(COLOR_YELLOW,string);}else{
    new Float: x ,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
    if(IsPlayerConnected(i))
    {
    if(IsPlayerInRangeOfPoint(i,10.0,x,y,z))
    {
    new string[128]; GetPlayerName(playerid,string,sizeof(string));
    format(string,sizeof(string),"%s Says:%s",string,text); SendClientMessage(i,-1,string);
}
}
}
}
Reply
#4

ohh thanks guys
Reply
#5

Why aren't you returning false?

Read https://sampwiki.blast.hk/wiki/OnPlayerText
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)