# Custom Framework

If you run a framework other than ESX or QBCore, set `Config.Framework = "custom"` and fill in the stub files.

***

## Setup

```lua
-- editable/shared/config.lua
Config.Framework = "custom"
```

Two stub files are then loaded automatically:

| File                                   | Side   |
| -------------------------------------- | ------ |
| `editable/custom/framework_server.lua` | Server |
| `editable/custom/framework_client.lua` | Client |

***

## Server Stubs

Open `editable/custom/framework_server.lua` and implement each function:

```lua
CustomFramework.Server = {}

-- Return a table of online player server IDs.
CustomFramework.Server.GetPlayers = function()
    return {}
end

-- Return the player object for the given source, or nil.
CustomFramework.Server.GetPlayer = function(src)
    return nil
end

-- Return the unique character/player identifier string.
CustomFramework.Server.GetIdentifier = function(src)
    return nil
end

-- Return the display name of the player.
CustomFramework.Server.GetPlayerName = function(src)
    return 'Unknown'
end

-- Return the job name and grade level.
-- @return string|nil, number
CustomFramework.Server.GetPlayerJob = function(src)
    return nil, 0
end

-- Return the permission group of the player (e.g. "admin", "user").
CustomFramework.Server.GetPlayerGroup = function(src)
    return nil
end

-- Return the money amount for the given type ("cash", "bank", "black").
CustomFramework.Server.GetMoney = function(src, mtype)
    return 0
end

-- Add money. Return true on success.
CustomFramework.Server.AddMoney = function(src, amount, mtype, reason)
    return false
end

-- Remove money. Return true on success.
CustomFramework.Server.RemoveMoney = function(src, amount, mtype, reason)
    return false
end
```

***

## Client Stubs

Open `editable/custom/framework_client.lua` and implement each function:

```lua
CustomFramework.Client = {}

-- Return the local player's data table.
CustomFramework.Client.GetPlayerData = function()
    return {}
end

-- Return the local player's job name.
CustomFramework.Client.GetPlayerJob = function()
    return nil
end

-- Return the local player's job label.
CustomFramework.Client.GetPlayerJobLabel = function()
    return nil
end
```

***

## Example (OX Core)

```lua
-- framework_server.lua
CustomFramework.Server.GetPlayer = function(src)
    return Ox.GetPlayer(src)
end

CustomFramework.Server.GetIdentifier = function(src)
    local p = Ox.GetPlayer(src)
    return p and tostring(p.charId) or nil
end

CustomFramework.Server.GetPlayerJob = function(src)
    local p = Ox.GetPlayer(src)
    if not p then return nil, 0 end
    local job = p.get('job')
    return job and job.name, job and job.grade or 0
end
```

## Related pages

- [Overview](/koja-lib/frameworks/overview) — koja-lib abstracts the differences between ESX and QBCore so your scripts work on both without any changes.
- [Frameworks](/koja-lib/frameworks) — back to the section overview
