Alerts

Customize the client side alerts to fit the look and feel of your own server

-- msg [string]: Message to display in the notification
-- type [string]: Type of notification to display
-- timeout [int]: Time in milliseconds to display the notification
function Alert(msg, type, timeout)
    lib.notify({
        type = type,
        description = msg,
        icon = "fas fa-truck",
        duration = timeout,
        position = "top",
    })
end

3D Text

Customize the the draw text placed at each interactable offset location

-- Purpose: Function to draw 3D text.
-- x [float]: X coordinate
-- y [float]: Y coordinate
-- z [float]: Z coordinate
-- text [string]: Text to display
function DrawText3D(x, y, z, text)
    SetTextScale(0.4, 0.4)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(220, 220, 220, 215)
    BeginTextCommandDisplayText("STRING")
    SetTextCentre(true)
    AddTextComponentSubstringPlayerName(text)
    SetDrawOrigin(x,y,z+0.5, 0)
    EndTextCommandDisplayText(0.0, 0.0)
    ClearDrawOrigin()
end

Police Alert

Customize the dispatch triggered when someone is trying to lockpick a motorhome (Does not get triggered if the player is on a configured police job if enabled)

-- Purpose: Alert police when a successful lockpick attempt is made.
-- vehicle [int]: Vehicle entity
function AlertPolice(vehicle)
    local coords = GetEntityCoords(PlayerPedId())

    -- PS-Dispatch
    --local dispatchData = {
    --    message = JobName,
    --    codeName = 'carjack',
    --    code = '10-17',
    --    icon = 'fas fa-truck',
    --    priority = 1,
    --    coords = coords,
    --    alertTime = nil,
    --    jobs = Config.PoliceJobs
    --}

    --TriggerServerEvent('ps-dispatch:server:notify', dispatchData)

    --CD_DISPATCH
    --local data = exports['cd_dispatch']:GetPlayerInfo()
    --TriggerServerEvent('cd_dispatch:AddNotification', {
    --    job_table = Config.PoliceJobs, 
    --    coords = coords,
    --    title = '10-17 - ' .. JobName,
    --    message = 'A stange shipment has been spotted, please investigate.',
    --    flash = 0,
    --    unique_id = data.unique_id,
    --    sound = 1,
    --    blip = {
    --        sprite = 431, 
    --        scale = 1.2, 
    --        colour = 3,
    --        flashes = false, 
    --        text = '10-17 - ' .. JobName,
    --        time = 5,
    --        radius = 25.0,
    --    }
    --})
end

Can Interact

An extra function that is used to check whether or not a mortohome can be interacted with. You can use this to disable an RV's functionality in specific scenarios such as the player being dead, or the RV located in a green zone.

-- Purpose: Function to check if player can interact with RV
-- vehicle [int]: Vehicle entity
-- return [bool]: Whether the player can interact with the RV
function CanInteract(vehicle)
    
    return true
end

Forced Entry

This is where you can customize a minigame of your choice. It is already setup to use a lockpick minigame that can be downloaded here

-- Purpose: Function to trigger lockpick minigame.
-- Triggered by client event "gs-motorhomes:client:minigame"
-- isPolice [bool]: Whether the player is a police officer
-- Callback [function]: Callback function
function AttemptForceEntry(isPolice, Callback)
    --Give police more chances to get the door open / unlock the stash
    local tries = (isPolice and 4 or 1)

    --Simple lockpick minigame https://github.com/GlitchOo/lockpick
    if IsResourceOnServer('lockpick') then
        local success = exports['lockpick']:startLockpick(tries)
        Callback(success) --true or false
    else
        Callback(false)
    end
end

Last updated