Configuration

Shared.lua file

Config, Noti = {}, {}
-- $$$$$$\   $$$$$$\  $$\   $$\ $$$$$$$$\ $$$$$$\  $$$$$$\  $$\   $$\ $$$$$$$\   $$$$$$\ $$$$$$$$\ $$$$$$\  $$$$$$\  $$\   $$\
-- $$  __$$\ $$  __$$\ $$$\  $$ |$$  _____|\_$$  _|$$  __$$\ $$ |  $$ |$$  __$$\ $$  __$$\\__$$  __|\_$$  _|$$  __$$\ $$$\  $$ |
-- $$ /  \__|$$ /  $$ |$$$$\ $$ |$$ |        $$ |  $$ /  \__|$$ |  $$ |$$ |  $$ |$$ /  $$ |  $$ |     $$ |  $$ /  $$ |$$$$\ $$ |
-- $$ |      $$ |  $$ |$$ $$\$$ |$$$$$\      $$ |  $$ |$$$$\ $$ |  $$ |$$$$$$$  |$$$$$$$$ |  $$ |     $$ |  $$ |  $$ |$$ $$\$$ |
-- $$ |      $$ |  $$ |$$ \$$$$ |$$  __|     $$ |  $$ |\_$$ |$$ |  $$ |$$  __$$< $$  __$$ |  $$ |     $$ |  $$ |  $$ |$$ \$$$$ |
-- $$ |  $$\ $$ |  $$ |$$ |\$$$ |$$ |        $$ |  $$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |  $$ |     $$ |  $$ |  $$ |$$ |\$$$ |
-- \$$$$$$  | $$$$$$  |$$ | \$$ |$$ |      $$$$$$\ \$$$$$$  |\$$$$$$  |$$ |  $$ |$$ |  $$ |  $$ |   $$$$$$\  $$$$$$  |$$ | \$$ |
-- \______/  \______/ \__|  \__|\__|      \______| \______/  \______/ \__|  \__|\__|  \__|  \__|   \______| \______/ \__|  \__|
-- Use "esx", "qb" or "qbox"
Config.Framework = "qb"
-- Change the language of the script ("en", "es")
Config.language = "en"
-- If true, the player will be forced to use first person
Config.forceFirstPerson = true
-- If true, the player will die if he fails the ghost selection
Config.dieOnFailSelection = true
-- Teleport the player after finishing the mission
Config.teleportAfterMission = {
    active = true, -- Set to true to enable the teleportation after the mission
    ifSuccess = vector4(1641.34, 3567.89, 35.54, 291.07), -- Coords where the player will be teleported if he succeeds
    ifFail = vector4(1452.44, 3754.53, 31.93, 301.11) -- Coords where the player will be teleported if he fails
}
-- Set to true to give a reward item on successful ghost identification. Change the reward in the config/s_config.lua file.
Config.giveReward = true
-- Debug mode (prints useful info in the console)
Config.debug = false

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

function notifications(notitype, message, time)
    -- Change this trigger for your notification system keeping the variables
    --
    --QBCore:
    QBCore.Functions.Notify(message, "error", time)
    --
    --ESX:
    --TriggerEvent("esx:showNotification", message, notitype, time)
end

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

-- Notification time:
Noti.time = 5000

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

-- Function for the use of the target in intro ped

-- If false, it will use the default interaction (E)
Config.useTarget = false

function entityTarget(entity, event, label)
    exports["qb-target"]:AddTargetEntity(
        entity,
        {
            options = {
                {
                    event = event,
                    icon = "fas fa-ghost",
                    label = label
                }
            },
            distance = 2.5
        }
    )
end

function customDrawText()
    TriggerEvent("bit-interact:Start", "E", "Press to start the hunt")
    if IsControlJustReleased(0, 38) then
        TriggerEvent("bit-ghosts:startGame")
    end
end

