πŸ”₯All scripts on our website are 50% off!πŸ”₯
Logo

Config file

Config, Lang, Noti = {}, {}, {}

--  $$$$$$\   $$$$$$\  $$\   $$\ $$$$$$$$\ $$$$$$\  $$$$$$\  $$\   $$\ $$$$$$$\   $$$$$$\ $$$$$$$$\ $$$$$$\  $$$$$$\  $$\   $$\ 
-- $$  __$$\ $$  __$$\ $$$\  $$ |$$  _____|\_$$  _|$$  __$$\ $$ |  $$ |$$  __$$\ $$  __$$\\__$$  __|\_$$  _|$$  __$$\ $$$\  $$ |
-- $$ /  \__|$$ /  $$ |$$$$\ $$ |$$ |        $$ |  $$ /  \__|$$ |  $$ |$$ |  $$ |$$ /  $$ |  $$ |     $$ |  $$ /  $$ |$$$$\ $$ |
-- $$ |      $$ |  $$ |$$ $$\$$ |$$$$$\      $$ |  $$ |$$$$\ $$ |  $$ |$$$$$$$  |$$$$$$$$ |  $$ |     $$ |  $$ |  $$ |$$ $$\$$ |
-- $$ |      $$ |  $$ |$$ \$$$$ |$$  __|     $$ |  $$ |\_$$ |$$ |  $$ |$$  __$$< $$  __$$ |  $$ |     $$ |  $$ |  $$ |$$ \$$$$ |
-- $$ |  $$\ $$ |  $$ |$$ |\$$$ |$$ |        $$ |  $$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |  $$ |     $$ |  $$ |  $$ |$$ |\$$$ |
-- \$$$$$$  | $$$$$$  |$$ | \$$ |$$ |      $$$$$$\ \$$$$$$  |\$$$$$$  |$$ |  $$ |$$ |  $$ |  $$ |   $$$$$$\  $$$$$$  |$$ | \$$ |
--  \______/  \______/ \__|  \__|\__|      \______| \______/  \______/ \__|  \__|\__|  \__|  \__|   \______| \______/ \__|  \__|

-- Use "esx", "qb" or "qbox"
Config.Framework = "qb"
-- oxmysql, mysql-async or ghmattisql
Config.Mysql = "oxmysql"
-- Prop used for the sticky note
Config.stickyNoteProp =  "xs_prop_arena_stickynote_01a"
-- Item used to create the sticky note
Config.stickyNoteItem = "sticky_note"
-- Allow players to rewrite existing notes
Config.canRewrite = true
-- Who can remove notes:
-- "everyone" = Anyone can delete notes
-- "admins" = Only admins can delete notes
-- "owner" = Only the note owner can delete their own notes
-- "police" or any job name = Players with that job can delete notes
-- "LDT19669", "char1:110001484222" or any citizenid/identifier = Specific player can delete notes
Config.whoCanRemove = {
    "everyone",
    "admins",
    "owner",
    "police",
    "LDT19669",
}

-- $$\   $$\  $$$$$$\ $$$$$$$$\ $$$$$$\ $$$$$$$$\ $$$$$$\  $$$$$$\   $$$$$$\ $$$$$$$$\ $$$$$$\  $$$$$$\  $$\   $$\  $$$$$$\
-- $$$\  $$ |$$  __$$\\__$$  __|\_$$  _|$$  _____|\_$$  _|$$  __$$\ $$  __$$\\__$$  __|\_$$  _|$$  __$$\ $$$\  $$ |$$  __$$\
-- $$$$\ $$ |$$ /  $$ |  $$ |     $$ |  $$ |        $$ |  $$ /  \__|$$ /  $$ |  $$ |     $$ |  $$ /  $$ |$$$$\ $$ |$$ /  \__|
-- $$ $$\$$ |$$ |  $$ |  $$ |     $$ |  $$$$$\      $$ |  $$ |      $$$$$$$$ |  $$ |     $$ |  $$ |  $$ |$$ $$\$$ |\$$$$$$\
-- $$ \$$$$ |$$ |  $$ |  $$ |     $$ |  $$  __|     $$ |  $$ |      $$  __$$ |  $$ |     $$ |  $$ |  $$ |$$ \$$$$ | \____$$\
-- $$ |\$$$ |$$ |  $$ |  $$ |     $$ |  $$ |        $$ |  $$ |  $$\ $$ |  $$ |  $$ |     $$ |  $$ |  $$ |$$ |\$$$ |$$\   $$ |
-- $$ | \$$ | $$$$$$  |  $$ |   $$$$$$\ $$ |      $$$$$$\ \$$$$$$  |$$ |  $$ |  $$ |   $$$$$$\  $$$$$$  |$$ | \$$ |\$$$$$$  |
-- \__|  \__| \______/   \__|   \______|\__|      \______| \______/ \__|  \__|  \__|   \______| \______/ \__|  \__| \______/

