Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 61b5704

Browse files
Merge pull request #16 from Annalouu/main
Fixed The command / god role detection.
2 parents 0d7e769 + 2578383 commit 61b5704

2 files changed

Lines changed: 27 additions & 30 deletions

File tree

client/main.lua

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ end
5353

5454
AddEventHandler('onResourceStart', function(resourceName)
5555
if GetCurrentResourceName() == resourceName then
56-
QBCore.Functions.TriggerCallback('qb-afkkick:server:GetPermissions', function(UserGroup)
57-
group = UserGroup
58-
if group and (group['god'] or group == 'god') then
59-
RegisterCommand('object', function()
60-
openMenu()
61-
end)
62-
else
63-
print("No permission to use the object command. Go to admin menu > Player Management > Select Player > Permission > Set Group to God > Confirm. Try again entering this command.")
64-
end
65-
end)
6656
QBCore.Functions.TriggerCallback('ps-objectspawner:server:RequestObjects', function(incObjectList)
6757
ObjectList = incObjectList
6858
end)
@@ -81,20 +71,17 @@ AddEventHandler('onResourceStop', function(resourceName)
8171
end
8272
end)
8373

74+
RegisterNetEvent('ps-objectspawner:client:registerobjectcommand', function(perms)
75+
permission = perms
76+
if permission == 'god' then
77+
openMenu()
78+
end
79+
end)
80+
8481
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
8582
QBCore.Functions.TriggerCallback('ps-objectspawner:server:RequestObjects', function(incObjectList)
8683
ObjectList = incObjectList
8784
end)
88-
89-
Wait(1500)
90-
QBCore.Functions.TriggerCallback('qb-afkkick:server:GetPermissions', function(UserGroup)
91-
group = UserGroup
92-
if group and group['god'] or group == 'god' then
93-
RegisterCommand('object', function()
94-
openMenu()
95-
end)
96-
end
97-
end)
9885
end)
9986

10087
local function ButtonMessage(text)
@@ -345,7 +332,7 @@ end)
345332

346333
RegisterNetEvent("ps-objectspawner:client:AddObject", function(object)
347334
ObjectList[object.id] = object
348-
if group and group['god'] or group == 'god' then
335+
if permission == 'god' then
349336
SendNUIMessage({
350337
action = "created",
351338
newSpawnedObject = object,
@@ -354,21 +341,21 @@ RegisterNetEvent("ps-objectspawner:client:AddObject", function(object)
354341
end)
355342

356343
RegisterNUICallback('tpTo', function(data, cb)
357-
if group and group['god'] or group == 'god' then
344+
if permission == 'god' then
358345
SetEntityCoords(PlayerPedId(), data.coords.x+1, data.coords.y+1, data.coords.z)
359346
end
360347
cb('ok')
361348
end)
362349

363350
RegisterNUICallback('delete', function(data, cb)
364-
if group and group['god'] or group == 'god' then
351+
if permission == 'god' then
365352
TriggerServerEvent("ps-objectspawner:server:DeleteObject", data.id)
366353
end
367354
cb('ok')
368355
end)
369356

370357
RegisterNetEvent('ps-objectspawner:client:receiveObjectDelete', function(id)
371-
if group and group['god'] or group == 'god' then
358+
if permission == 'god' then
372359
if ObjectList[id]["IsRendered"] then
373360
if DoesEntityExist(ObjectList[id]["object"]) then
374361
for i = 255, 0, -51 do

server/main.lua

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
local QBCore = exports["qb-core"]:GetCoreObject()
22
local ServerObjects = {}
33

4+
QBCore.Commands.Add('object', 'Makes you add objects', {}, true, function(source)
5+
local source = source
6+
local Player = QBCore.Functions.GetPlayer(source)
7+
local permission = 'god'
8+
QBCore.Functions.AddPermission(Player.PlayerData.source, permission)
9+
if QBCore.Functions.HasPermission(source, 'god') then
10+
TriggerClientEvent('ps-objectspawner:client:registerobjectcommand', source, permission)
11+
end
12+
end, 'god')
13+
414
RegisterNetEvent("ps-objectspawner:server:CreateNewObject", function(model, coords, objecttype, options, objectname)
5-
local src = source
6-
if QBCore.Functions.HasPermission(src, 'god') then
15+
local source = source
16+
local hasperms = QBCore.Functions.HasPermission(source, 'god')
17+
if hasperms then
718
if model and coords then
819
local data = MySQL.query.await("INSERT INTO objects (model, coords, type, options, name) VALUES (?, ?, ?, ?, ?)", { model, json.encode(coords), objecttype, json.encode(options), objectname })
920
ServerObjects[data.insertId] = {id = data.insertId, model = model, coords = coords, type = objecttype, name = objectname, options = options}
@@ -18,8 +29,6 @@ end)
1829

1930
CreateThread(function()
2031
local results = MySQL.query.await('SELECT * FROM objects', {})
21-
--Wait(5000)
22-
--TriggerClientEvent("ps-objectspawner:client:UpdateObjectList", -1, ServerObjects)
2332
for k, v in pairs(results) do
2433
ServerObjects[v["id"]] = {
2534
id = v["id"],
@@ -37,8 +46,9 @@ QBCore.Functions.CreateCallback("ps-objectspawner:server:RequestObjects", functi
3746
end)
3847

3948
RegisterNetEvent("ps-objectspawner:server:DeleteObject", function(objectid)
40-
local src = source
41-
if QBCore.Functions.HasPermission(src, 'god') then
49+
local source = source
50+
local hasperms = QBCore.Functions.HasPermission(source, 'god')
51+
if hasperms then
4252
if objectid > 0 then
4353
local data = MySQL.query.await('DELETE FROM objects WHERE id = ?', {objectid})
4454
ServerObjects[objectid] = nil

0 commit comments

Comments
 (0)