All pastes #937091 Raw Edit

Vermischtes

public text v1 · immutable
·published 2008-03-10 21:02 UTC
rendered paste body
// somewhere in script
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
ProxDetector(Float:radi, playerid, string[], col1, col2, col3, col4, col5)
{
    new
        Float:posx,
        Float:posy,
        Float:posz,
        Float:oldposx,
        Float:oldposy,
        Float:oldposz,
        Float:distance,
        Float:rad0 = radi / 2,
        Float:rad1 = radi / 4,
        Float:rad2 = radi / 8,
        Float:rad3 = radi / 16;
    rad0 *= rad0;
    rad1 *= rad1;
    rad2 *= rad2;
    rad3 *= rad3;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
                GetPlayerPos(i, posx, posy, posz);
                distance = ((oldposx - posx) * (oldposx - posx)) + ((oldposy - posy) * (oldposy - posy)) + ((oldposz - posz) * (oldposz - posz));

                if (distance < rad3)
                {
                    SendClientMessage(i, col1, string);
                }
                else if (distance < rad2)
                {
                    SendClientMessage(i, col2, string);
                }
                else if (distance < rad1)
                {
                    SendClientMessage(i, col3, string);
                }
                else if (distance < rad0)
                {
                    SendClientMessage(i, col4, string);
                }
                else if (distance < radi)
                {
                    SendClientMessage(i, col5, string);
                }
            }
            else
            {
                SendClientMessage(i, col1, string);
            }
        }
    return 1;
}