Mensagem para players prуximos
#1

Sou novo em programaзгo em Pwn, espero que tenham paciкncia comigo

Estou fazendo um sistema de Kit, estou com uma duvida, como faзo para depois que o player pegar o kit mandar uma mensagem para os players prуximos, exemplo: " Fulano pegou seu kit "
Reply
#2

PHP код:
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
public 
ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(
IsPlayerConnected(playerid))
    {
        new 
Float:posx, Float:posy, Float:posz;
        new 
Float:oldposx, Float:oldposy, Float:oldposz;
        new 
Float:tempposx, Float:tempposy, Float:tempposz;
        
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        for(new 
i = 0; i < MAX_PLAYERS; i++)
        {
            if(
IsPlayerConnected(i))
            {
                
GetPlayerPos(i, posx, posy, posz);
                
tempposx = (oldposx -posx);
                
tempposy = (oldposy -posy);
                
tempposz = (oldposz -posz);
                if(
GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
                {
                    if (((
tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                    {
                        
SendClientMessage(i, col1, string);
                    }
                    else if (((
tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                    {
                        
SendClientMessage(i, col2, string);
                    }
                    else if (((
tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                    {
                        
SendClientMessage(i, col3, string);
                    }
                    else if (((
tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                    {
                        
SendClientMessage(i, col4, string);
                    }
                    else if (((
tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                    {
                        
SendClientMessage(i, col5, string);
                    }
                }
            }
        }
    }
    return 
1;
} 
Uso:
PHP код:
ProxDetector(10.0, playerid, "Mensagem", COR1, COR2, COR3, COR4, COR5); 
Reply
#3

PHP код:
stock SendClientMessageOnRadius(playerid, Float:range, color, const message[]) // fiz rapidamente aqui, n sei se ja existe algo do tipo
{
    new 
Float:x, Float:y, Float:z;
    
GetPlayerPos(playerid, x, y, z);
    for(new 
i=0, maxid = GetPlayerPoolSize(); i <= maxid; i++)
    {
        if(!
IsPlayerConnected(i)) continue;        
        if(!
IsPlayerInRangeOfPoint(i, range, x, y, z)) continue;
        
SendClientMessage(i, color, message);
    }
    return 
1;
} 
Modo de uso seria simples
PHP код:
public OnPlayerText(playerid, text[])
{
    if(
text[0] == ';') // Exemplo de chat prуximo
    
{
         new 
Msg[144];
         
format(Msg, sizeof Msg, "> %s [%i]: %s", getName(playerid), playerid, text);
         
SendClientMessageOnRadius(playerid, 50.0, 0x808080FF, Msg); // Enviando mensagem formatada
         
return 0;
    }
    return 
1;
} 
Assim, sу utilizar SendClientMessageOnRadius e utilizar em seu script.
Reply
#4

Valeu galera,
Reply
#5

PHP код:
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
for(new 
i = 0; i < MAX_PLAYERS; i++)
{
 if(
IsPlayerInRangeOfPoint(i, 12.0, pos[0], pos[1], pos[2]))
 { 
 
SenClientMessage(i, -1, "Fulano pegou seu kit !");
 }
} 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)