From 4b218e7b731200ce527c4e3f7a7501c446c07ffc Mon Sep 17 00:00:00 2001 From: foe Date: Thu, 27 Jan 2022 18:52:00 +0100 Subject: [PATCH] Update 'Example_StatPointUI/Server/StatPointUI.lua' --- Example_StatPointUI/Server/StatPointUI.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Example_StatPointUI/Server/StatPointUI.lua b/Example_StatPointUI/Server/StatPointUI.lua index f3fbc04..603b0fe 100644 --- a/Example_StatPointUI/Server/StatPointUI.lua +++ b/Example_StatPointUI/Server/StatPointUI.lua @@ -38,6 +38,15 @@ function StatPointUI.OnLogin(event, player) StatPointUI.SetStats(player:GetGUIDLow()) end +function StatPointUI.AddStatPoint(guid) + local player = GetPlayerByGUID(guid) + if(player) then + StatPointUI.cache[guid][6] = StatPointUI.cache[guid][6]+1 + CharDBQuery("UPDATE character_stats_extra SET `points`=`points`+1 WHERE `guid`="..guid..";") + player:SendServerResponse(config.Prefix, 1, StatPointUI.cache[guid]) + end +end + function StatPointUI.SetStats(guid, stat) stat = stat or nil local player = GetPlayerByGUID(guid) @@ -121,6 +130,11 @@ function OnStatResetRequest(player, argTable) player:SendServerResponse(config.Prefix, 1, StatPointUI.cache[player:GetGUIDLow()]) end +-- Helper function to add a stat point to the player through other scripts +function Player:AddPoint() + StatPointUI.AddStatPoint(self:GetGUIDLow()) +end + RegisterPlayerEvent(3, StatPointUI.OnLogin) RegisterServerEvent(33, StatPointUI.OnElunaStartup) RegisterClientRequests(config) \ No newline at end of file