[Ajuda] Chat
#1

pawn Код:
public OnPlayerText(playerid, text[])
{
    new str[128];
    format(str, sizeof(str), "%s fala: %s", ReturnUser(Name), text[0]);
    for (new d = 0; r < MAX_PLAYERS; d++)
    {
        if(IsPlayerConnected(d))
        {
            if(IsPlayerInRangeOfPoint(d, 10.0, x, y, z))
            {
                SendClientMessage(d, -1, str);
            }
        }
        return 0;
    }
    return 1;
}
O chat sу apareзe pro ID 0.

E quando eu tiro o return 0;, apareзe pra todos(normal), porйm a frase repete.

Alguem ajuda.
Reply
#2

Nгo tenho certeza, mas acho que estб faltando um return 1; nesta linha...
if(IsPlayerInRangeOfPoint(d, 10.0, x, y, z))
{
SendClientMessage(d, -1, str);
}

Tenta assim:
pawn Код:
if(IsPlayerInRangeOfPoint(d, 10.0, x, y, z))
            {
                SendClientMessage(d, -1, str);
                return 1;
            }
Reply
#3

pawn Код:
public OnPlayerText(playerid, text[])
{
    new str[128];
    format(str, sizeof(str), "%s fala: %s", ReturnUser(Name), text[0]);
    for (new d = 0; r < MAX_PLAYERS; d++)
    {
        if(IsPlayerConnected(d))
        {
            if(IsPlayerInRangeOfPoint(d, 10.0, x, y, z))
            {
                SendClientMessage(d, -1, str);
            }
        }
    }
    return false;
}
Reply
#4

Vou sair agora galera, +rep pra quem ajudou ai.

Amanha eu testo, Se alguem tem outra soluзгo posta ae por favor
Reply
#5

pawn Код:
public OnPlayerText(playerid, text[])
{
    new str[128];
    format(str, sizeof(str), "%s fala: %s", ReturnUser(Name), text[0]);
    for (new d = 0; r < MAX_PLAYERS; d++)
    {
        if(IsPlayerConnected(d))
        {
            if(IsPlayerInRangeOfPoint(d, 10.0, x, y, z))
            {
                SendClientMessage(d, -1, str);
                return 0; // ignorar o texto padrгo e enviar a uma mensagem  costumizada.
            }
        }
        return 0;
    }
    return 1;
}
faltando um return ali aonde deixei comentario .
Reply
#6

Minha versгo
pawn Код:
public OnPlayerText(playerid, text[])
{
    static
        Float:sx[3],
        Nome[24],
        str[128],
        i
    ;
   
   
    i       =   0;
    str[0]  =   '\0';
    Nome[0] =   '\0';
   
    format(str, sizeof(str), "%s fala: %s", (GetPlayerName(playerid, Nome, 24), Nome), text[0]);
   
    GetPlayerPos(playerid, sx[0],  sx[1], sx[2]);
   
    for( i = GetMaxPlayers(); i > -1; --i){
   
        if(IsPlayerConnected(i)){
       
            if(IsPlayerInRangeOfPoint(, 10.0, sx[0],  sx[1], sx[2])){
                SendClientMessage(i, -1, str);
            }
        }
    }
    return 0;
}
Reply
#7

Parabйns, pessoal ta sabendo usar o return dentro de loop's.

PHP код:
public OnPlayerText(playeridtext[])
{
    static 
Float:pos[3];
    
GetMaxPlayers();
    
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    
format(text128"%s fala: %s"ReturnUser(Name), text); // economizando variбveis.
    
for (; > -1; --a)
    {
        if(!
IsPlayerInRangeOfPoint(a10.0pos[0],pos[1],pos[2])) continue; // sem necessidade de checar se estб conectado, isto sу irб funcionar caso esteja conectado.
        
SendClientMessage(a, -1text);
    }
    return 
0// para nгo repetir o texto.

Reply
#8

Quote:
Originally Posted by HDTV
Посмотреть сообщение
Parabйns, pessoal ta sabendo usar o return dentro de loop's.

PHP код:
public OnPlayerText(playeridtext[])
{
    static 
Float:pos[3];
    
GetMaxPlayers();
    
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    
format(text128"%s fala: %s"ReturnUser(Name), text); // economizando variбveis.
    
for (; > -1; --a)
    {
        if(!
IsPlayerInRangeOfPoint(a10.0pos[0],pos[1],pos[2])) continue; // sem necessidade de checar se estб conectado, isto sу irб funcionar caso esteja conectado.
        
SendClientMessage(a, -1text);
    }
    return 
0// para nгo repetir o texto.

+rep

Por isso:
pawn Код:
// sem necessidade de checar se estб
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)