Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Commit

Permalink
Add sEntity and sPed
Browse files Browse the repository at this point in the history
  • Loading branch information
benank committed Mar 19, 2021
1 parent f326511 commit 60b384d
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example_fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ server_scripts {
'oof/server/player/sPlayer.lua', -- Player class
'oof/server/player/sPlayers.lua', -- Players class
'oof/server/player/sPlayerManager.lua', -- PlayerManager class
'oof/server/entity/sEntity.lua', -- Entity class
'oof/server/ped/sPed.lua', -- Ped class
'oof/server/world/*.lua', -- World class

-- Add other modules here (server and shared)
Expand Down
84 changes: 84 additions & 0 deletions server/entity/sEntity.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Entity = class(ValueStorage)

function Entity:__init(entity_id)
self.entity = entity_id
self:InitializeEntity(self.entity)
end

function Entity:InitializeEntity(ent)
self.entity = ent
self:InitializeValueStorage(self)
end

function Entity:GetEntity()
return self.entity
end

function Entity:GetEntityId()
return self.entity
end

function Entity:Remove()
DeleteEntity(self.entity)
end

function Entity:Exists()
return DoesEntityExist(self.entity)
end

function Entity:GetNetworkId()
return NetworkGetNetworkIdFromEntity(self.entity)
end

function Entity:GetNetworkOwner()
return NetworkGetEntityOwner(self.entity)
end

function Entity:NetworkGetFirstEntityOwner()
-- Get first entity owner - with fallback in case of older server version
return NetworkGetFirstEntityOwner and NetworkGetFirstEntityOwner(self.entity) or NetworkGetEntityOwner(self.entity)
end

function Entity:GetPosition()
return GetEntityCoords(self.entity)
end

function Entity:GetHeading()
return GetEntityHeading(self.entity)
end

function Entity:GetHealth()
return GetEntityHealth(self.entity)
end

function Entity:GetMaxHealth()
return GetEntityMaxHealth(self.entity)
end

function Entity:GetModel()
return GetEntityModel(self.entity)
end

function Entity:GetRotation()
return GetEntityRotation(self.entity)
end

function Entity:GetRotationVelocity()
return GetEntityRotationVelocity(self.entity)
end

function Entity:GetRoutingBucket()
return GetEntityRoutingBucket(self.entity)
end

function Entity:SetRoutingBucket(bucket)
SetEntityRoutingBucket(self.entity, bucket)
end

function Entity:GetType()
return GetEntityType(self.entity)
end

function Entity:GetVelocity()
return GetEntityVelocity(self.entity)
end
11 changes: 11 additions & 0 deletions server/ped/sPed.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Ped = class(Entity)

function Ped:__init(ped_id)
self.ped_id = ped_id
self:InitializeEntity(self.ped_id)
end

function Ped:GetPedId()
return self.ped_id
end

0 comments on commit 60b384d

Please sign in to comment.