function notifications(notitype, message, time)
    -- Change this trigger for your notification system keeping the variables
    -- Example:
    if Config.Framework == "esx" then
        ESX.ShowNotification(message)
    elseif Config.Framework == "qb" or Config.Framework == "qbox" then
        QBCore.Functions.Notify(message, notitype, time)
    end
end

-- Notifications types:
Noti.info = "info"
Noti.check = "success"
Noti.error = "error"

-- Notification time:
Noti.time = 5000


-- $$$$$$$$\  $$$$$$\  $$$$$$$\   $$$$$$\  $$$$$$$$\ $$$$$$$$\ 
-- \__$$  __|$$  __$$\ $$  __$$\ $$  __$$\ $$  _____|\__$$  __|
--    $$ |   $$ /  $$ |$$ |  $$ |$$ /  \__|$$ |         $$ |   
--    $$ |   $$$$$$$$ |$$$$$$$  |$$ |$$$$\ $$$$$\       $$ |   
--    $$ |   $$  __$$ |$$  __$$< $$ |\_$$ |$$  __|      $$ |   
--    $$ |   $$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |         $$ |   
--    $$ |   $$ |  $$ |$$ |  $$ |\$$$$$$  |$$$$$$$$\    $$ |   
--    \__|   \__|  \__|\__|  \__| \______/ \________|   \__|

-- Target system, use "qb-target", "ox_target", etc...
Config.Target = "qb-target"

-- Target function, used to add the target to the sticky note prop
function target(element, noteIdentifier)
   exports[Config.Target]:AddTargetEntity(element, {
        options = {
            {
                icon = "fas fa-note-sticky",
                label = Config.canRewrite and Lang.editStickyNote or Lang.openStickyNote,
                action = function(entity)
                    playAnimation("anim@mp_player_intmenu@key_fob@", "fob_click", 4.0, 1.0, -1, 49, 0, 0, 0, 0)
                    openStickyNoteRead(entity)
                end
            },
            {
                icon = "fas fa-trash",
                label = Lang.deleteNote,
                action = function(entity)
                    playAnimation("anim@mp_player_intmenu@key_fob@", "fob_click", 4.0, 1.0, -1, 49, 0, 0, 0, 0)
                    deleteNote(entity)
                end
            }
        },
        distance = 3.0
    })
end

-- $$\        $$$$$$\  $$\   $$\  $$$$$$\  $$\   $$\  $$$$$$\   $$$$$$\  $$$$$$$$\ 
-- $$ |      $$  __$$\ $$$\  $$ |$$  __$$\ $$ |  $$ |$$  __$$\ $$  __$$\ $$  _____|
-- $$ |      $$ /  $$ |$$$$\ $$ |$$ /  \__|$$ |  $$ |$$ /  $$ |$$ /  \__|$$ |      
-- $$ |      $$$$$$$$ |$$ $$\$$ |$$ |$$$$\ $$ |  $$ |$$$$$$$$ |$$ |$$$$\ $$$$$\    
-- $$ |      $$  __$$ |$$ \$$$$ |$$ |\_$$ |$$ |  $$ |$$  __$$ |$$ |\_$$ |$$  __|   
-- $$ |      $$ |  $$ |$$ |\$$$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |      
-- $$$$$$$$\ $$ |  $$ |$$ | \$$ |\$$$$$$  |\$$$$$$  |$$ |  $$ |\$$$$$$  |$$$$$$$$\ 
-- \________|\__|  \__|\__|  \__| \______/  \______/ \__|  \__| \______/ \________|

Lang.openStickyNote = "Read the sticky note"
Lang.editStickyNote = "Read/Edit sticky note"
Lang.deleteNote = "Delete sticky note"
Lang.noPermission = "You don't have permission to delete this note"
Lang.options = "~g~[E]~w~ Place sticky note here  ~r~[X]~w~ Cancel"
Lang.allNotesDeleted = "All sticky notes have been deleted"
Lang.allNotesError = "Error deleting notes, check the server console for more info"

Server config file

if Config.Framework == "esx" then
    ESX = exports["es_extended"]:getSharedObject()
elseif Config.Framework == "qb" or Config.Framework == "qbox" then
    QBCore = exports["qb-core"]:GetCoreObject()
else
    print("Unrecognized framework")
end


