# Skill System

A comprehensive skill and XP system for FiveM servers that allows players to level up and improve their character's abilities through various skills.

## Features

* Dynamic XP and leveling system
* Multiple skill trees with customizable effects
* Support for both QB-Core and ESX frameworks
* Time-based XP gain system
* Multiple XP sources (driving, killing, missions)
* Customizable skill costs and effects
* Framework-agnostic design

## Installation

1. Download the resource
2. Place it in your resources folder
3. Add `ensure hate-skill` to your server.cfg
4. Configure the config.lua file according to your needs
5. Import the SQL file to your database
6. Start your server

## Configuration

### Main Configuration Options

```lua
Config.Debug = false -- Enable/disable debug mode
Config.Framework = "QB" -- Use "ESX" or "QB"
Config.BaseXP = 50 -- Base XP required for the first level
Config.XPMultiplier = 1.3 -- Multiplier for XP required for each subsequent level
Config.LevelCap = 50 -- Maximum level a player can reach
Config.PointsPerLevel = 1 -- Skill points awarded per level
```

### Skill Configuration

Each skill can be configured with:

* base: Base cost for the first level
* multiplier: Cost multiplier for each subsequent level
* maxLevel: Maximum level the skill can reach

```lua
Config.SkillCosts = {
    ['health'] = { base = 2, multiplier = 1.5, maxLevel = 16 },
    ['regen'] = { base = 2, multiplier = 1.5, maxLevel = 16 },
    ['stamina'] = { base = 2, multiplier = 1.5, maxLevel = 16 },
    ['stamina_regen'] = { base = 2, multiplier = 1.5, maxLevel = 16 },
    ['speed'] = { base = 2, multiplier = 1.5, maxLevel = 16 },
    ['swim'] = { base = 2, multiplier = 1.5, maxLevel = 16 },
    ['car_speed'] = { base = 2, multiplier = 1.5, maxLevel = 16 },
    ['boat_speed'] = { base = 2, multiplier = 1.5, maxLevel = 16 }
}
```

### Skill Effects

Each skill has customizable effects:

```lua
Config.SkillEffects = {
    health = { max_health_per_level = 10 }, -- +10 HP per level
    regen = { health_regen_per_level = 0.2 }, -- +0.2 HP/s health regeneration per level
    stamina = { max_stamina_per_level = 0.5 }, -- +5% max stamina per level
    stamina_regen = { stamina_regen_per_level = 0.25 }, -- +0.25/s stamina regeneration per level
    speed = { run_speed_per_level = 0.03 }, -- +3% run speed per level
    swim = { swim_speed_per_level = 0.02 }, -- +2% swim speed per level
    car_speed = { speed_per_level = 0.03 }, -- +3% car speed per level
    boat_speed = { speed_per_level = 0.05 } -- +5% boat speed per level
}
```

### Time-Based XP System

```lua
Config.TimeBasedXP = {
    enable = true, -- Enable or disable time-based XP gain
    interval = 5, -- Interval in minutes for time-based XP gain
    amount = 15 -- XP amount given to player at each interval
}
```

### XP Sources

```lua
Config.XPSources = {
    ['drive'] = { xp = 5, cooldown = 30000 }, -- XP for driving with a cooldown of 30 seconds
    ['kill'] = { xp = 10 }, -- XP for killing
    ['mission'] = { xp = 50 } -- XP for completing missions
}
```

## Exports

### Server Side Exports

```lua
exports['hate-skill']:AddXP(playerId, amount)
exports['hate-skill']:AddSkillPoints(playerId, amount)
exports['hate-skill']:GetPlayerLevel(source)
```

### Client Side Exports

```lua
exports['hate-skill']:AddXP(amount)
exports['hate-skill']:AddSkillPoints(amount)
exports['hate-skill']:GetPlayerLevel()
```

## Commands

* `/givexp [ID] [Amount]` - Add XP to a player
* `/addskillpoints [ID] [Amount]` - Add skill points to a player
* `/resetskills [ID]` - Reset a player's skills

## Important Notes

* The script is protected with escrow
* Server and client files are encrypted
* The script requires one of the supported frameworks (QB-Core or ESX)
* The script requires oxmysql for database operations

## Security Notice

This script is protected by FiveM's escrow system. The client and server-side code is encrypted and cannot be modified.
