# Skill System - QBCore

### 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. \
\\

![](https://1149355704-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBYDBAQDN7jtuQiChmqnn%2Fuploads%2FC9F6ngNHgMgv9Bz4kzOD%2Funknown.png?alt=media\&token=43eee36d-88fc-4eb2-8f0c-7698ac25063a)

### 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!

### INSTALLATION GUIDE

1. Go to qb-core/server/player.lua line 583 and add our sql table to the current table in your files.&#x20;
2. Make sure to not replace our example with yours. Simply add <mark style="color:red;">{ table = 'reflex\_skillsystem' },</mark> to your table.

```lua
local playertables = { -- Add tables as needed...
    { table = 'reflex_skillsystem' }
}
```

### 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 citizenid...below is a example of how to do this.

```lua
    QBCore.Functions.CreateCallback('reflex-fishing:getPlayerInfo', function(source, cb)
        local xPlayer = QBCore.Functions.GetPlayer(source)
        local citizenid = xPlayer.PlayerData.citizenid
        local data = {}
  
        table.insert(data, {
            citizenid = citizenid,
        })
  
        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('QBCore:Client:OnPlayerLoaded')
    AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
        QBCore.Functions.TriggerCallback('reflex-fishing:getPlayerInfo', function(data)
            if (data ~= nil) then

                local id = data[1].citizenid
                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()
	QBCore.Functions.TriggerCallback('reflex-fishing:getPlayerInfo', function(data)
		if (data ~= nil) then
	
                local id = data[1].citizenid
                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 finished3 = exports["reload-skillbar"]:taskBar(math.random(900,2000),math.random(5,7))
	if finished3 ~= 100 then
	    QBCore.Functions.Notify("The fish has got away!", 'error', 2500)
	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.

<table><thead><tr><th>Button</th><th width="238.33333333333331">Description</th></tr></thead><tbody><tr><td>F10</td><td>Opens The UI</td></tr></tbody></table>

### 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.
