# Installation

## Installing Dependencies

Make sure you install the latest versions and follow the documentation of the scripts, the Limited Life(s) script needs to start after all the dependencies start!

1. [ox\_lib](https://github.com/overextended/ox_lib)
2. [ox\_mysql](https://github.com/overextended/oxmysql)
3. [qbx\_core](https://github.com/Qbox-project/qbx_core) / [qb-core](https://github.com/qbcore-framework/qb-core)

## Config

Default config file.

```lua
Config = {}

Config.Debug = true

Config.AmountOfLives = 5 -- amount of lives a playter has, when they reach 5 their character gets deleted
Config.AdminPerms = 'group.admin' -- Perms needed to execute /addlifes and /checklifes
```

## Add SQL

Add the sql from lifes.sql to your database or just copy this snippet below\\

```sql
CREATE TABLE IF NOT EXISTS `player_lives` (
  `citizenid` varchar(50) NOT NULL DEFAULT 'none',
  `lives_spent` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`citizenid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
```

## Event placement&#x20;

This is where you should put  the server side event to remove a life, below is a example to put in qbx\_medical. You can choose where to place the event (server side) to remove a life, so it's up to you when you want to remove them, snippet below removes lifes when a player respawns (qbx only).

```lua
-- Replace the function
-- qbx_medical/server/main.lua - line 40

---@param player table|number
local function revivePlayer(player)
	if type(player) == 'number' then
		player = exports.qbx_core:GetPlayer(player)
	end

	TriggerEvent('yettiLives:server:removeLife', player.PlayerData.source)
	TriggerClientEvent('qbx_medical:client:playerRevived', player.PlayerData.source)
end
```
