Street Lights

Započeo devster, Jul 27, 2023, 21:48:36 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 2 gostiju pregledaju ovu temu.

Tip: Include
Slike ili Video: //
Opis i dodatne informacije: //
Download link: //
Scan link: //
Credits: realnaith

[pawn]
/*
* Street Lights Control Include
* Author: [realnaith]
* Version: 1.0
*/

#define MAX_STREET_LIGHTS 100
const Float:STREET_LIGHT_MAX_DIST = 50.0;

enum StreetLightState
{
    LIGHT_OFF,
    LIGHT_ON,
    LIGHT_DIMMED,
};

new Float:StreetLightPositions[MAX_STREET_LIGHTS][3];
new StreetLightState:StreetLightStates[MAX_STREET_LIGHTS];

stock OnStreetLightsInit()
{
    for (new i = 0; i < MAX_STREET_LIGHTS; i++)
    {
        StreetLightPositions
  • = 0.0;
            StreetLightPositions[1] = 0.0;
            StreetLightPositions[2] = 0.0;
            StreetLightStates = LIGHT_OFF;
        }
    }

    stock SetStreetLightState(Float:x, Float:y, Float:z, streetlightstate)
    {
        new lightID = FindNearestStreetLight(x, y, z);

        if (lightID != INVALID_LIGHT)
        {
            StreetLightStates[lightID] = streetlightstate;

            switch (streetlightstate)
            {
                case LIGHT_OFF:
                    break;

                case LIGHT_ON:
                    break;

                case LIGHT_DIMMED:
                    break;
            }
        }
    }

    stock FindNearestStreetLight(Float:x, Float:y, Float:z)
    {
        new nearestLight = INVALID_LIGHT;
        new nearestDist = STREET_LIGHT_MAX_DIST;

        for (new i = 0; i < MAX_STREET_LIGHTS; i++)
        {
            if (StreetLightStates != LIGHT_OFF)
            {
                Float:dist = GetDistance3D(x, y, z, StreetLightPositions
    • , StreetLightPositions[1], StreetLightPositions[2]);
                  if (dist < nearestDist)
                  {
                      nearestDist = dist;
                      nearestLight = i;
                  }
              }
          }

          return nearestLight;
      }


      [/pawn]
Poslednja Izmena: Jul 27, 2023, 21:52:17 POSLE PODNE od realnaith