> For the complete documentation index, see [llms.txt](https://botiv.gitbook.io/rdr2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://botiv.gitbook.io/rdr2/reward-loyalty-and-total-playtime.md).

# Reward Loyalty and Total playtime

### 🟧 Server Side

#### 🔌 Export: Get Player Game Time

Retrieve a player’s total playtime (in minutes and hours) with this export:

```lua
local TimePlayed = exports.bt_primeco:getPlayerGameTime(source)
print("Minute : " .. TimePlayed.minute .. " Hour : " .. TimePlayed.hour)
```

* Returns a table:
  * `minute` : Total minutes played
  * `hour` : Total hours played

***

### ⚙️ Configuration Example (`config.lua`)

```lua
Config = {
    discord_webhook  = "",            -- Discord webhook URL
    discord_log_name = "BT_PRIMECO",  -- Discord log title
    MAX_CONNECT_TIME = 240,           -- Minutes before FINAL_REWARD (default 4h)
    REFRESH_TIME     = 60,            -- Refresh interval (seconds)
    CUSTOM_REWARD    = false,         -- Set to true to use your own CustomReward function
    REWARD_PER_HOUR  = { TYPE = 0, MIN = 1, MAX = 3 }, -- Hourly reward
    FINAL_REWARD     = { TYPE = 2, MIN = 1, MAX = 1 }, -- Final reward after MAX_CONNECT_TIME
    MONEY_NAME       = "$",
    GOLD_NAME        = "Gold",
    ROL_NAME         = "Diams",
    THANKS_MESSAGE   = "Thank you for you fidelity :)",
    REWARD_MESSAGE   = "Reward for %s hours played",
    CURRENCY_MSG     = "+ %s %s"
}
```

***

### 📝 Custom Rewards

Set `CUSTOM_REWARD = true` to handle rewards yourself with the `CustomReward(source, timeSinceLastReboot, totalPlayTime)` function.

**Example for VORP:**

```lua
if timeSinceLastReboot == 2 then -- 2 hours since last reboot
    Character.addCurrency(1, 20) -- Add 20 Gold
end
if totalPlayTime == 100 then     -- 100 total hours
    Character.addCurrency(0, 50) -- Add 50 $
end
```

**Example for RedEM:**

```lua
if timeSinceLastReboot == 2 then
    User.AddMoney(20) -- Add 20 $
end
if totalPlayTime == 100 then
    User.AddBankMoney(50) -- Add 50 $ to bank account
end
```

***

### 📌 Notes

* Discord logging is supported for playtime/reward events.
* Currency types and reward values are fully configurable.
* Use the export to display or automate in-game playtime rewards, milestones, or loyalty perks.
