# Functions/Events

### server/ecitable-main.lua

#### Bank Reward System

#### Event: `enyo-doctorsim:giveBankMoney`

**Purpose:** Give money to a player’s bank depending on the configured framework.

**Validation Checks:**

```lua
if not amount or type(amount) ~= "number" or amount < 1 then
    print(("[WARNING] Invalid or missing amount provided by player %s"):format(playerId))
    return
end
```

**Framework-specific behavior:**

```lua
-- QBCore
Player.Functions.AddMoney("bank", amount, "reward")

-- ESX
xPlayer.addAccountMoney("bank", amount)

-- Standalone
bankAccounts[playerId] = bankAccounts[playerId] + amount
TriggerClientEvent("chat:addMessage", playerId, {
    args = { "[BANK]", "You received $" .. amount }
})
```

***

#### Job Validation System

#### Function: `HasRequiredJob(playerSource)`

**Purpose:** Checks if a player has the required job from:

```lua
Config.RequiredJob
```

**Returns:**

```lua
true  -- Player has the required job
false -- Player does NOT have the required job
```

***

#### ESX Job Check

```lua
local xPlayer = ESX.GetPlayerFromId(playerSource)
if xPlayer and xPlayer.getJob() then
    jobName = xPlayer.getJob().name
end
return jobName == Config.RequiredJob
```

***

#### QBCore Job Check

```lua
local qbPlayer = Framework.Functions.GetPlayer(playerSource)
if qbPlayer and qbPlayer.PlayerData and qbPlayer.PlayerData.job then
    jobName = qbPlayer.PlayerData.job.name
end
return jobName == Config.RequiredJob
```

***

#### Standalone Job Check

By default, standalone mode **always returns true**:

```lua
print('WARNING: Job check is running in standalone mode. Add custom logic!')
return true
```

**Recommended integration for standalone:**

```lua
jobName = exports['your-job-script']:GetPlayerJob(playerSource)
return jobName == Config.RequiredJob
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://enyo-scripts.gitbook.io/documentations/fivem-scripts/doctor-simulator-job/functions-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
