https://open.mp logo
Title
f

flat-egg-44689

05/25/2023, 9:04 PM
Updated version. Compiles, but still not actually tested in-game. Removed the magic numbers.
c
SendNearbyMessage(playerid, const message[])
{
    new const Float:MAX_DISTANCE = 16.0;
    new const MAX_COLOR_COMPONENT = 255;
    new const MIN_COLOR_COMPONENT = 127;

    new
        Float:x,
        Float:y,
        Float:z;
        
    GetPlayerPos(playerid, x, y, z);
    
    foreach (new i : StreamedPlayer[playerid])
    {
        new Float:distance = GetPlayerDistanceFromPoint(i, x, y, z);
        
        if (distance <= MAX_DISTANCE)
        {
            new component = MAX_COLOR_COMPONENT - floatround(distance * (float(MAX_COLOR_COMPONENT - MIN_COLOR_COMPONENT) / MAX_DISTANCE));
            new color = component << 24 | component << 16 | component << 8 | 0xFF;
            
            SendClientMessage(i, color, message);
        }
    }
}