diff --git a/lib/entities/shared/behaviors/anim.lua b/lib/entities/shared/behaviors/anim.lua index ef8574e..ee6e40a 100644 --- a/lib/entities/shared/behaviors/anim.lua +++ b/lib/entities/shared/behaviors/anim.lua @@ -18,13 +18,13 @@ function Animation.Play(entityData) local flags = entityData.anim.flags or Animation.default.flags local duration = entityData.anim.duration or Animation.default.duration entityData.anim.id = Bridge.Anim.Play(nil, entity, dict, name, 8.0, -8.0, duration, flags, 0.0, onComplete) - Bridge.ClientEntity.Set(entityData.id, "anim", entityData.anim) + Bridge.Entity.Set(entityData.id, "anim", entityData.anim) entityData.oldAnim = entityData.anim - Bridge.ClientEntity.Set(entityData.id, "oldAnim", entityData.oldAnim) + Bridge.Entity.Set(entityData.id, "oldAnim", entityData.oldAnim) -- SetTimeout(1000, function() -- if entityData.anim then -- entityData.anim.disable = false - -- Bridge.ClientEntity.Set(entityData.id, "anim", entityData.anim) + -- Bridge.Entity.Set(entityData.id, "anim", entityData.anim) -- end -- end) end @@ -36,15 +36,15 @@ function Animation.OnSpawn(entityData) entityData.anim.disable = false TaskSetBlockingOfNonTemporaryEvents(entityData.spawned, true) SetBlockingOfNonTemporaryEvents(entityData.spawned, true) - Bridge.ClientEntity.Set(entityData.id, "anim", entityData.anim) + Bridge.Entity.Set(entityData.id, "anim", entityData.anim) end function Animation.OnRemove(entityData) if not entityData.spawned or not entityData.anim then return end entityData.oldAnim = nil entityData.anim.disable = true - Bridge.ClientEntity.Set(entityData.id, "anim", entityData.anim) - Bridge.ClientEntity.Set(entityData.id, "oldAnim", entityData.oldAnim) + Bridge.Entity.Set(entityData.id, "anim", entityData.anim) + Bridge.Entity.Set(entityData.id, "oldAnim", entityData.oldAnim) end function Animation.OnUpdate(entityData) @@ -58,5 +58,5 @@ function Animation.OnUpdate(entityData) end end -Bridge.ClientEntity.RegisterBehavior("anim", Animation) +Bridge.Entity.RegisterBehavior("anim", Animation) return Animation \ No newline at end of file diff --git a/lib/entities/shared/behaviors/attach.lua b/lib/entities/shared/behaviors/attach.lua index 291de33..8b3f66f 100644 --- a/lib/entities/shared/behaviors/attach.lua +++ b/lib/entities/shared/behaviors/attach.lua @@ -14,7 +14,7 @@ function Attach.OnSpawn(entityData) local entity = entityData.spawned local targetEntity = entityData.attach.target if type(targetEntity) == "string" then - targetEntity = Bridge.ClientEntity.Get(targetEntity)?.spawned or targetEntity + targetEntity = Bridge.Entity.Get(targetEntity)?.spawned or targetEntity else local player = GetPlayerFromServerId(targetEntity) if player and player ~= -1 then @@ -27,13 +27,13 @@ function Attach.OnSpawn(entityData) local offset = entityData.attach.offset or Attach.default.offset local rotation = entityData.attach.rotation or Attach.default.rotation AttachEntityToEntity(entity, targetEntity, GetPedBoneIndex(targetEntity, bone), offset.x, offset.y, offset.z, rotation.x, rotation.y, rotation.z, true, true, false, true, 1, true) - Bridge.ClientEntity.Set(entityData.id, "attach", entityData.attach) + Bridge.Entity.Set(entityData.id, "attach", entityData.attach) end function Attach.Detach(entityData) if not entityData.spawned or not IsEntityAttached(entityData.spawned) then return end DetachEntity(entityData.spawned, true, true) - Bridge.ClientEntity.Set(entityData.id, "attach", entityData.attach) + Bridge.Entity.Set(entityData.id, "attach", entityData.attach) end function Attach.OnUpdate(entityData) @@ -42,9 +42,11 @@ function Attach.OnUpdate(entityData) return Attach.Detach(entityData) end local entity = entityData.spawned + local coords = GetEntityCoords(entity) + Bridge.Entity.Set(entityData.id, "coords", vector3(coords.x, coords.y, coords.z)) if IsEntityAttached(entity) then return end Attach.OnSpawn(entityData) end -Bridge.ClientEntity.RegisterBehavior("attach", Attach) +Bridge.Entity.RegisterBehavior("attach", Attach) return Attach \ No newline at end of file diff --git a/lib/entities/shared/behaviors/clothing.lua b/lib/entities/shared/behaviors/clothing.lua index 1b3f605..4ae11db 100644 --- a/lib/entities/shared/behaviors/clothing.lua +++ b/lib/entities/shared/behaviors/clothing.lua @@ -19,7 +19,7 @@ function Clothing.ChangeClothes(entityData) clothing = Bridge.Clothing.GetAppearance(GetPlayerPed(player)) end elseif type(clothing) == "string" then - local targetEntityData = Bridge.ClientEntity.Get(clothing) + local targetEntityData = Bridge.Entity.Get(clothing) if targetEntityData then clothing = Bridge.Clothing.GetAppearance(targetEntityData.spawned) end @@ -29,9 +29,9 @@ function Clothing.ChangeClothes(entityData) end Bridge.Clothing.SetAppearance(entity, clothing) - Bridge.ClientEntity.Set(entityData.id, "clothing", clothing) + Bridge.Entity.Set(entityData.id, "clothing", clothing) entityData.oldClothing = clothing - Bridge.ClientEntity.Set(entityData.id, "oldClothing", clothing) + Bridge.Entity.Set(entityData.id, "oldClothing", clothing) end @@ -73,10 +73,10 @@ function Clothing.OnUpdate(entityData) SetTimeout(1000, function() if entityData.clothing then entityData.clothing.updating = false - Bridge.ClientEntity.Set(entityData.id, "clothing", entityData.clothing) + Bridge.Entity.Set(entityData.id, "clothing", entityData.clothing) end end) end -Bridge.ClientEntity.RegisterBehavior("clothing", Clothing) +Bridge.Entity.RegisterBehavior("clothing", Clothing) return Clothing \ No newline at end of file diff --git a/lib/entities/shared/behaviors/follow.lua b/lib/entities/shared/behaviors/follow.lua index 9a4c2c4..addefb3 100644 --- a/lib/entities/shared/behaviors/follow.lua +++ b/lib/entities/shared/behaviors/follow.lua @@ -21,7 +21,7 @@ function Follow.PedWalkToPos(entityData) targetCoords = GetEntityCoords(targetCoords) end elseif type(targetCoords) == "string" then - local targetEntityData = Bridge.ClientEntity.Get(targetCoords) + local targetEntityData = Bridge.Entity.Get(targetCoords) if targetEntityData then targetCoords = GetEntityCoords(targetEntityData.spawned) end @@ -31,32 +31,32 @@ function Follow.PedWalkToPos(entityData) if distance > (entityData.follow.distance or Follow.default.distance) then if entityData.anim then entityData.anim.disable = true - Bridge.ClientEntity.Set(entityData.id, "anim", entityData.anim) + Bridge.Entity.Set(entityData.id, "anim", entityData.anim) end if entityData.scenarios then entityData.scenarios.disable = true - Bridge.ClientEntity.Set(entityData.id, "scenarios", entityData.scenarios) + Bridge.Entity.Set(entityData.id, "scenarios", entityData.scenarios) end local speed = entityData.follow.speed or Follow.default.speed local heading = GetHeadingFromVector_2d(targetCoords.x - entityPos.x, targetCoords.y - entityPos.y) TaskGoStraightToCoord(entity, targetCoords.x, targetCoords.y, targetCoords.z, speed, -1, heading, 0.0) entityData.coords = GetEntityCoords(entity) entityData.follow.walking = true - Bridge.ClientEntity.Set(entityData.id, "coords", entityData.coords - vector3(0,0,1)) - Bridge.ClientEntity.Set(entityData.id, "follow", entityData.follow) + Bridge.Entity.Set(entityData.id, "coords", entityData.coords - vector3(0,0,1)) + Bridge.Entity.Set(entityData.id, "follow", entityData.follow) if entityData.follow.OnExit then entityData.follow.OnExit(entityData) end return false end if not entityData.follow.walking then return end entityData.follow.walking = false - Bridge.ClientEntity.Set(entityData.id, "follow", entityData.follow) + Bridge.Entity.Set(entityData.id, "follow", entityData.follow) if entityData.anim then entityData.anim.disable = false - Bridge.ClientEntity.Set(entityData.id, "anim", entityData.anim) + Bridge.Entity.Set(entityData.id, "anim", entityData.anim) end if entityData.scenarios then entityData.scenarios.disable = false - Bridge.ClientEntity.Set(entityData.id, "scenarios", entityData.scenarios) + Bridge.Entity.Set(entityData.id, "scenarios", entityData.scenarios) end ClearPedTasks(entity) if entityData.follow.OnEnter then entityData.follow.OnEnter(entityData) end @@ -71,5 +71,5 @@ function Follow.OnUpdate(entityData) return Follow.PedWalkToPos(entityData) end -Bridge.ClientEntity.RegisterBehavior("follow", Follow) +Bridge.Entity.RegisterBehavior("follow", Follow) return Follow \ No newline at end of file diff --git a/lib/entities/shared/behaviors/particles.lua b/lib/entities/shared/behaviors/particles.lua index fecc6b7..1160360 100644 --- a/lib/entities/shared/behaviors/particles.lua +++ b/lib/entities/shared/behaviors/particles.lua @@ -76,5 +76,5 @@ function ParticlesBehaviors.OnMove(entityData) end end -Bridge.ClientEntity.RegisterBehavior("particles", ParticlesBehaviors) +Bridge.Entity.RegisterBehavior("particles", ParticlesBehaviors) return ParticlesBehaviors \ No newline at end of file diff --git a/lib/entities/shared/behaviors/scenarios.lua b/lib/entities/shared/behaviors/scenarios.lua index 20efb69..760af6c 100644 --- a/lib/entities/shared/behaviors/scenarios.lua +++ b/lib/entities/shared/behaviors/scenarios.lua @@ -23,7 +23,7 @@ function Scenarios.Play(entityData) ClearPedTasks(entity) if not entityData.scenarios.onComplete then return end entityData.scenarios.disabled = true - Bridge.ClientEntity.Set(entityData.id, "scenarios", entityData.scenarios) + Bridge.Entity.Set(entityData.id, "scenarios", entityData.scenarios) entityData.scenarios.onComplete(entityData) end) @@ -60,5 +60,5 @@ function Scenarios.OnUpdate(entityData) Scenarios.Play(entityData) end -Bridge.ClientEntity.RegisterBehavior("scenarios", Scenarios) +Bridge.Entity.RegisterBehavior("scenarios", Scenarios) return Scenarios \ No newline at end of file diff --git a/lib/entities/shared/behaviors/shop.lua b/lib/entities/shared/behaviors/shop.lua index 048e786..306752c 100644 --- a/lib/entities/shared/behaviors/shop.lua +++ b/lib/entities/shared/behaviors/shop.lua @@ -36,12 +36,12 @@ function Shop.OnCreate(entityData) ) end -if not IsDuplicityVersion() then return Bridge.ClientEntity.RegisterBehavior("shop", Shop) end +if not IsDuplicityVersion() then return Bridge.Entity.RegisterBehavior("shop", Shop) end RegisterNetEvent("community_bridge:server:OpenShop", function(id) local src = source if not src then return end - local entityData = Bridge.ServerEntity.Get(id) + local entityData = Bridge.Entity.Get(id) if not entityData or not entityData.shop then return print(string.format("[Shop] OpenShop: Entity %s does not exist or has no shop", id)) end diff --git a/lib/entities/shared/behaviors/stash.lua b/lib/entities/shared/behaviors/stash.lua index c006a11..994a7d0 100644 --- a/lib/entities/shared/behaviors/stash.lua +++ b/lib/entities/shared/behaviors/stash.lua @@ -26,7 +26,7 @@ function Stash.OnCreate(entityData) label = entityData.stash.target.label or Stash.default.target.label, icon = entityData.stash.target.icon or Stash.default.target.icon, canInteract = function(_) - local entData = Bridge.ClientEntity.Get(entityData.id) + local entData = Bridge.Entity.Get(entityData.id) return not entData.stash.disable end, onSelect = function() @@ -34,16 +34,16 @@ function Stash.OnCreate(entityData) end } - Bridge.ClientEntity.Set(entityData.id, 'targets', entityData.targets) + Bridge.Entity.Set(entityData.id, 'targets', entityData.targets) end end -if not IsDuplicityVersion() then return Bridge.ClientEntity.RegisterBehavior("stash", Stash) end +if not IsDuplicityVersion() then return Bridge.Entity.RegisterBehavior("stash", Stash) end RegisterNetEvent("community_bridge:server:OpenStash", function(id) local src = source if not src then return end - local entityData = Bridge.ServerEntity.Get(id) + local entityData = Bridge.Entity.Get(id) if not entityData or not entityData.stash then return print(string.format("[Stash] OpenStash: Entity %s does not exist or has no stash", id)) end @@ -56,4 +56,4 @@ RegisterNetEvent("community_bridge:server:OpenStash", function(id) Bridge.Inventory.OpenStash(src, "stash", id) end) -Bridge.ServerEntity.RegisterBehavior("stash", Stash) \ No newline at end of file +Bridge.Entity.RegisterBehavior("stash", Stash) \ No newline at end of file diff --git a/lib/entities/shared/behaviors/targets.lua b/lib/entities/shared/behaviors/targets.lua index cb15ac3..610b2ca 100644 --- a/lib/entities/shared/behaviors/targets.lua +++ b/lib/entities/shared/behaviors/targets.lua @@ -26,7 +26,7 @@ function Targets.OnSpawn(entityData) table.sort(numberedTargets, function(a, b) return (a.label < b.label) end) Bridge.Target.AddLocalEntity(entityData.spawned, numberedTargets) entityData.oldTargets = entityData.targets - Bridge.ClientEntity.Set(entityData.id, "oldTargets", entityData.oldTargets) + Bridge.Entity.Set(entityData.id, "oldTargets", entityData.oldTargets) end function Targets.OnRemove(entityData) @@ -57,5 +57,5 @@ function Targets.OnUpdate(entityData) Targets.OnSpawn(entityData) end end -Bridge.ClientEntity.RegisterBehavior("targets", Targets) +Bridge.Entity.RegisterBehavior("targets", Targets) return Targets \ No newline at end of file diff --git a/lib/entities/shared/behaviors/weapon.lua b/lib/entities/shared/behaviors/weapon.lua index d055ccd..24c6b7c 100644 --- a/lib/entities/shared/behaviors/weapon.lua +++ b/lib/entities/shared/behaviors/weapon.lua @@ -19,7 +19,7 @@ function Weapon.GiveWeapon(entityData) TaskSwapWeapon(entity, true) end entityData.oldWeapon = entityData.weapon - Bridge.ClientEntity.Set(entityData.id, "oldWeapon", entityData.oldWeapon) + Bridge.Entity.Set(entityData.id, "oldWeapon", entityData.oldWeapon) end function Weapon.OnSpawn(entityData) @@ -44,11 +44,11 @@ function Weapon.OnUpdate(entityData) SetTimeout(1000, function() if entityData.weapon then entityData.weapon.updating = false - Bridge.ClientEntity.Set(entityData.id, "weapon", entityData.weapon) + Bridge.Entity.Set(entityData.id, "weapon", entityData.weapon) end end) - Bridge.ClientEntity.Set(entityData.id, "weapon", entityData.weapon) + Bridge.Entity.Set(entityData.id, "weapon", entityData.weapon) end -Bridge.ClientEntity.RegisterBehavior("weapon", Weapon) +Bridge.Entity.RegisterBehavior("weapon", Weapon) return Weapon \ No newline at end of file diff --git a/lib/init.lua b/lib/init.lua index e8676e0..48cbce8 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -59,7 +59,11 @@ cLib.Cache = Cache or Require("lib/cache/shared/cache.lua") cLib.Marker = Marker or Require("lib/markers/server/server.lua") cLib.Particle = Particle or Require("lib/particles/server/particles.lua") cLib.Shell = Shells or Require("lib/shells/server/shells.lua") -cLib.ServerEntity = ServerEntity or Require("lib/entities/server/server_entity.lua") +cLib.Entity = ServerEntity or Require("lib/entities/server/server_entity.lua") + +-- Depricated +cLib.ServerEntity = cLib.Entity + if IsDuplicityVersion() then return cLib end ::client:: @@ -71,10 +75,13 @@ cLib.Raycast = Raycast or Require("lib/raycast/client/raycast.lua") cLib.Point = Point or Require("lib/points/client/points.lua") cLib.Particle = Particle or Require("lib/particles/client/particles.lua") cLib.Cache = Cache or Require("lib/cache/client/cache.lua") -cLib.ClientEntity = ClientEntity or Require("lib/entities/client/client_entity.lua") cLib.Marker = Marker or Require("lib/markers/client/markers.lua") cLib.Anim = Anim or Require("lib/anim/client/client.lua") cLib.Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua") cLib.Particle = Particle or Require("lib/particles/client/particles.lua") +cLib.Entity = ClientEntity or Require("lib/entities/client/client_entity.lua") + +-- Deprecated +cLib.ClientEntity = cLib.Entity return cLib