> For the complete documentation index, see [llms.txt](https://the-s-project.gitbook.io/the-s-project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://the-s-project.gitbook.io/the-s-project/standalone/integrations.md).

# Standalone Function

The interesting part starts here.

### When switching the config to standalone&#x20;

Lets see for example `client/checks_client.lua`\
this event checks what framework we set in the config and takes the player job\
to allow him to open the casino doors, in line 80 you will have to take your way\
of taking the player job and implement it that if the player job is set to

```lua
Config.authorizedJobs = 'police'
```

In line 80 implement your logic\
for example you can see how qbcore is doing it

```lua
PlayerJob = QBCore.Functions.GetPlayerData().job.name
```

```lua
RegisterNetEvent('s-casinoheist:client:doorlock')
AddEventHandler('s-casinoheist:client:doorlock', function()
    CreateThread(function()
        if Config.Framework == "ESX" then
            ESX = exports[Config.CoreName]:getSharedObject()
            PlayerData = ESX.GetPlayerData()
            PlayerJob = PlayerData.job.name
        elseif Config.Framework == "QB" then
            QBCore = exports[Config.CoreName]:GetCoreObject()
            while not QBCore.Functions.GetPlayerData().job do Citizen.Wait(100) end
            PlayerJob = QBCore.Functions.GetPlayerData().job.name
        else
            --standalone-- implement your logic here
        end
        if Config.debug then print("PlayerJob", PlayerJob) end
        while true do
            local playerPed = PlayerPedId()
            local playerCoords = GetEntityCoords(playerPed)
            -- Reset door interaction status for this iteration
            isNearDoor = false
            closestCategory = nil
            closestDoorId = nil
            -- Check proximity to doors and handle interaction
            for category, doors in pairs(Config.Doors) do
-- the rest of the code
-- ...
```

### All the places you will have to implement your logic

and again remember, all of this is optional it all depands if you want full integration

{% tabs %}
{% tab title="Framework Object - line 16" %}

```etlua
-- checks_server.lua - line 16 - optional
elseif Config.Framework == "QB" then
    QBCore = exports[Config.CoreName]:GetCoreObject()
else
    -- standalone here you will be able to grab your framework server object
end
```

{% endtab %}

{% tab title="Item Check - line 54" %}

<pre class="language-etlua"><code class="lang-etlua">-- checks_server.lua - s-casinoheist:hasitems
<strong>elseif Config.Framework == "QB" then
</strong>        if Config.debug then print("qb run hasitems") end
        local Player = QBCore.Functions.GetPlayer(source)
        local hasItem = false
        if Player and Player.PlayerData.items then
            for _, itemData in pairs(Player.PlayerData.items) do
                if itemData.name == item and (not amount or itemData.amount >= amount) then
                    hasItem = true
                    break
                end
            end
        end
        cb(hasItem)
    else
        if Config.debug then print("standalone run hasitems") end
        -- Implement your own logic for standalone.
        -- if player has the item cb(true)
        -- if player doesent have the item cb(false)
        cb(true)
    end
</code></pre>

{% endtab %}

{% tab title="Police Check - line 95" %}

```lua
-- checks_server.lua - s-casinoheist:policecheck
    elseif Config.Framework == "QB" then
        if Config.debug then print("qb run policecheck") end
        if Config.debug then print("current police", CurrentCops) end
        if CurrentCops >= Config.RequiredCops then
            cb(true)
            if Config.debug then print("callback s-casinoheist:policecheck is:", true) end
        else
            cb(false)
            if Config.debug then print("callback s-casinoheist:policecheck is:", false) end
        end
    else
        if Config.debug then print("standalone run policecheck") end
        local amount = 0
         -- Implement your own logic for standalone.
         -- Get the police count and verify if it meets the Config.RequiredCops
        if amount >= Config.RequiredCops then
            cb(true)
            if Config.debug then print("callback s-casinoheist:policecheck is:", true) end
        else
            cb(false)
            if Config.debug then print("callback s-casinoheist:policecheck is:", false) end
        end
    end
```

{% endtab %}

{% tab title="Police Alert - line 130" %}

```lua
    elseif Config.Framework == "QB" then
        if Config.debug then print("qb run") end
        local src = source
        local players = QBCore.Functions.GetPlayers(src)
        for i = 1, #players do
            local player = QBCore.Functions.GetPlayer(players[i])
            if (player.PlayerData.job.name == 'police' and player.PlayerData.job.onduty) then
                TriggerClientEvent('casinoheist:client:policeAlertconfig', players[i], coords)
            end
        end
    else
        if Config.debug then print("standalone run") end
        -- Implement your own logic for standalone.
        -- Trigger the event for all the cops in the server, see the example above
    end
```

{% endtab %}

{% tab title="Remove Item - line 155" %}

```lua
RegisterServerEvent("s-casinoheist:removeitem")
AddEventHandler("s-casinoheist:removeitem", function(item)
    if Config.Framework == "ESX" then
        if Config.debug then print("esx run RemoveItem") end
        local Player = ESX.GetPlayerFromId(source)
        if Config.Inventory == "regular" then
            Player.removeInventoryItem(item, 1)
        else
            exports.ox_inventory:RemoveItem(source, item, 1)
        end
    elseif Config.Framework == "QB" then
        if Config.debug then print("qb run RemoveItem") end
        local src = source
        if Config.Inventory == "qb-inventory" then
            exports[Config.Inventory]:RemoveItem(src, item, 1, false, 's-casinoheist:removeitem') -- todo : doc
        else
            exports.ox_inventory:RemoveItem(source, item, 1)
        end
    else
        if Config.debug then print("standalone run removeitem") end
        -- implement your own logic.a
    end
end)
```

{% endtab %}

{% tab title="Rewards - line 193 " %}

```lua
RegisterServerEvent('s-casinoheist:server:rewardItem')
AddEventHandler('s-casinoheist:server:rewardItem', function(reward)
    if Config.Framework == "ESX" then
        if Config.debug then print("esx run rewardItem") end
        local src = source
        local player = ESX.GetPlayerFromId(src)

        if player then
            if reward.item ~= nil then
                if Config.Inventory == "regular" then
                    player.addInventoryItem(reward.item, reward.count)
                else
                    exports.ox_inventory:AddItem(src, reward.item, reward.count)
                end
            else
                player.addMoney(reward.count)
            end
        end
    elseif Config.Framework == "QB" then
        if Config.debug then print("qb run rewardItem") end
        local src = source
        local player = QBCore.Functions.GetPlayer(src)
        if player then
            if reward.item ~= nil then
                player.Functions.AddItem(reward.item, reward.count)
                TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[reward.item], "add")
            else
                player.Functions.AddMoney('cash', reward.count, 'casino')
            end
        end
    else
        if Config.debug then print("standalone run rewardItem") end
        -- Implement your own logic for standalone.
    end
end)
```

{% endtab %}
{% endtabs %}
