# Events

You can use event like this to trigger the dragon spawn/despawn:

```lua
-- server.lua
TriggerClientEvent('luman-dragon:spawnDragonOrDespawnIfExists', playerId, dragonIndex)
```

`playerId` - player server ID

`dragonIndex` - dragon number as it is ordered via `config.lua`.

You can listen for next events:

```lua
-- client.lua
AddEventHandler('luman-dragon:onMountingDragon', function(dragonIndex)
    print('Mounting dragon', dragonIndex)
end)
AddEventHandler('luman-dragon:onDragonMounted', function(dragonIndex)
    print('Mounted dragon', dragonIndex)
end)
AddEventHandler('luman-dragon:onUnmountingDragon', function(dragonIndex)
    print('Unmounting dragon', dragonIndex)
end)
AddEventHandler('luman-dragon:onDragonUnmounted', function(dragonIndex)
    print('Unmounted dragon', dragonIndex)
end)
```
