# Skill System - ESX

### INTRODUCTION

Thank you for purchasing Reflex Skill System. This guide is to help you better understand how our system operates and how to implement it into your server properly. We highly recommend having some basic knowledge in LUA before attempting to implement this into your server. \
\
We designed our skill system so it can be used for literally anything. From making more money based on your skill level to having a completely advanced job that rewards different items depending on your level. Leveling works by gaining XP. Once you have gathered 1000 XP you will advance to the next level. There is so much our skill system has to offer.

&#x20;

![](https://1149355704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBYDBAQDN7jtuQiChmqnn%2Fuploads%2FCG55Oflk4arxxdoLB97j%2Fimage.png?alt=media\&token=fdff9e62-6351-4136-bf61-70507bb7ac0a)

### START HERE

1. Unzip the <mark style="color:red;">reflex\_skillsystem.zip</mark>
2. Place resource inside your server files
3. Go to server.cfg or resource.cfg (depending on which one you use) and add ensure <mark style="color:red;">reflex\_skillsystem</mark>
4. **WARNING:** DO NOT RENAME THIS RESOURCE OR MODIFY THE ENCRYPTED FILES IN ANY WAY!

### EXPORTS

We have designed our system to include 3 exports for you to use. This should make it easy for you to design new scripts or make it easy for you to implement our system into a current script on your server.&#x20;

**CHECKING EXPERIENCE**

There is a easy way for you to get the players current experience. You would want to run this export if you were trying to tell the script what to do if the player is a certain level. A example of the export is listed below.

```lua
exports.reflex_skillSystem:checkExp(id, 'Fishing')
```

After running this export our system will return the players current XP and current Level.

#### ADDING EXPERIENCE

Adding experience is as simple as running our export. If you wanted to add 500 experience to a player who just successfully caught a fish you would run this export below.

```lua
exports.reflex_skillSystem:addExp(id, 500, 'Fishing')
```

After you run this export if you check you the SQL table and look at Column "Experience" and you should now see that this player has 500 Experience.

#### ADDING SKILLS

We have made it easy for you to add skills to your server. You can simply run this export below when a player either does a action or when they load in. There's 3 things you would to fill in for the export...

1. What skill are you wanting to create? (EX: Fishing)
2. What Icon would you like to use? (<https://fontawesome.com/>)
3. Do you want the skill to be visible on the menu? (true or false)

Below is a example of how you would use this export properly...

```lua
exports.reflex_skillSystem:addSkill('Fishing', '<i class="fas fa-fish"></i>', true)
```

### USAGE AND EXAMPLES

Finally, we would like to show you how to implement this into a fishing script properly.&#x20;

* First we need to create a callback that will return the players uID...below is a example of how to do this.

```lua
    ESX.RegisterServerCallback('reflex-fishing:getPlayerInfo', function(source, cb)
        local _source = source
        local xPlayer = ESX.GetPlayerFromId(_source)
        local uID = xPlayer.getIdentifier()
        local data = {}
  
        table.insert(data, {
            uID = uID,
        })
  
        cb(data)
    end)
```

* Next we would then need to create a client event that would create the skill. In this example we create the event when the player loads in, however there is many other ways to do this.

```lua
    RegisterNetEvent('esx:playerLoaded')
    AddEventHandler('esx:playerLoaded', function()
        ESX.TriggerServerCallback('reflex-fishing:getPlayerInfo', function(data)
            if (data ~= nil) then

                local id = data[1].uID
                local fishingIcon= '<i class="fas fa-fish"></i>'
                local skillFishing = exports.reflex_skillSystem:checkExp(id, 'Fishing')

                if not next(skillFishing) then
                    exports.reflex_skillSystem:addSkill('Fishing', fishingIcon, true)
                else
                    print('reflex_skillsystem Fishing skill already exists.')
                end
            end
        end)
    end)
```

* Lastly we would need to create a function to give the XP to the player

```lua
function GiveFishingXP()
	ESX.TriggerServerCallback('reflex-fishing:getPlayerInfo', function(data)
		if (data ~= nil) then
	
                local id = data[1].uID
                local skill = exports.reflex_skillSystem:checkExp(id, 'Fishing')
		local level = skill[1].level

		if level <= 4 then --Event below for what to do at level 0 - 4
		    exports.reflex_skillSystem:addExp(id, 750, 'Fishing')
		elseif level <= 9 then --Event below for what to do at level 5 - 9
                    exports.reflex_skillSystem:addExp(id, 500, 'Fishing')
                else
                    -- Trigger whatever here if the level is 10 or more.
	        end
	     end
	 end)
      end
```

* This event below is a example of how you could trigger the above event to give a player XP

```lua
RegisterNetEvent('reflex-fishing:skillbar')
AddEventHandler('reflex-fishing:skillbar', function()
    local finished = exports["skillbar"]:taskBar(math.random(900,2000),math.random(5,7))
	if finished ~= 100 then
	    -- Notification Trigger Here For Error.
	else
	    GiveFishingXP()
	end
    end)
```

### KEYBINDS

Keybinds can be configured either by the usersettings folder or in game by pressing escape and going to SETTINGS>Key Bindings>FiveM and look for <mark style="color:red;">refles\_skillsystem Open Skills Menu</mark> from here you can now change the keybinding for opening the UI.

| Button | Description  |
| ------ | ------------ |
| F10    | Opens The UI |

### COMMANDS

The default commands can be changed via the usersettings folder under config.lua

| Command | Description  |
| ------- | ------------ |
| /skills | Opens The UI |

### SUPPORT

#### CURRENT COMMON ISSUES

There is currently <mark style="color:red;">NO</mark> common issues or bugs at this current time.

#### CONTACT US

If you are having issues with our script feel free to join our discord (<https://discord.gg/dkpm8HFXCA>) and open a ticket.

#### CUSTOM WORK?

If you are having trouble implementing our system into one of your resources we can do this for you. Please open a ticket in our discord to acquire about this.