function closeUIText()
    SetTextFont(4)
    SetTextProportional(0)
    SetTextScale(0.6, 0.6)
    SetTextColour(255, 255, 255, 255)
    SetTextDropShadow(0, 0, 0, 0, 255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextCentre(1)
    SetTextEntry("STRING")
    AddTextComponentString("Press X to stop using the item")
    DrawText(0.5, 0.8)
end

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

-- Polyzone area to block the random ped spawning
PolyzonePoints = {
    vector2(1479.61, 3582.92),
    vector2(1589.39, 3644.67),
    vector2(1638.43, 3561.14),
    vector2(1522.05, 3504.69)
}
PolyzoneDebug = false

IntroPed = {
    model = "ig_priest",
    coords = vector4(1532.79, 3577.67, 34.44, 208.18)
}

GhostSpawnPoints = {
    vector4(1507.36, 3576.83, 38.74, 198.33),
    vector4(1536.11, 3593.32, 38.77, 248.28),
    vector4(1560.13, 3598.57, 38.78, 190.05),
    vector4(1543.36, 3592.19, 35.45, 118.64),
    vector4(1607.63, 3569.46, 38.78, 126.27),
    vector4(1599.55, 3591.86, 38.77, 336.79),
    vector4(1580.03, 3615.04, 38.78, 251.25)
}

Lights = {
    vector3(1511.62, 3573.19, 38.74),
    vector3(1540.64, 3588.29, 38.77),
    vector3(1556.9, 3600.56, 38.78),
    vector3(1545.3, 3593.07, 35.45),
    vector3(1606.53, 3570.66, 38.78),
    vector3(1595.08, 3587.13, 38.77),
    vector3(1579.85, 3616.92, 38.78)
}

Chairs = {
    ["prop_old_wood_chair_lod"] = {
        vector3(1514.45, 3570.38, 38.74),
        vector3(1555.27, 3598.58, 38.78),
        vector3(1556.86, 3604.63, 38.78),
        vector3(1537.42, 3586.89, 38.77),
        vector3(1543.54, 3596.68, 35.45),
        vector3(1605.96, 3569.97, 38.78),
        vector3(1599.43, 3585.04, 38.77),
        vector3(1591.27, 3586.59, 38.77),
        vector3(1596.45, 3595.95, 38.77),
        vector3(1577.52, 3613.78, 38.78)
    }
}

Props = {
    "v_ret_fh_pizza01",
    "v_res_tt_litter3",
    "ng_proc_paper_news_rag",
    "ng_proc_cigpak01c",
    "ng_proc_food_burg02c",
    "prop_ld_scrap",
    "ng_proc_food_chips01c",
    "ng_proc_food_chips01b",
    "ng_proc_brkbottle_02c",
    "ng_proc_paper_news_meteor",
    "v_res_tt_cancrsh02",
    "prop_spraygun_01",
    "prop_rub_litter_06",
    "v_ind_rc_rubbish",
    "ng_proc_food_bag02a",
    "ng_proc_litter_plasbot1",
    "ng_proc_brkbottle_02b",
    "ng_proc_litter_plasbot3",
    "m23_2_prop_m32_puddle_01a",
    "ng_proc_food_chips01a",
    "ng_proc_litter_plasbot2",
    "v_res_tt_cancrsh01",
    "m25_1_prop_m51_blood_smear_01a"
}

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

-- If true, the intro ped will give you the items when starting the game
Config.itemsDeliveredByIntroPed = true

-- List of items needed to play
Items = {
    ["spectralcodex"] = {
        command = "codex",
        label = "Spectral Codex",
        itemRequired = true
    },
    ["candle"] = {
        command = "candle",
        label = "Candle",
        itemRequired = true
    },
    ["cross"] = {
        command = "cross",
        label = "Cross",
        itemRequired = true
    },
    ["emf"] = {
        command = "emf",
        label = "EMF Reader",
        itemRequired = true
    },
    ["movementdetector"] = {
        command = "movementdetector",
        label = "Movement Detector",
        itemRequired = true
    },
    ["ouijaboard"] = {
        command = "ouijaboard",
        label = "Ouija Board",
        itemRequired = true
    },
    ["palosanto"] = {
        command = "palosanto",
        label = "Palo Santo",
        itemRequired = true
    },
    ["spiritbox"] = {
        command = "spiritbox",
        label = "Spirit Box",
        itemRequired = true
    },
    ["thermometer"] = {
        command = "thermometer",
        label = "Thermometer",
        itemRequired = true
    }
}

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

Lang = {
    ["start"] = "Start",
    ["noitem"] = "You don't have the required item",
    ["itemsProvided"] = "You've been given the necessary tools. For more information, use the Spectral Codex.",
    ["leftMissionZone"] = "You have left the mission area",
    ["Description"] = "Description",
    ["Evidence"] = "Evidence",
    ["firstPerson"] = "While you are on the mission, first-person view will be forced",
    ["noGhostSelected"] = "You must select a ghost to finish the mission",
    ["correctGhost"] = "Correct! You have identified the ghost",
    ["wrongGhost"] = "Wrong! The ghost was a "
}

Lang.intro =
    [[
 Welcome to the Spectral Codex, your comprehensive guide to the various ghosts you may encounter. <br/>
 Each enty provides essential information to help you identify and understand the spectral entities. <br/><br/>
 Stay vigilant, and may your encounters be enlightening.
]]

Lang.evidences = {
    ["ouijaBoard"] = "Ouija Board",
    ["spiritBox"] = "Spirit Box",
    ["crucifix"] = "Crucifix",
    ["candle"] = "Candle",
    ["emf"] = "EMF",
    ["movementDetector"] = "Mov Detector",
    ["palosanto"] = "Palo Santo",
    ["thermometer"] = "Thermometer",
    ["freezing"] = "Freezing Temperature",
    ["fullApparition"] = "Full Apparition",
    ["partialApparition"] = "Part. Apparition",
    ["objectLevitation"] = "Object Levitation",
    ["lightFlicker"] = "Light Flicker",
    ["moveChairs"] = "Moving Chairs",
    ["throwObjects"] = "Throwing Objects",
    ["windowKnocking"] = "Window Knocking",
    ["doorSlamming"] = "Door Slamming",
    ["whisperVoices"] = "Voices",
    ["footsteps"] = "Footsteps",
    ["childrenLaughter"] = "Children Laughter",
    ["knocking"] = "Knocking"
}

s_config.lua (server config):

function giveItems(playerID, item, amount)
    if Config.Framework == "esx" then
        local xPlayer = ESX.GetPlayerFromId(playerID)
        local itemFound = xPlayer.getInventoryItem(item)
        if itemFound == nil then
            xPlayer.addInventoryItem(item, amount)
            return
        end
    else
        local xPlayer = QBCore.Functions.GetPlayer(playerID)
        local itemFound = xPlayer.Functions.GetItemByName(item)
        if itemFound == nil then
            xPlayer.Functions.AddItem(item, amount)
            return
        end
    end
end

function deleteItems(playerID, item, amount)
    if Config.Framework == "esx" then
        local xPlayer = ESX.GetPlayerFromId(playerID)
        local itemFound = xPlayer.getInventoryItem(item)
        if itemFound ~= nil then
            xPlayer.removeInventoryItem(item, amount)
            return
        end
    else
        local xPlayer = QBCore.Functions.GetPlayer(playerID)
        local itemFound = xPlayer.Functions.GetItemByName(item)
        if itemFound ~= nil then
            xPlayer.Functions.RemoveItem(item, amount)
            return
        end
    end
end

function useableItems()
    if Config.Framework == "esx" then
        for k, v in pairs(Items) do
            ESX.RegisterUsableItem(
                k,
                function(source)
                    local xPlayer = ESX.GetPlayerFromId(source)
                    TriggerClientEvent("bit-ghosts:useItem", source, k)
                end
            )
        end
    else
        for k, v in pairs(Items) do
            QBCore.Functions.CreateUseableItem(
                k,
                function(source)
                    print("Item used: " .. k)
                    local xPlayer = QBCore.Functions.GetPlayer(source)
                    TriggerClientEvent("bit-ghosts:useItem", source, k)
                end
            )
        end
    end
end

RegisterNetEvent("bit-ghosts:giveFinalReward")
AddEventHandler(
    "bit-ghosts:giveFinalReward",
    function()
        --something
    end
)

Last updated