Developer
Overview
Integrate through the open/ folder, where server, client and shared handlers hook into every step of a drop. Two server exports let other resources trigger drops and read the active ones.
Server Exports
TriggerAirdrop(spec): starts a drop and returns its uid, orniland'denied'or'invalid'. The calling resource must be listed inConfig.AdminExportResources, andspecmust be a table, empty for all defaults.GetActiveDrops(): returns the list of active drops with their state and coordinates.
server.lua
1local uid, reason = exports.ml_airdrop:TriggerAirdrop({
2 crateId = 'military',
3 planeId = 'cargobob_titan',
4 zoneId = 'sandy',
5 contested = false,
6 triggeredBy = source,
7})crateId,planeId,zoneId: leave any of them out for the default or a random pick. The shipped zones aresandy,grapeseed,chiliad,paletoandelysiancontested:falsetogether withtriggeredBylocks the drop to that player. WithouttriggeredBythe drop has no owner and stays open to everyone
Server Handlers
Located in open/server.lua. Return false from a Before handler to block that step.
open/server.lua
1function OpenServer.BeforeTrigger(src, triggerKind, opts) return true end
2function OpenServer.OnDropSpawned(drop) end
3function OpenServer.OnDropLanded(drop) end
4function OpenServer.ModifyLoot(drop, stock) return stock end
5function OpenServer.BeforeGiveLoot(src, drop, entry) return true end
6function OpenServer.OnLootGiven(src, drop, entry) end
7function OpenServer.BeforeVehicleClaim(src, drop, model) return true end
8function OpenServer.OnVehicleClaimed(src, payload) end
9function OpenServer.CanCallFlare(src) return true end
10function OpenServer.OnDropDespawned(drop, reason) endBeforeTrigger: fires before a drop starts.triggerKindisauto,adminorflare. A drop started by export uses thetriggerKindof its spec,autowhen not set.OnDropSpawned/OnDropLanded: fire as the drop goes inbound and when it lands.ModifyLoot: mutate and return the rolled loot before it is locked in.BeforeGiveLoot/OnLootGiven: gate and observe each captured slot.BeforeVehicleClaim/OnVehicleClaimed: gate and observe a vehicle claim. Register ownership here on QBCore or ESX.
Keep the Original Call
The shipped OnLootGiven and OnVehicleClaimed call the built-in versions, which give the skill XP and register the vehicle on Qbox. Keep that call when you add your own code, or XP and Qbox ownership stop working.
CanCallFlare: gate whether a player may call a drop with a flare item.OnDropDespawned: fires on cleanup.reasonisemptied,expiredorforced.
Client Handlers
Located in open/client.lua.
open/client.lua
1function OpenClient.BeforeOpenLoot(drop) return true end
2function OpenClient.AfterLanded(drop) end
3function OpenClient.AfterOpened(drop) end
4function OpenClient.AfterCaptureItem(drop, item, count) endBeforeOpenLoot: returnfalseto block the loot panel from opening.AfterLanded/AfterOpened/AfterCaptureItem: observe the lifecycle on this client.
Shared Handlers
Located in open/shared.lua.
open/shared.lua
1function OpenShared.ResolveId(kind, id) return id endResolveId: remap a crate, loot, plane or zone id before it is used, for example a seasonal swap.
Minigames
Crate open minigames are adapters in open/minigames. Each returns whether the player passed, and registers itself into Config.AirdropMiniGames.
open/minigames/_template.lua
1Config.AirdropMiniGames['my_game'] = {
2 label = 'My Minigame',
3 Start = function()
4 -- run your minigame, return true on success
5 return true
6 end,
7}Examples
List your resource in Config.AdminExportResources, then:
server.lua
1exports.ml_airdrop:TriggerAirdrop({ crateId = 'military', contested = true })open/server.lua
1function OpenServer.BeforeTrigger(src, triggerKind, opts)
2 if MyEvent and MyEvent.active then return false end
3 return true
4endopen/server.lua
1function OpenServer.OnLootGiven(src, drop, entry)
2 -- runs once per captured slot
3end