Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if CLIENT then
- local function add_wf(data)
- local ply = data:ReadEntity()
- local model = data:ReadString()
- local pos = data:ReadVector()
- if ply.clientm and ply.clientm:IsValid() then ply.clientm:Remove() end
- ply.clientm = ClientsideModel(model)
- if not ply.clientm and not ply.clientm:IsValid() then return end
- local cache_model = ply.clientm
- ply.clientm:SetPos(pos)
- ply.clientm:SetSequence(ply:GetSequence())
- ply.clientm:SetModelScale(1.2, 0)
- ply.clientm:SetRenderMode(RENDERMODE_TRANSALPHA)
- ply.clientm:SetMaterial("models/vortigaunt/pupil")
- local a = 255
- hook.Add("Think", "remove_wireframe_tws" .. ply:EntIndex(), function()
- if not ply:IsValid() then
- if cache_model and cache_model:IsValid() then cache_model:Remove() end
- hook.Remove("Think", "remove_wireframe_tws" .. ply:EntIndex())
- end
- if ply.clientm and ply.clientm:IsValid() then
- if a <= 0 then ply.clientm:Remove() hook.Remove("Think", "remove_wireframe_tws" .. ply:EntIndex()) return end
- a = a - 0.5
- ply.clientm:SetColor(Color(255, 255, 255, a))
- ply.clientm:SetAngles(Angle(0, CurTime() * 150, 0))
- end
- end)
- end
- usermessage.Hook("make_wireframe_tws", add_wf)
- cl_spawnpnts = {}
- usermessage.Hook("tws_clear", function() cl_spawnpnts = {} end)
- usermessage.Hook("tws_update", function(data)
- local k = data:ReadString()
- local v = data:ReadVector()
- table.insert(cl_spawnpnts, { name = k, pos = v })
- end)
- local function OpenMenu()
- local current = { name = "Nil", pos = Vector(0, 0, 0) }
- local win = vgui.Create("DFrame")
- win:SetSize(600, 450)
- win:Center()
- win:SetTitle("Spawnpoints manager | " .. game.GetMap())
- win:MakePopup()
- win.Paint = function()
- if win and IsValid(win) then
- local w = win:GetWide()
- local t = win:GetTall()
- draw.RoundedBox(0, 0, 0, w, t, Color(0, 0, 0, 230))
- end
- end
- local lab = vgui.Create("DLabel", win)
- lab:SetPos(230, 40)
- lab:SetFont("Trebuchet24")
- lab.Think = function() if current.name then lab:SetText("Point: " .. current.name) lab:SizeToContents() end end
- local lab = vgui.Create("DLabel", win)
- lab:SetPos(230, 70)
- lab:SetFont("Trebuchet24")
- lab.Think = function() if current.pos then lab:SetText("Pos: " .. tostring(current.pos)) lab:SizeToContents() end end
- local del = vgui.Create("DButton", win)
- del:SetPos(230, 110)
- del:SetSize(100, 25)
- del:SetText("Delete spawn point")
- del.DoClick = function()
- net.Start("tws_removeptn")
- net.WriteString(current.name)
- net.WriteEntity(LocalPlayer())
- net.SendToServer()
- win:Close()
- timer.Simple(0.1, function() if IsValid(LocalPlayer()) then OpenMenu() end end)
- end
- local lst = vgui.Create("DListView", win)
- lst:SetSize(200, 400)
- lst:SetPos(15, 35)
- lst:AddColumn("Spawnpoint")
- for k, v in pairs(cl_spawnpnts) do
- lst:AddLine(v.name)
- end
- lst.OnClickLine = function(parent, line, isselected)
- for k, v in pairs(cl_spawnpnts) do
- if line:GetValue(1) == v.name then current = v break end
- end
- hook.Add("CalcView", "tws_viewing" .. LocalPlayer():EntIndex(), function()
- if not win then hook.Remove("CalcView", "tws_viewing" .. LocalPlayer():EntIndex()) return end
- if not IsValid(win) then hook.Remove("CalcView", "tws_viewing" .. LocalPlayer():EntIndex()) return end
- if LocalPlayer():KeyPressed(IN_ATTACK) then hook.Remove("CalcView", "tws_viewing" .. LocalPlayer():EntIndex()) return end
- local pos
- for k, v in pairs(cl_spawnpnts) do
- if line:GetValue(1) == v.name then pos = v.pos + Vector(0, 0, 50) break end
- end
- if not pos then hook.Remove("CalcView", "tws_viewing" .. LocalPlayer():EntIndex()) return end
- local view = {}
- view.origin = pos
- view.angles = Angle(0, CurTime() * 20, 0)
- view.fov = 90
- return view
- end)
- hook.Add("ShouldDrawLocalPlayer", "tws_shldviewingself" .. LocalPlayer():EntIndex(), function(ply)
- if not win then hook.Remove("ShouldDrawLocalPlayer", "tws_shldviewingself" .. LocalPlayer():EntIndex()) return end
- if not IsValid(win) then hook.Remove("ShouldDrawLocalPlayer", "tws_shldviewingself" .. LocalPlayer():EntIndex()) return end
- return true
- end)
- end
- end
- usermessage.Hook("tws_mngr", OpenMenu)
- return
- end
- function GetSpawnpoints()
- return file.Find("spawnpoints_tws/" .. game.GetMap() .. "/" .. "*.txt", "DATA")
- end
- function UpdateSpawnpoints()
- umsg.Start("tws_clear")
- umsg.End()
- local sp = GetSpawnpoints()
- for i = 1, #sp do
- local ptn = string.Explode(".", sp[i])
- umsg.Start("tws_update")
- umsg.String(ptn[1])
- umsg.Vector(GetSpawnptnPos(ptn[1]))
- umsg.End()
- end
- end
- function ExSpawnptn(name)
- return file.Exists("spawnpoints_tws/" .. game.GetMap() .. "/" .. name .. ".txt", "DATA")
- end
- function GetSpawnptnPos(name)
- if ExSpawnptn(name) then
- local pos = file.Read("spawnpoints_tws/" .. game.GetMap() .. "/" .. name .. ".txt", "DATA")
- pos = string.Explode(" ", pos)
- local num = {}
- for i = 1, 3 do num[i] = pos[i] end
- return Vector(num[1], num[2], num[3])
- else
- return false
- end
- end
- function DelSpawnPoint(name, ply)
- if ExSpawnptn(name) then
- file.Delete("spawnpoints_tws/" .. game.GetMap() .. "/" .. name .. ".txt")
- UpdateSpawnpoints()
- ply:ChatPrint(name .. " spawnpoints was deleted!")
- end
- end
- function AddSpawnPoint(name, ply)
- if ExSpawnptn(name) then ply:ChatPrint("This spawnpoint is already existst!") return end
- file.Write("spawnpoints_tws/" .. game.GetMap() .. "/" .. name .. ".txt", tostring(ply:GetEyeTrace().HitPos))
- UpdateSpawnpoints()
- end
- util.AddNetworkString("tws_addptn")
- util.AddNetworkString("tws_removeptn")
- /**********
- Removing spawnpoint
- **********/
- net.Receive("tws_removeptn", function()
- local name = net.ReadString()
- local ply = net.ReadEntity()
- DelSpawnPoint(name, ply)
- end)
- /**********
- Adding spawnpoint
- **********/
- net.Receive("tws_addptn", function()
- local name = net.ReadString()
- local ply = net.ReadEntity()
- AddSpawnPoint(name, ply)
- end)
- if not file.Exists("spawnpoints_tws", "DATA") then
- file.CreateDir("spawnpoints_tws")
- end
- if not file.Exists("spawnpoints_tws/" .. game.GetMap(), "DATA") then
- file.CreateDir("spawnpoints_tws/" .. game.GetMap())
- else
- UpdateSpawnpoints()
- end
- hook.Add("PlayerSay", "custom_spawnp_tws", function(ply, text, team)
- if not ply:IsAdmin() then return end
- local str = string.Explode(" ", text)
- if str[1] == "/mngr" then
- UpdateSpawnpoints()
- umsg.Start("tws_mngr")
- umsg.End()
- end
- if str[1] == "/delsptn" then
- DelSpawnPoint(str[2], ply)
- return ""
- end
- if str[1] == "/addsptn" then
- AddSpawnPoint(str[2], ply)
- ply:ChatPrint(str[2] .. " spawnpoint is done!")
- return ""
- end
- if str[1] == "/showptn" then
- for k, v in pairs(GetSpawnpoints()) do
- ply:ChatPrint(v)
- end
- return ""
- end
- end)
- hook.Add("PlayerSpawn", "ply_spawn_tws", function(ply)
- local tbl = table.Random(GetSpawnpoints())
- if not tbl then return end
- tbl = string.Explode(".", tbl)
- tbl = tbl[1]
- if GetSpawnptnPos(tbl) then ply:SetPos(GetSpawnptnPos(tbl)) ply:SetEyeAngles(Angle(0, 0, 0)) end
- end)
- hook.Add("PlayerSpawn", "tws_spawnprotect", function(ply)
- if CLIENT then return end
- ply:GodEnable()
- ply:ChatPrint("TEST")
- local model = ply:GetModel()
- local pos = ply:GetPos()
- umsg.Start("make_wireframe_tws")
- umsg.Entity(ply)
- umsg.String(model)
- umsg.Vector(pos)
- umsg.End()
- timer.Simple(6, function()
- if IsValid(ply) then
- ply:GodDisable()
- end
- end)
- end)
- //blocker
- hook.Add("PlayerSpawnSENT", "blocker_tws", function(ply, class)
- if class == "sent_ball" then return false end
- return true
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement