Integrations

We provide various open source functions into our Advanced Money Laundering resource that enables you to add further customization and/or add third-party resource integrations.

Client

The functions below can be found in lation_laundering/client/functions.lua

CanOpenMenu() - Function that allows or rejects a player from opening main menu

-- Function that allows or rejects a player from opening main menu
CanOpenMenu = function()
    -- Example implementation to show how this works
    -- First, we're checking if the player is dead
    local dead = IsPedDeadOrDying(cache.ped, false)
    -- If the variable "dead" is true, it'll return false below
    -- Which will not allow the menu to open
    if dead then
        -- Here is where you would display a notification providing
        -- Some information to the player about why the menu won't open
        return false
    end
    -- If "dead" is false, then the code proceeds to here
    -- Which now returns "true", allowing the menu to open
    return true
end

CanBuyKey() - Function that allows or rejects a player from purchasing warehouse key

-- Function that allows or rejects a player from purchasing warehouse key
CanBuyKey = function()
    -- This function works the same as the above CanOpenMenu
    -- Except obviously for the purchasing of the warehouse key
    -- We'll provide another example implementation below:
    -- Let's say we wanted to restrict buying keys to gangs only
    -- You would obviously replace "true" with your gang system export
    -- That would check if a player was in a gang or not
    local inGang = true
    -- Next we add an if-then statement below, so if not inGang then..
    if not inGang then
        -- We return false! Thus not allowing the player to purchase
        -- A warehouse key if they are not a gang member. We would also
        -- Likely inform the player here with a notification like:
        -- ShowNotification('You must be a gang member to purchase this', 'error')
        return false
    end
    -- If the player IS a gang member, then we'll make it to this part of
    -- The code and then simply return true, allowing them to purchase a key
    return true
end

CanEnterWarehouse() - Function that runs to verify conditions before allowing entry

-- Function that runs to verify conditions before allowing warehouse entry
CanEnterWarehouse = function()
    -- Initialize variables
    local result, isPolice = true, false
    -- Check if police exception exists
    if Config.Police.warehouseAccess then
        local player = GetPlayerData()
        for _, job in pairs(Config.Police.jobs) do
            if player.job.name == job then
                isPolice = true
            end
        end
    end
    -- Check if player has the key
    local hasKey = HasItem(Config.Items.key, 1)
    if not hasKey and not isPolice then
        ShowNotification(Strings.Notify.notAuthorized, 'error')
        result = false
    end
    -- Check if we're enforcing level requirement
    if Config.Warehouse.requireLvl then
        local level = exports.lation_laundering:GetData('level')
        if level < Config.Warehouse.unlockAt and not isPolice then
            ShowNotification(Strings.Notify.notAuthorized, 'error')
            result = false
        end
    end
    -- If you want to add custom requirements to entering the warehouse
    -- This is where you would make that happen
    return result
end

StartedCounting() - Function that's triggered when started counting money

-- Function that's triggered when started counting money
-- This function can be used for anything, but by default
-- It disables the ability to open your inventory during
-- The money counting process
StartedCounting = function()
    -- Check if ox_inventory is running
    if GetResourceState('ox_inventory') == 'started' then
        LocalPlayer.state.invBusy = true
    end
    -- Check if qb-inventory is running
    if GetResourceState('qb-inventory') == 'started' then
        LocalPlayer.state.inv_busy = true
    end
    -- Check if qs-inventory is running
    if GetResourceState('qs-inventory') == 'started' then
        exports['qs-inventory']:setInventoryDisabled(true)
    end
end

StoppedCounting() - Function that's triggered when stopped counting money

-- Function that's triggered when stopped counting money
-- As mentioned above, this function can be used for anything
-- After a player has completed counting money, it will 
-- Re-enable access to their inventory
StoppedCounting = function()
    -- Check if ox_inventory is running
    if GetResourceState('ox_inventory') == 'started' then
        LocalPlayer.state.invBusy = false
    end
    -- Check if qb-inventory is running
    if GetResourceState('qb-inventory') == 'started' then
        LocalPlayer.state.inv_busy = false
    end
    -- Check if qs-inventory is running
    if GetResourceState('qs-inventory') == 'started' then
        exports['qs-inventory']:setInventoryDisabled(false)
    end
end

StartedLaundering() - Function that's triggered when starting contracts

-- Function that's triggered when starting contracts
StartedLaundering = function()

end

StoppedLaundering() - Function that's triggered when stopped contracts

-- Function that's triggered when stopping contracts
StoppedLaundering = function()

end

Last updated