Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Modules/Core/Player/Server/Events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ AddEventHandler("Player:Spawned", function()
local Skin = json.decode(Result[1]["Skin"])
local Position = json.decode(Result[1]["Position"])
local PlayerInventory = _Player.GetInventory()
TriggerEvent("framework:status:server:set", _Player.source)
TriggerClientEvent("Inventory:PlayerInventory", _Player.Source, PlayerInventory)
TriggerClientEvent("Player:LoadPlayer", _Player.Source, Sex, Skin, Position)
end)
Expand Down
18 changes: 18 additions & 0 deletions Modules/Core/Status/Client/Events.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
RegisterNetEvent("framework:status:client:change")
AddEventHandler("framework:status:client:change", function(pType, pAmount, pPositive)
if not pPositive then
values[tostring(pType)] = values[tostring(pType)] - pAmount or pAmount - values[tostring(pType)]
else
values[tostring(pType)] = values[tostring(pType)] + pAmount
end
end)

RegisterNetEvent("framework:status:client:set")
AddEventHandler("framework:status:client:set", function(pValue)
values = pValue
end)

RegisterNetEvent("framework:status:client:fill")
AddEventHandler("framework:status:client:fill", function()
values = {["health"] = 200,["armour"] = 100,["hunger"] = 100,["thirst"] = 100,["oxy"] = 100, ["sanity"] = 100}
end)
20 changes: 20 additions & 0 deletions Modules/Core/Status/Client/Main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local values = {
["health"] = GetEntityHealth(PlayerPedId())
["armour"] = GetPedArmour(PlayerPedId())
["hunger"] = 100,
["thirst"] = 100,
["oxy"] = 100,
["sanity"] = 100,
["infection"] = 0
["Drunk"] = 0,
["Sleep"] = 100,
["Bleeding"] = false,
}

SetInterval(10000, function()
for i=0,4 do
values = values - 1
TriggerServerEvent("framework:status:save", values)
--SendNuiMessage(jsonString)
end
end)
21 changes: 21 additions & 0 deletions Modules/Core/Status/Server/Main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
RegisterNetEvent("framework:status:server:save")
AddEventHandler("framework:status:server:save", function(pValue)
local _Player = Player(source)
local Identifier = _Player.Identifier()

Database.ExecuteUpdateQuery("UPDATE users SET status = @status WHERE Identifier = @Identifier", {["@Identifier"] = Identifier, ["@status"] = json.encode(pValue)})
end)

RegisterNetEvent("framework:status:server:set")
AddEventHandler("framework:status:server:set", function(pSource)
local _Player = Player(pSource)
local Identifier = _Player.Identifier()
local status
Database.ExecuteSelectQuery("SELECT status FROM users WHERE Identifier = @Identifier", {["@Identifier"] = Identifier}, function(pResult)
if pResult[1] ~= nil then
status = pResult[1].status
end
end)

TriggerClientEvent("framework:status:client:set", _Player.source, json.decode(status))
end)
1 change: 1 addition & 0 deletions zombieoutbreak.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CREATE TABLE `users` (
`Inventory` LONGTEXT NOT NULL DEFAULT '{}',
`Skin` LONGTEXT NULL DEFAULT NULL,
`Position` LONGTEXT NULL DEFAULT NULL,
`Status` LONGTEXT NOT NULL DEFAULT '{}'

PRIMARY KEY (`ID`)
);
Expand Down