Update 'Example_StatPointUI/Server/StatPointUI.lua'

This commit is contained in:
foe
2022-01-27 18:52:00 +01:00
parent d7a2bd8cae
commit 4b218e7b73

View File

@ -38,6 +38,15 @@ function StatPointUI.OnLogin(event, player)
StatPointUI.SetStats(player:GetGUIDLow()) StatPointUI.SetStats(player:GetGUIDLow())
end 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) function StatPointUI.SetStats(guid, stat)
stat = stat or nil stat = stat or nil
local player = GetPlayerByGUID(guid) local player = GetPlayerByGUID(guid)
@ -121,6 +130,11 @@ function OnStatResetRequest(player, argTable)
player:SendServerResponse(config.Prefix, 1, StatPointUI.cache[player:GetGUIDLow()]) player:SendServerResponse(config.Prefix, 1, StatPointUI.cache[player:GetGUIDLow()])
end 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) RegisterPlayerEvent(3, StatPointUI.OnLogin)
RegisterServerEvent(33, StatPointUI.OnElunaStartup) RegisterServerEvent(33, StatPointUI.OnElunaStartup)
RegisterClientRequests(config) RegisterClientRequests(config)