[QB] Skills - Modern Affordable

A script by krane_rcc

No reviews yet.
[QB] Skills - Modern Affordable main image

Full Description

Screenshot_17

Code is accessible No
Subscription-based No
Lines (approximately) 400+
Requirements QBCore
Support Yes

Preview: https://www.youtube.com/watch?v=5T1NCKQGxDE

Please note that this Skills resource is its inception and it is subject to changes in UI and it will be expanded with free updates and new skills to the guys who already bought it


How does it work

Hi, so this is my version of the “skills” problem in qbcore, currently there is only 2 scripts for skills that i know of and both of then don’t solve the problem i solve: “Decent ui, with a complex and simple to understand backend with endless expanding potential”

90% of the code is accessible, and the rest 10% is available using exports.


How to implement it

You have exports in here to help you guide yourself around adding and removing skills and whatnot

SERVER.LUA

--[[
  exports("update", function(id) update(id) end)
  exports("add_skill", function(skill, progress, id) add_skill(skill, progress, id) end)
  exports("remove_skill", function(skill, id) remove_skill(skill, id) end)
  exports("add_progress", function(skill, progress, id) add_progress(skill, progress, id) end)
  exports("remove_progress", function(skill, progress, id) remove_progress(skill, progress, id) end)
  exports("check_player_skills", function(id) return check_player_skills(id) end)
  exports("has_skill", function(skill, id) return has_skill(skill, id) end)
]]

exports['stats']:update(1) --update id 1
exports['stats']:add_skill('🔫|Shooting', 1, 1) --add skill shooting with progress 1 to player id 1
exports['stats']:remove_skill('🔫|Shooting', 1) --remove skill shooting from player id 1
exports['stats']:add_progress('🔫|Shooting', 1, 1) --add progress 1 to skill shooting for player id 1
exports['stats']:remove_progress('🔫|Shooting', 1, 1) --remove progress 1 from skill shooting for player id 1

local has_driving =  exports['stats']:has_skill('🚗|Driving', 1)
print(has_driving)

for _, skill_data in pairs(exports['stats']:check_player_skills(1)) do
    print(skill_data.skill .. ': ' .. skill_data.progress) -- print each skill name and current progress
end

CLIENT.LUA

this is subject to change to an exports approach, but for now you use this:


TriggerServerEvent("krane-stats-add_skill", "SKILL_NAME", 50) -- this will add the skill: SKILL_NAME with 50 progress to the player (source)
TriggerServerEvent("krane-stats-remove_skill", "SKILL_NAME") -- this will remove the skill: SKILL_NAME from the player (source)
TriggerServerEvent("krane-stats-add_progress", "SKILL_NAME", 50) -- this will add 50 progress to the skill: SKILL_NAME of the player (source)
TriggerServerEvent("krane-stats-remove_progress", "SKILL_NAME", 50) -- this will remove 50 progress from the skill: SKILL_NAME of the player (source)

function get_skills_from_server()
    local skills = nil
    TriggerServerEvent("krane-stats-get-skills") -- this will return the skills of the player (source)
    RegisterNetEvent("krane-stats-get-skills", function(data) skills = data end)
    while skills == nil do Wait(0) end
    return skills
end
for _, skill_data in pairs(get_skills_from_server()) do
    print(skill_data.skill .. ": " .. skill_data.progress)
end

In this current state, this script will help the developers alot since they don’t need to make a skill system for their server, and this script has all the implementation in it, just modify the ui and it’s the bomb

There are alot of safety net implementations for easy of integration, for example if you do add_progress to a skill that doens’t exist, it will automatically implement it during the execution so feel free to try and break it :smile:

If you don’t know to code

I have created demo files inside the client folder to help you guide yourself:

DRIVING.lua

This will increase your driving skill once every second if it detects you driving and waits 1 more second just because

CreateThread(function()
    while true do
        Wait(1000)
        if IsPedInAnyVehicle(PlayerPedId(), false) then
            local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
            if GetPedInVehicleSeat(vehicle, -1) then
                if GetEntitySpeed(vehicle) > 5 then
                    TriggerServerEvent("krane-stats-add_progress", "🚗|Driving", 1)
                    Wait(1000)
                end
            end
        end
    end
end)

SHOOTING.lua

CreateThread(function()
    while true do
        Wait(0)
        if IsPedShooting(PlayerPedId()) then
            TriggerServerEvent("krane-stats-add_progress", "🔫|Shooting", 1)
            Wait(1000)
        end
    end
end)

The Market

Price 4.99€: https://krane.tebex.io/package/5207324

The addons that are created for the script resource, will be available and free to download from the link in the config.lua file.
Support will also be found on there, with a ticketing system so no issue is lost to chat

UPDATES


Update 1

Update 1

Added new export for CLIENT and SERVER

--[[ CLIENT
exports("get_current_progress", function(skill_name)
    return get_current_progress(skill_name)
end)
]]
Can be ran using:
exports['stats']:get_current_progress(skill_name)

--[[ SERVER
exports("get_current_progress", function(skill, id) return get_current_progress(skill, id) end)
]]
exports['stats']:get_current_progress(skill_name, player_id)

Fixed the issue with js not decrease on progress_remove()

Implemented the driving.lua script properly
How it works:
Everytime you enter the vehicle, a progress is counted in the background and updated every 7.5seconds (to not explode the server with requests)
If you drive normally you keep going up the progress
If you crash you will be penalized (removing progress)
If you get above 25% progress you get special abilities (configurable)
At 25% you, as a driver, when entering a vehicle, that vehicle becomes 20% faster WHILE you are inside of it
At 50% the speed bonus goes to 40% faster, and you unlock the health_multiplier ability (basically any vehicle you enter doubles it’s HP if it has not been damaged, so you don’t abuse it the vehicle must be in top condition for this to work)
At 75% speed bonus 60%
At 100% speed bonus 80%
If you fall below any % due to crashing the vehicle, you lose the bonuses applied to you as a driver.

Update is available to be downloaded from your keymaster if you have bought the script, also the script stand-alone verison (driver.lua) can be found on the support room from your “config.lua”, if you already bought the script and just want to implement a new addon

Update 2

Update 2

Added check for progress so it won’t go over 100 in case you add more

old

if v.progress >= 100 then

new

if v.progress >= 100 or v.progress + progress >= 100 then 

Added integration with [QB] Stop Violence ([QB] Stop Violence Against PEDS)

Update 3

Old UI:


New UI:
Screenshot_13

Added Running.lua script
You will have to run for a certain amount of time, after which you will get updated, when you:

  1. 25% progress = 5% faster run
  2. 50% progress = 10% faster run
  3. 75% progress = 15% faster run
  4. 100% progress = 20% faster run

This will allow you to outpace ANYONE that doesn’t work on this running skill

Added DETAILS on skills that you can manipulate using HTML
Preview:

Added new exports and triggers

--[[ SERVER
exports("set_details", function(skill, details, id) set_details(skill, details, id) end)
]]
exports['stats']:set_details("SKILL_NAME", "<p>html, or simple text</p>", id_of_player)

--[[ CLIENT 
]]
TriggerServerEvent("krane-stats-set_details", "SKILL_NAME", "<p>details</p>")

Added some exceptions when you call from client which hasn’t yet logged it

If not Player then return PROPER_DATA_TYPE end

it won’t affect your logic, but it will return empty lists and 0 or false depending on the expected result