forked from Project-Sloth/ps-objectspawner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d751628
commit 72cbad3
Showing
3 changed files
with
99 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
RegisterNetEvent('ps-objectspawner:client:containers') | ||
AddEventHandler('ps-objectspawner:client:containers', function(data) | ||
local objectData = data | ||
print(objectData.id) | ||
TriggerServerEvent("inventory:server:OpenInventory", "stash", "container_"..objectData.id, {maxweight = 1000000, slots = 10}) | ||
TriggerEvent("inventory:client:SetCurrentStash", "container_"..objectData.id) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
local QBCore = exports["qb-core"]:GetCoreObject() | ||
local ServerObjects = {} | ||
|
||
RegisterNetEvent("objects:CreateNewObject", function(model, coords, objecttype, options) | ||
print(objecttype) | ||
RegisterNetEvent("ps-objectspawner:server:CreateNewObject", function(model, coords, objecttype, options) | ||
local src = source | ||
print(model) | ||
print(coords) | ||
print(objecttype) | ||
if model and coords then | ||
local data = MySQL.query.await("INSERT INTO objects (model, coords, type, options) VALUES (?, ?, ?, ?)", { model, json.encode(coords), objecttype, json.encode(options) }) | ||
ServerObjects[#ServerObjects+1] = {id = data.insertId, model = model, coords = json.encode(coords), type = objecttype, options = json.encode(options)} | ||
TriggerClientEvent("objects:AddObject", -1, {id = data.insertId, model = model, coords = json.encode(coords), type = objecttype, options = json.encode(options)}) | ||
TriggerClientEvent("ps-objectspawner:client:AddObject", -1, {id = data.insertId, model = model, coords = json.encode(coords), type = objecttype, options = json.encode(options)}) | ||
else | ||
print("[P-OBJECTS]: Object or coords was invalid") | ||
print("[PS-OBJECTSPAWNER]: Object or coords was invalid") | ||
end | ||
end) | ||
|
||
function CreateDataObject(mode, coords, type, options) | ||
MySQL.query.await("INSERT INTO objects (model, coords, type, options) VALUES (?, ?, ?, ?)", { model, json.encode(coords), type, json.encode(options) }) | ||
end | ||
exports("CreateDataObject", CreateDataObject) | ||
|
||
CreateThread(function() | ||
-- MySQL.Async.execute('DELETE FROM objects') | ||
ServerObjects = MySQL.query.await('SELECT * FROM objects', {}) | ||
Wait(5000) | ||
TriggerClientEvent("objects:UpdateObjectList", -1, ServerObjects) | ||
--Wait(5000) | ||
--TriggerClientEvent("ps-objectspawner:client:UpdateObjectList", -1, ServerObjects) | ||
end) | ||
|
||
QBCore.Functions.CreateCallback("RequestObjects", function(source, cb) | ||
QBCore.Functions.CreateCallback("ps-objectspawner:server:RequestObjects", function(source, cb) | ||
cb(ServerObjects) | ||
end) | ||
|
||
local function CreateDataObject(mode, coords, type, options) | ||
MySQL.query.await("INSERT INTO objects (model, coords, type, options) VALUES (?, ?, ?, ?)", { model, json.encode(coords), type, json.encode(options) }) | ||
end | ||
|
||
exports("CreateDataObject", CreateDataObject) |