Skip to content

Commit

Permalink
Merge pull request #19 from Project-Sloth/monkey
Browse files Browse the repository at this point in the history
Added support for qb-management and auto firing
  • Loading branch information
MonkeyWhisper authored Mar 19, 2023
2 parents 25f5465 + 3305059 commit e1c454e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ A script designed with a sleek and modern design for being able to display your
* Import [SQL](https://github.com/Project-Sloth/ps-multijob/blob/main/database.sql) into your database
* Ensure to server.cfg

# Linking to qb-management | Auto Firing
1. Find the following event
```
qb-bossmenu:server:FireEmployee
```
2. Insert the TriggerEvent right under the notification for 'Employee Fired!'. The TriggerEvent should be added twice, once near line 174 and once near line 199.

```
TriggerClientEvent('QBCore:Notify', src, "Employee fired!", "success")
TriggerEvent('ps-multijob:server:removeJob', target)
```

# Credits:
* [xFutte](https://github.com/xFutte)
* [Silent](https://github.com/S1lentcodes)
* [Jay](https://github.com/jay-fivem)
* [Snipe](https://github.com/pushkart2)
* [Snipe](https://github.com/pushkart2)
16 changes: 8 additions & 8 deletions server/sv_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ end)

-- QBCORE EVENTS

RegisterNetEvent("qb-bossmenu:server:FireEmployee", function(target)
local source = source
local Player = QBCore.Functions.GetPlayer(source)
if not Player.PlayerData.job.isboss then return end
local Employee = QBCore.Functions.GetPlayerByCitizenId(target)
if target ~= Player.PlayerData.citizenid then
RemoveJob(target, Employee.PlayerData.job.name, Employee.PlayerData.job.grade.level)
end
RegisterNetEvent('ps-multijob:server:removeJob', function(targetCitizenId)
MySQL.Async.execute('DELETE FROM multijobs WHERE citizenid = ?', { targetCitizenId }, function(affectedRows)
if affectedRows > 0 then
print('Removed job: ' .. targetCitizenId)
else
print('Cannot remove job: ' .. targetCitizenId)
end
end)
end)

RegisterNetEvent('QBCore:Server:OnJobUpdate', function(source, newJob)
Expand Down

0 comments on commit e1c454e

Please sign in to comment.