function CheckItem(item)
    if Config.Framework == "esx" then
        local player = ESX.GetPlayerData()
        for _, v in pairs(player.inventory) do
            if v.name == item and v.count > 0 then
                return true
            end
        end
    elseif Config.Framework == "qb" or Config.Framework == "qbox" then
        local player = QBCore.Functions.GetPlayerData()
        for _, v in pairs(player.items) do
            if v.name == item and v.amount > 0 then
                return true
            end
        end
    else
        print("Unrecognized framework")
    end
end

-- $$\   $$\  $$$$$$\  $$$$$$$$\  $$$$$$\  $$$$$$$\  $$\       $$$$$$$$\       $$$$$$\ $$$$$$$$\ $$$$$$$$\ $$\      $$\ 
-- $$ |  $$ |$$  __$$\ $$  _____|$$  __$$\ $$  __$$\ $$ |      $$  _____|      \_$$  _|\__$$  __|$$  _____|$$$\    $$$ |
-- $$ |  $$ |$$ /  \__|$$ |      $$ /  $$ |$$ |  $$ |$$ |      $$ |              $$ |     $$ |   $$ |      $$$$\  $$$$ |
-- $$ |  $$ |\$$$$$$\  $$$$$\    $$$$$$$$ |$$$$$$$\ |$$ |      $$$$$\            $$ |     $$ |   $$$$$\    $$\$$\$$ $$ |
-- $$ |  $$ | \____$$\ $$  __|   $$  __$$ |$$  __$$\ $$ |      $$  __|           $$ |     $$ |   $$  __|   $$ \$$$  $$ |
-- $$ |  $$ |$$\   $$ |$$ |      $$ |  $$ |$$ |  $$ |$$ |      $$ |              $$ |     $$ |   $$ |      $$ |\$  /$$ |
-- \$$$$$$  |\$$$$$$  |$$$$$$$$\ $$ |  $$ |$$$$$$$  |$$$$$$$$\ $$$$$$$$\       $$$$$$\    $$ |   $$$$$$$$\ $$ | \_/ $$ |
--  \______/  \______/ \________|\__|  \__|\_______/ \________|\________|      \______|   \__|   \________|\__|     \__|

if Config.Framework == "esx" then
    ESX.RegisterUsableItem(
        Config.stickyNoteItem,
        function(source)
            local xPlayer = ESX.GetPlayerFromId(source)
            xPlayer.removeInventoryItem(Config.stickyNoteItem, 1)
            TriggerClientEvent("bit-stickynotes:openUI", source)
        end
    )
elseif Config.Framework == "qb" or Config.Framework == "qbox" then
    QBCore.Functions.CreateUseableItem(
        Config.stickyNoteItem,
        function(source, item)
            local Player = QBCore.Functions.GetPlayer(source)
            Player.Functions.RemoveItem(Config.stickyNoteItem, 1)
            TriggerClientEvent("bit-stickynotes:openUI", source)
        end
    )
end

-- $$$$$$\ $$$$$$$\  $$$$$$$$\ $$\   $$\ $$$$$$$$\ $$$$$$\ $$$$$$$$\ $$$$$$\ $$$$$$$$\ $$$$$$$\  
-- \_$$  _|$$  __$$\ $$  _____|$$$\  $$ |\__$$  __|\_$$  _|$$  _____|\_$$  _|$$  _____|$$  __$$\ 
--   $$ |  $$ |  $$ |$$ |      $$$$\ $$ |   $$ |     $$ |  $$ |        $$ |  $$ |      $$ |  $$ |
--   $$ |  $$ |  $$ |$$$$$\    $$ $$\$$ |   $$ |     $$ |  $$$$$\      $$ |  $$$$$\    $$$$$$$  |
--   $$ |  $$ |  $$ |$$  __|   $$ \$$$$ |   $$ |     $$ |  $$  __|     $$ |  $$  __|   $$  __$$< 
--   $$ |  $$ |  $$ |$$ |      $$ |\$$$ |   $$ |     $$ |  $$ |        $$ |  $$ |      $$ |  $$ |
-- $$$$$$\ $$$$$$$  |$$$$$$$$\ $$ | \$$ |   $$ |   $$$$$$\ $$ |      $$$$$$\ $$$$$$$$\ $$ |  $$ |
-- \______|\_______/ \________|\__|  \__|   \__|   \______|\__|      \______|\________|\__|  \__|

function GetIdentifier(source)
    if Config.Framework == "esx" then
        local xPlayer = ESX.GetPlayerFromId(source)
        return xPlayer.identifier
    elseif Config.Framework == "qb" or Config.Framework == "qbox" then
        local Player = QBCore.Functions.GetPlayer(source)
        return Player.PlayerData.citizenid
    end
end