Skip to content

Commit

Permalink
Update v0.2.2
Browse files Browse the repository at this point in the history
- Added Wait modifier for markers (less lag when far)
- Fixed StateBag client-side at Player class
- Updated StateBag client-side
  • Loading branch information
pitermcflebor committed Nov 5, 2020
1 parent 2f4241f commit a2d0a93
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 5 additions & 2 deletions classes/client/marker.lua
Expand Up @@ -62,15 +62,18 @@ MarkerMethods.__index = {
Inside = function(self, cb)
self.threadWorking = true
self.inside = false
self.threadWorkingTime = 0
Citizen.CreateThreadNow(function()
while self.threadWorking do
if Vdist2(self.coords.x, self.coords.y, self.coords.z, GetEntityCoords(PlayerPedId())) <= self.radius*1.5 then
if not self.inside then self.inside = true end
cb(self)
self.threadWorkingTime = 0
else
if self.inside then collectgarbage("collect") end
self.threadWorkingTime = 100
end
Wait(0)
Wait(self.threadWorkingTime)
end
end)
end,
Expand All @@ -82,7 +85,7 @@ MarkerMethods.__index = {
if Vdist2(self.coords.x, self.coords.y, self.coords.z, GetEntityCoords(PlayerPedId())) > self.radius*1.5 then
cb(self)
end
Wait(0)
Wait(self.threadWorkingTime)
end
end)
end
Expand Down
5 changes: 4 additions & 1 deletion classes/client/player.lua
Expand Up @@ -31,7 +31,10 @@ PlayerMethods.__call = function(self, source)
else
warning('The paremeter need to be number, but got '..type(source))
end
o.state = o.ped.state
if not StateBag then
import 'statebag'
end
o.state = StateBag(o.source, true)
return o
end
Expand Down
16 changes: 10 additions & 6 deletions classes/client/statebag.lua
Expand Up @@ -6,15 +6,19 @@ exports('statebag', function()
_G.StateBagMethods = {}
StateBagMethods.__call = function(self, entityId)
StateBagMethods.__call = function(self, entityId, isPlayer)
if type(entityId) == 'number' then
local o = setmetatable({}, {__index = self})
o.localId = entityId
o.networked = NetworkGetEntityIsNetworked(entityId)
if o.networked then
o.id = NetworkGetNetworkIdFromEntity(entityId)
else
if isPlayer ~= nil and isPlayer == true then
o.id = entityId
else
o.localId = entityId
o.networked = NetworkGetEntityIsNetworked(entityId)
if o.networked then
o.id = NetworkGetNetworkIdFromEntity(entityId)
else
o.id = entityId
end
end
return o
else
Expand Down
2 changes: 1 addition & 1 deletion classes/fxmanifest.lua
Expand Up @@ -2,7 +2,7 @@ fx_version 'cerulean'
games { 'gta5' }

developer 'PiterMcFlebor'
version '0.2.0'
version '0.2.2'
description [[
Classes script created by PiterMcFlebor (2020)
Expand Down

0 comments on commit a2d0a93

Please sign in to comment.