# API & Exports

Developer reference for integrating with EL\_EVENTS.

***

### Server-Side Functions

#### Starting Events

```lua
-- Start with auto settings
local success, reason = StartEvent('airdrop', {})

-- Force start (ignore player count)
local success, reason = StartEvent('airdrop', { force = true })

-- Available types: 'airdrop', 'hotzone', 'convoy', 'treasure'
Return values:

success: boolean
reason: string (if failed) - 'max_events', 'already_active', 'not_enough_players', 'no_location', 'no_route'
```

#### Stopping Events

```lua
-- Stop specific event by ID
StopEvent(eventId)

-- Stop all running events
StopAllEvents()
```

#### Querying Events

```lua
-- Count active events
local count = ServerFunctions.GetActiveEventCount()

-- Check if type is running
local active = ServerFunctions.IsEventTypeActive('convoy')

-- Iterate all active events
for eventId, event in pairs(ActiveEvents) do
    print(event.type, event.label, event.coords)
end
```

#### Utility Functions

```lua
-- Generate unique event ID
local id = ServerFunctions.GenerateEventId()

-- Get random location from a list
local loc = ServerFunctions.GetRandomLocation(Config.Airdrop.locations)

-- Get weighted random reward
local reward = ServerFunctions.GetWeightedReward(Config.Airdrop.rewards)

-- Translate string
local text = ServerFunctions.Translate('event_started')
local text = ServerFunctions.Translate('convoy_destroyed_by', playerName)

-- Notify all players
ServerFunctions.NotifyAll('Message here', 'info')

-- Notify single player
ServerFunctions.NotifyPlayer(source, 'Message', 'success')
```

#### Framework Functions

```lua
-- Give money
Framework.GiveMoney(source, 5000)

-- Give item
Framework.GiveItem(source, 'lockpick', 3)

-- Check admin
local isAdmin = Framework.IsAdmin(source)

-- Get player name
local name = Framework.GetPlayerName(source)

-- Get player count
local count = Framework.GetPlayerCount()
```

#### Database Functions

```lua
-- Log event start
Database.LogEventStart(eventId, 'airdrop', 'Port Area')

-- Log event end
Database.LogEventEnd(eventId, 'completed', 'PlayerName', playerId, 5000, nil, 3)

-- Get history
local history = Database.GetHistory(50)

-- Get today stats
local stats = Database.GetTodayStats()
```

### Client-Side Functions

#### Translation

```lua
local text = Translate('airdrop_open_prompt', 30)
```

#### Notifications

```lua
ClientFunctions.Notify('Message text', 'success')
-- Types: 'info', 'success', 'warning', 'error'
```

#### Blips

```lua
local blip = ClientFunctions.CreateBlip(coords, sprite, color, scale, label, flash)
ClientFunctions.RemoveBlip(blip)
```

#### 3D Drawing

```lua
ClientFunctions.DrawText3D(coords, 'Text here')
ClientFunctions.DrawMarker3D(coords, type, scale, color, bobUpDown)
```

#### Animations

```lua
ClientFunctions.PlayAnim(dict, name, duration, flag)
ClientFunctions.StopAnim()
```

#### Effects

```lua
local smoke = ClientFunctions.CreateSmoke(coords, color, duration)
local flare = ClientFunctions.CreateFlare(coords)
```

#### Announcements

```lua
ClientFunctions.ShowAnnouncement(title, subtitle, duration)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://elena-scripts.gitbook.io/elenascripts/core-systems/el-events/api-and-exports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
