Developer
Overview
Other resources read the loot setup through server exports. The loot flow is changed in open/handlers_server.lua and open/handlers_client.lua, which stay unencrypted. Every handler returns the default value, so change only the ones you need.
Server Exports
lua
1local config = exports['ml_lootprops']:GetPropConfig(propHash)
2local category = exports['ml_lootprops']:GetCategory('animals')
3local props = exports['ml_lootprops']:GetAllProps()
4local categories = exports['ml_lootprops']:GetAllCategories()GetPropConfig(propHash): settings of a configured model, ornilGetCategory(categoryId): settings of a category, ornilGetAllProps(): list of configured models as{ hash, model }GetAllCategories(): list of categories as{ id, label }
Server Handlers
Located in open/handlers_server.lua.
Loot Flow
open/handlers_server.lua
1Handlers.OnBeforeClaim = function(source, propHash, coords, config)
2 return true
3end
4
5Handlers.OnAfterClaim = function(source, propHash, coords, items, config)
6end
7
8Handlers.ModifyLoot = function(source, propHash, fixedLoots, probabilityLoots, config)
9 return fixedLoots, probabilityLoots
10end
11
12Handlers.GetLootMultiplier = function(source, propHash, config)
13 return 1.0
14end
15
16Handlers.GetBonusLoot = function(source, propHash, config)
17 return nil
18endOnBeforeClaim: runs before the items are given. Returnfalseto stop the claimOnAfterClaim: runs after the items are given.itemslists themModifyLoot: edits the guaranteed and chance tables before the rollGetLootMultiplier: multiplies item amounts.2.0doubles themGetBonusLoot: extra items on top, as{ { name = 'item', amount = 1 } }
Cooldowns
open/handlers_server.lua
1Handlers.GetCooldownOverride = function(source, propHash, baseCooldown, config)
2 return nil
3end
4
5Handlers.CanBypassCooldown = function(source, propHash)
6 return false
7endGetCooldownOverride: return seconds to replace the personal cooldownCanBypassCooldown: returntrueto let the player skip the cooldown
Access
open/handlers_server.lua
1Handlers.CanPlayerLoot = function(source, propHash, config)
2 return true, nil
3end
4
5Handlers.CanPlayerLootInArea = function(source, coords)
6 return true, nil
7endCanPlayerLoot: returnfalse, 'reason'to refuse a model to that playerCanPlayerLootInArea: same check by position, for territories or event areas
Dispatch
open/handlers_server.lua
1Handlers.ShouldTriggerDispatch = function(source, propHash, config)
2 return nil
3endShouldTriggerDispatch:trueorfalseforces the alert,nilkeeps the configured chance
Client Handlers
Located in open/handlers_client.lua.
Interaction
open/handlers_client.lua
1Handlers.CanInteractWithProp = function(propHash, entity, coords)
2 return true
3end
4
5Handlers.GetCustomTargetLabel = function(propHash, entity, config)
6 return nil
7end
8
9Handlers.GetCustomTargetIcon = function(propHash, entity, config)
10 return nil
11end
12
13Handlers.GetCustomTargetDistance = function(propHash, entity, config)
14 return nil
15end
16
17Handlers.AddCustomTargetOptions = function(propHash, entity, config)
18 return {}
19endCanInteractWithProp: returnfalseto hide the option on that objectGetCustomTargetLabel,GetCustomTargetIcon: return a string to replace the label or icon, such as'fas fa-skull'GetCustomTargetDistance: return a number to replace the interaction rangeAddCustomTargetOptions: extra target options on the same object
Looting
open/handlers_client.lua
1Handlers.CanLootProp = function(propHash, entity, config)
2 return true, nil
3end
4
5Handlers.OnBeforeLoot = function(propHash, entity, config)
6end
7
8Handlers.OnAfterProgress = function(propHash, entity, config)
9 return true
10end
11
12Handlers.OnLootFailed = function(propHash, entity, reason)
13endCanLootProp: returnfalse, 'reason'to stop the loot after the player interactsOnBeforeLoot: runs before the progress barOnAfterProgress: runs when the progress bar ends. Returnfalseto cancel the claimOnLootFailed: runs when a loot fails, for example a failed minigame
Object Tracking
open/handlers_client.lua
1Handlers.OnPropDetected = function(entity, propHash, coords)
2end
3
4Handlers.OnPropLost = function(entity, propHash)
5endOnPropDetected: a configured object comes within about 20 meters of the playerOnPropLost: a tracked object leaves that range
Examples
open/handlers_server.lua
1Handlers.GetLootMultiplier = function(source, propHash, config)
2 local day = os.date('*t').wday
3 if day == 1 or day == 7 then return 2.0 end
4 return 1.0
5endopen/handlers_server.lua
1Handlers.CanBypassCooldown = function(source, propHash)
2 local job = Bridge.GetJob(source)
3 return job and job.name == 'vip'
4endopen/handlers_server.lua
1local eventActive = false
2
3Handlers.CanPlayerLoot = function(source, propHash, config)
4 if eventActive then
5 return false, 'Looting is closed during the event'
6 end
7 return true
8end