Skip to content

Commit

Permalink
Update v2.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Nov 17, 2024
1 parent 014b6ed commit 15106ac
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
39 changes: 38 additions & 1 deletion client/functions/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ setmetatable(Player, {
if tonumber(key) then
return MSK.Trigger('msk_core:player', key)
end
end,
__call = function(self, key, val, update)
local value = rawget(self, key)

if value == nil then
if type(val) == 'function' then
value = func()
else
value = val
end

rawset(self, key, value)
end

return value
end
})

Expand Down Expand Up @@ -89,4 +104,26 @@ CreateThread(function()
end
end)

MSK.Player = Player
MSK.Player = Player

local Contains = function(key)
local keys = {
'clientId', 'serverId', 'playerId', 'Notify',
'coords', 'heading', 'state',
'ped', 'playerPed', 'vehicle', 'seat', 'weapon', 'isDead',
}

for k, v in pairs(keys) do
if k == key then
return true
end
end

return false
end

AddEventHandler('msk_core:invokingUpdate', function(key, value)
if Contains(key) then return end

Player:set(key, value)
end)
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_core'
description 'Functions for MSK Scripts'
version '2.7.3'
version '2.7.4'

lua54 'yes'

Expand Down
23 changes: 20 additions & 3 deletions import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,32 @@ if context == 'client' then
if tonumber(key) then
return MSK.Trigger('msk_core:player', key)
end
end,
__call = function(self, key, val, update)
local value = rawget(self, key)

if value == nil then
if type(val) == 'function' then
value = func()
else
value = val
end

rawset(self, key, value)

if update then
TriggerEvent('msk_core:invokingUpdate', key, value)
end
end

return value
end
})

AddEventHandler('msk_core:onPlayer', function(key, value, oldValue)
MSK.Player[key] = value
end)
end

if context == 'server' then
elseif context == 'server' then
local metatable = {
__index = function(self, key)
if type(key) == "string" then
Expand Down

0 comments on commit 15106ac

Please sign in to comment.