mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
105
gamemodes/helix/plugins/teleporters/cl_hooks.lua
Normal file
105
gamemodes/helix/plugins/teleporters/cl_hooks.lua
Normal file
@@ -0,0 +1,105 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
ix.teleporters = ix.teleporters or {}
|
||||
ix.teleporters.selected = ix.teleporters.selected or {}
|
||||
ix.teleporters.data = ix.teleporters.data or {}
|
||||
|
||||
function PLUGIN:PlayerNoClip(ply, bool)
|
||||
if (bool) then
|
||||
if (!timer.Exists("ixTeleporterRetrieveData") and CAMI.PlayerHasAccess(ply, "Helix - Manage Teleporters", nil)) then
|
||||
timer.Create("ixTeleporterRetrieveData", 2, 0, function()
|
||||
netstream.Start("ixTeleportersGetData")
|
||||
end)
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if (timer.Exists("ixTeleporterRetrieveData") and CAMI.PlayerHasAccess(ply, "Helix - Manage Teleporters", nil)) then
|
||||
timer.Remove("ixTeleporterRetrieveData")
|
||||
end
|
||||
end
|
||||
|
||||
local function teleporterESP(client, entity, x, y, factor)
|
||||
local color = Color(0, 208, 255)
|
||||
ix.util.DrawText("Teleporter", x, y, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, factor)
|
||||
|
||||
for _, v in pairs(ix.teleporters.data) do
|
||||
if (entity:EntIndex() == v["id"] or entity:EntIndex() == v["entIndex"]) then
|
||||
ix.util.DrawText("ID - " .. v["id"], x, y + 20, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, factor)
|
||||
ix.util.DrawText(v["mate"] and "Mate - " .. v["mate"] or "Mate - N/A", x, y + 40, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, factor)
|
||||
ix.util.DrawText(v["name"] != "Default" and "Name - " .. v["name"] or "Name - Default", x, y + 60, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, factor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ix.observer:RegisterESPType("ix_teleporter", teleporterESP, "Teleporter")
|
||||
|
||||
netstream.Hook("ixTeleportersPassSelection", function(ID)
|
||||
if (!ix.teleporters or !ix.teleporters.selected) then
|
||||
ErrorNoHalt("Tried to reach invalid teleporter table")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if (table.IsEmpty(ix.teleporters.selected)) then
|
||||
ix.teleporters.selected[1] = ID
|
||||
|
||||
LocalPlayer():Notify("Teleporter one selected! The selection will reset in twenty seconds.")
|
||||
|
||||
timer.Create("ixTeleportersResetSelection", 20, 1, function()
|
||||
LocalPlayer():Notify("Teleporter selection has been reset.")
|
||||
|
||||
table.Empty(ix.teleporters.selected)
|
||||
end)
|
||||
elseif (!table.IsEmpty(ix.teleporters.selected) and isnumber(ix.teleporters.selected[1]) and ID != ix.teleporters.selected[1]) then
|
||||
ix.teleporters.selected[2] = ID
|
||||
|
||||
if (timer.Exists("ixTeleportersResetSelection")) then
|
||||
timer.Remove("ixTeleportersResetSelection")
|
||||
end
|
||||
|
||||
netstream.Start("ixTeleportersAssignMates", ix.teleporters.selected[1], ix.teleporters.selected[2])
|
||||
|
||||
LocalPlayer():Notify("Teleporters linked successfully.")
|
||||
|
||||
table.Empty(ix.teleporters.selected)
|
||||
end
|
||||
end)
|
||||
|
||||
netstream.Hook("ixTeleportersSendData", function(data)
|
||||
ix.teleporters.data = data
|
||||
end)
|
||||
|
||||
hook.Add("HUDPaint", "DrawImageOnEntity", function()
|
||||
local ply = LocalPlayer()
|
||||
local tr = ply:GetEyeTraceNoCursor()
|
||||
|
||||
if (IsValid(tr.Entity) and tr.Entity:GetClass() == "ix_teleporter") then
|
||||
local maxDistance = 140
|
||||
local distance = ply:GetPos():Distance(tr.HitPos)
|
||||
|
||||
if (distance <= maxDistance) then
|
||||
local imagePath = "willardnetworks/teleporters/teleporter.png"
|
||||
local pos = tr.HitPos:ToScreen()
|
||||
local imageSize = 100
|
||||
|
||||
surface.SetDrawColor(255, 255, 255, 255)
|
||||
surface.SetMaterial(Material(imagePath))
|
||||
surface.DrawTexturedRect(pos.x - imageSize / 2, pos.y - imageSize / 2, imageSize, imageSize)
|
||||
|
||||
ix.util.DrawText("ENTER", pos.x, pos.y + imageSize / 2, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
23
gamemodes/helix/plugins/teleporters/cl_plugin.lua
Normal file
23
gamemodes/helix/plugins/teleporters/cl_plugin.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
ix.teleporters = ix.teleporters or {}
|
||||
ix.teleporters.selected = ix.teleporters.selected or {}
|
||||
ix.teleporters.data = ix.teleporters.data or {}
|
||||
|
||||
function ix.teleporters:RetrieveData(entity)
|
||||
if (entity and isentity(entity) and ix.teleporters.data and !table.IsEmpty(ix.teleporters.data)) then
|
||||
for k, v in ipairs(ix.teleporters.data) do
|
||||
if (v["id"] == entity:EntIndex()) then
|
||||
return v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,67 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
ix.teleporters = ix.teleporters or {}
|
||||
|
||||
ENT.PrintName = "Teleporter"
|
||||
ENT.Category = "HL2 RP"
|
||||
ENT.Spawnable = true
|
||||
ENT.AdminOnly = true
|
||||
ENT.Model = Model("models/props_c17/door01_left.mdl")
|
||||
ENT.ID = nil
|
||||
ENT.Mate = nil
|
||||
ENT.EntModel = nil
|
||||
ENT.WarpSound = ENT.WarpSound or ""
|
||||
ENT.UniqueName = ENT.UniqueName or "Default"
|
||||
ENT.WarpPos = nil
|
||||
ENT.WarpAngles = nil
|
||||
|
||||
if (SERVER) then
|
||||
function ENT:Initialize()
|
||||
self:SetModel(self.Model)
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
|
||||
local phys = self:GetPhysicsObject()
|
||||
|
||||
if (phys:IsValid()) then
|
||||
phys:EnableMotion(false)
|
||||
phys:Wake()
|
||||
end
|
||||
|
||||
self.ID = self:EntIndex()
|
||||
|
||||
ix.saveEnts:SaveEntity(self)
|
||||
end
|
||||
|
||||
function ENT:Use(activator)
|
||||
if (ix.teleporters:IsDefaultTeleporter(self)) then
|
||||
netstream.Start(activator, "ixTeleportersPassSelection", self.ID)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if (ix.teleporters:IsMateValid(self.Mate)) then
|
||||
local teleporter = ix.teleporters:TeleporterFindByID(self.Mate)
|
||||
|
||||
self:EmitSound(self.WarpSound, 100, 100, 1)
|
||||
teleporter:EmitSound(self.WarpSound, 100, 100, 1)
|
||||
|
||||
activator:ScreenFade(SCREENFADE.IN, Color(16, 16, 16), 0.5, 1)
|
||||
activator:SetPos(teleporter.WarpPos and teleporter.WarpPos or teleporter:GetPos())
|
||||
activator:SetEyeAngles(teleporter.WarpAngles and teleporter.WarpAngles or Angle(0, 0, 0))
|
||||
return
|
||||
end
|
||||
|
||||
activator:Notify("This leads nowhere.")
|
||||
end
|
||||
end
|
||||
226
gamemodes/helix/plugins/teleporters/sh_plugin.lua
Normal file
226
gamemodes/helix/plugins/teleporters/sh_plugin.lua
Normal file
@@ -0,0 +1,226 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
PLUGIN.name = "Teleporters"
|
||||
PLUGIN.author = "Mango"
|
||||
PLUGIN.description = "A map teleportation system."
|
||||
|
||||
CAMI.RegisterPrivilege({
|
||||
Name = "Helix - Manage Teleporters",
|
||||
MinAccess = "admin"
|
||||
})
|
||||
|
||||
properties.Add("ixTeleporterGetID", {
|
||||
MenuLabel = "Copy ID",
|
||||
Order = 405,
|
||||
MenuIcon = "icon16/application_double.png",
|
||||
|
||||
Filter = function(self, entity, client)
|
||||
if (entity:GetClass() == "ix_teleporter" and CAMI.PlayerHasAccess(client, "Helix - Manage Teleporters", nil)) then return true end
|
||||
end,
|
||||
|
||||
Action = function(self, entity)
|
||||
if (!IsValid(entity)) then return end
|
||||
if (!self:Filter(entity, client)) then return end
|
||||
|
||||
local data = ix.teleporters:RetrieveData(entity)
|
||||
|
||||
if (data and istable(data)) then
|
||||
SetClipboardText(data["id"])
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
properties.Add("ixTeleporterGoToMate", {
|
||||
MenuLabel = "Goto Mate",
|
||||
Order = 406,
|
||||
MenuIcon = "icon16/bullet_go.png",
|
||||
|
||||
Filter = function(self, entity, client)
|
||||
if (entity:GetClass() == "ix_teleporter" and CAMI.PlayerHasAccess(client, "Helix - Manage Teleporters", nil)) then return true end
|
||||
end,
|
||||
|
||||
Action = function(self, target)
|
||||
self:MsgStart()
|
||||
net.WriteEntity(target)
|
||||
self:MsgEnd()
|
||||
end,
|
||||
|
||||
Receive = function(self, length, client)
|
||||
local target = net.ReadEntity()
|
||||
|
||||
if (!IsValid(target)) then return end
|
||||
if (!self:Filter(target, client)) then return end
|
||||
|
||||
if (ix.teleporters:IsMateValid(target.ID)) then
|
||||
local mate = ix.teleporters:TeleporterFindByID(target.Mate)
|
||||
|
||||
client:SetPos(mate:GetPos())
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
properties.Add("ixTeleporterSetModel", {
|
||||
MenuLabel = "Set Model",
|
||||
Order = 407,
|
||||
MenuIcon = "icon16/application_form_edit.png",
|
||||
|
||||
Filter = function(self, entity, client)
|
||||
if (entity:GetClass() == "ix_teleporter" and CAMI.PlayerHasAccess(client, "Helix - Manage Teleporters", nil)) then return true end
|
||||
end,
|
||||
|
||||
Action = function(self, target)
|
||||
Derma_StringRequest(
|
||||
"",
|
||||
"Input the desired model for the teleporter.",
|
||||
target.EntModel,
|
||||
function(text)
|
||||
self:MsgStart()
|
||||
net.WriteEntity(target)
|
||||
net.WriteString(text)
|
||||
self:MsgEnd()
|
||||
end
|
||||
)
|
||||
end,
|
||||
|
||||
Receive = function(self, length, client)
|
||||
local target = net.ReadEntity()
|
||||
local model = net.ReadString()
|
||||
|
||||
if (!IsValid(target)) then return end
|
||||
if (!self:Filter(target, client)) then return end
|
||||
|
||||
ix.teleporters:SetEntModel(target, model)
|
||||
end
|
||||
})
|
||||
|
||||
properties.Add("ixTeleporterSetWarpSound", {
|
||||
MenuLabel = "Set Warp Sound",
|
||||
Order = 408,
|
||||
MenuIcon = "icon16/bell.png",
|
||||
|
||||
Filter = function(self, entity, client)
|
||||
if (entity:GetClass() == "ix_teleporter" and CAMI.PlayerHasAccess(client, "Helix - Manage Teleporters", nil)) then return true end
|
||||
end,
|
||||
|
||||
Action = function(self, target)
|
||||
Derma_StringRequest(
|
||||
"",
|
||||
"Input the desired warp sound for the teleporter.",
|
||||
target.WarpSound,
|
||||
function(text)
|
||||
self:MsgStart()
|
||||
net.WriteEntity(target)
|
||||
net.WriteString(text)
|
||||
self:MsgEnd()
|
||||
end
|
||||
)
|
||||
end,
|
||||
|
||||
Receive = function(self, length, client)
|
||||
local target = net.ReadEntity()
|
||||
local text = net.ReadString()
|
||||
|
||||
if (!IsValid(target)) then return end
|
||||
if (!self:Filter(target, client)) then return end
|
||||
|
||||
target.WarpSound = text
|
||||
end
|
||||
})
|
||||
|
||||
properties.Add("ixTeleporterSetName", {
|
||||
MenuLabel = "Set Name",
|
||||
Order = 409,
|
||||
MenuIcon = "icon16/bullet_wrench.png",
|
||||
|
||||
Filter = function(self, entity, client)
|
||||
if (entity:GetClass() == "ix_teleporter" and CAMI.PlayerHasAccess(client, "Helix - Manage Teleporters", nil)) then return true end
|
||||
end,
|
||||
|
||||
Action = function(self, target)
|
||||
Derma_StringRequest(
|
||||
"",
|
||||
"Input the desired name for the teleporter.",
|
||||
target.UniqueName,
|
||||
function(text)
|
||||
self:MsgStart()
|
||||
net.WriteEntity(target)
|
||||
net.WriteString(text)
|
||||
self:MsgEnd()
|
||||
end
|
||||
)
|
||||
end,
|
||||
|
||||
Receive = function(self, length, client)
|
||||
local target = net.ReadEntity()
|
||||
local name = net.ReadString()
|
||||
|
||||
if (!IsValid(target)) then return end
|
||||
if (!self:Filter(target, client)) then return end
|
||||
|
||||
target.UniqueName = name
|
||||
end
|
||||
})
|
||||
|
||||
ix.command.Add("TeleporterSetWarpPos", {
|
||||
description = "Sets the position the player will appear at once warping to the selected teleporter.",
|
||||
adminOnly = true,
|
||||
arguments = {
|
||||
ix.type.number
|
||||
},
|
||||
OnRun = function(self, client, ID)
|
||||
if (!ix.teleporters:CheckPermissions(client)) then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = client:GetPos()
|
||||
|
||||
ix.teleporters:SetWarpPos(ID, pos)
|
||||
end
|
||||
})
|
||||
|
||||
ix.command.Add("TeleporterSetWarpAngles", {
|
||||
description = "Sets the angles the player will look at once warping to the selected teleporter.",
|
||||
adminOnly = true,
|
||||
arguments = {
|
||||
ix.type.number
|
||||
},
|
||||
OnRun = function(self, client, ID)
|
||||
if (!ix.teleporters:CheckPermissions(client)) then
|
||||
return
|
||||
end
|
||||
|
||||
local angles = client:EyeAngles()
|
||||
|
||||
ix.teleporters:SetWarpAngles(ID, angles)
|
||||
end
|
||||
})
|
||||
|
||||
ix.command.Add("TeleporterGetID", {
|
||||
description = "Sets the position the player will appear at once warping to the selected teleporter.",
|
||||
adminOnly = true,
|
||||
OnRun = function(self, client, ID)
|
||||
if (!ix.teleporters:CheckPermissions(client)) then
|
||||
return
|
||||
end
|
||||
|
||||
local tr = client:GetEyeTraceNoCursor().Entity
|
||||
|
||||
ix.teleporters:GetID(client, tr)
|
||||
end
|
||||
})
|
||||
|
||||
ix.util.Include("sv_hooks.lua")
|
||||
ix.util.Include("sv_plugin.lua")
|
||||
ix.util.Include("cl_plugin.lua")
|
||||
ix.util.Include("cl_hooks.lua")
|
||||
|
||||
61
gamemodes/helix/plugins/teleporters/sv_hooks.lua
Normal file
61
gamemodes/helix/plugins/teleporters/sv_hooks.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
ix.teleporters = ix.teleporters or {}
|
||||
|
||||
ix.saveEnts:RegisterEntity("ix_teleporter", true, true, true, {
|
||||
OnSave = function(entity, data)
|
||||
data.ID = entity.ID
|
||||
data.Mate = entity.Mate
|
||||
data.EntModel = entity.EntModel and entity.EntModel or entity.Model
|
||||
data.WarpSound = entity.WarpSound
|
||||
data.UniqueName = #entity.UniqueName > 1 and entity.UniqueName or "Default"
|
||||
data.WarpPos = isvector(entity.WarpPos) and entity.WarpPos or nil
|
||||
data.WarpAngles = isangle(entity.WarpAngles) and entity.WarpAngles or nil
|
||||
end,
|
||||
OnRestore = function(entity, data)
|
||||
entity.ID = data.ID
|
||||
entity.Mate = data.Mate
|
||||
entity.EntModel = data.EntModel
|
||||
entity.WarpSound = data.WarpSound
|
||||
entity.UniqueName = data.UniqueName
|
||||
entity.WarpPos = data.WarpPos
|
||||
entity.WarpAngles = data.WarpAngles
|
||||
|
||||
ix.teleporters:ReinitializeModel(entity, entity.EntModel and entity.EntModel or entity.Model)
|
||||
end
|
||||
})
|
||||
|
||||
netstream.Hook("ixTeleportersAssignMates", function(ply, ID1, ID2)
|
||||
if (!CAMI.PlayerHasAccess(ply, "Helix - Manage Teleporters")) then
|
||||
return
|
||||
end
|
||||
|
||||
ix.teleporters:TeleporterFindByID(ID1).Mate = ID2
|
||||
ix.teleporters:TeleporterFindByID(ID2).Mate = ID1
|
||||
end)
|
||||
|
||||
netstream.Hook("ixTeleportersGetData", function(ply)
|
||||
if (!CAMI.PlayerHasAccess(ply, "Helix - Manage Teleporters")) then
|
||||
return
|
||||
end
|
||||
|
||||
netstream.Start(ply, "ixTeleportersSendData", ix.teleporters:GetTeleportersData())
|
||||
end)
|
||||
|
||||
function PLUGIN:SetupPlayerVisibility(client)
|
||||
for _, v in pairs(ents.FindByClass("ix_teleporter")) do
|
||||
if (v:IsValid()) then
|
||||
AddOriginToPVS(v:GetPos())
|
||||
end
|
||||
end
|
||||
end
|
||||
141
gamemodes/helix/plugins/teleporters/sv_plugin.lua
Normal file
141
gamemodes/helix/plugins/teleporters/sv_plugin.lua
Normal file
@@ -0,0 +1,141 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
ix.teleporters = ix.teleporters or {}
|
||||
|
||||
function ix.teleporters:CheckPermissions(ply)
|
||||
if (!CAMI.PlayerHasAccess(ply, "Helix - Manage Teleporters", nil)) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ix.teleporters:SetEntModel(entity, strModel)
|
||||
if (!entity or !strModel or entity and !IsValid(entity) or strModel and IsUselessModel(strModel)) then
|
||||
return
|
||||
end
|
||||
|
||||
if (isentity(entity) and entity:GetClass() == "ix_teleporter") then
|
||||
entity:SetModel(strModel)
|
||||
entity.EntModel = strModel
|
||||
|
||||
self:ReinitializeModel(entity, strModel)
|
||||
end
|
||||
end
|
||||
|
||||
function ix.teleporters:SetWarpPos(ID, hitPos)
|
||||
local teleporter = self:TeleporterFindByID(ID)
|
||||
|
||||
if (teleporter and isentity(teleporter) and IsValid(teleporter)) then
|
||||
teleporter.WarpPos = hitPos
|
||||
end
|
||||
end
|
||||
|
||||
function ix.teleporters:SetWarpAngles(ID, angles)
|
||||
local teleporter = self:TeleporterFindByID(ID)
|
||||
|
||||
if (teleporter and isentity(teleporter) and IsValid(teleporter)) then
|
||||
teleporter.WarpAngles = angles
|
||||
end
|
||||
end
|
||||
|
||||
function ix.teleporters:GetTeleportersData()
|
||||
local data = {}
|
||||
|
||||
for _, v in ipairs(ents.FindByClass("ix_teleporter")) do
|
||||
data[#data + 1] = {
|
||||
name = v.UniqueName,
|
||||
id = v.ID,
|
||||
pos = v:GetPos(),
|
||||
angles = v:GetAngles(),
|
||||
mate = v.Mate,
|
||||
entModel = v.EntModel,
|
||||
warpSound = v.WarpSound,
|
||||
warpPos = v.WarpPos,
|
||||
warpAngles = v.WarpAngles,
|
||||
entIndex = v:EntIndex()
|
||||
}
|
||||
|
||||
if (v.Mate and !self:TeleporterFindByID(v.Mate)) then
|
||||
v.Mate = nil
|
||||
end
|
||||
end
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
function ix.teleporters:GetID(caller, entity)
|
||||
if (caller and IsValid(caller) and entity and isentity(entity) and entity:GetClass() == "ix_teleporter") then
|
||||
caller:Notify(entity.ID)
|
||||
end
|
||||
end
|
||||
|
||||
function ix.teleporters:IsDefaultTeleporter(entity)
|
||||
if (entity and isentity(entity) and entity:GetClass() == "ix_teleporter") then
|
||||
if (!entity.Mate) then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function ix.teleporters:IsMateValid(ID)
|
||||
local teleporter = self:TeleporterFindByID(ID)
|
||||
|
||||
if (teleporter and teleporter.Mate) then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function ix.teleporters:ReinitializeModel(entity, model) -- This will assure that bounds of model are reinitialized correctly to allow full free movement of the entity
|
||||
if (!entity or !model or model and #model == 0) then
|
||||
ErrorNoHalt("Attempted to reinitialize teleporter with missing arguments.")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if (!entity or entity and !IsValid(entity)) then
|
||||
ErrorNoHalt("Attempted to reinitialize teleporter with invalid player argument.")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
entity:SetModel(model)
|
||||
entity:PhysicsInit(SOLID_VPHYSICS)
|
||||
entity:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
entity:SetSolid(SOLID_VPHYSICS)
|
||||
|
||||
local phys = entity:GetPhysicsObject()
|
||||
|
||||
if (phys:IsValid()) then
|
||||
phys:EnableMotion(false)
|
||||
phys:Wake()
|
||||
end
|
||||
end
|
||||
|
||||
function ix.teleporters:TeleporterFindByID(ID)
|
||||
if (!ID) then
|
||||
ErrorNoHalt("Attempted to find teleporter with missing ID argument")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
for _, v in ipairs(ents.FindByClass("ix_teleporter")) do
|
||||
if (v.ID == ID) then
|
||||
return v
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
Reference in New Issue
Block a user