add sborka
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,319 @@
|
||||
TOOL.Category = "Construction"
|
||||
TOOL.Name = "LED screens"
|
||||
TOOL.Command = nil
|
||||
TOOL.ConfigName = ""
|
||||
|
||||
local TextBox = {}
|
||||
local slider = {}
|
||||
local slider2 = {}
|
||||
local slider3 = {}
|
||||
local frame = {}
|
||||
TOOL.ClientConVar[ "text" ] = ""
|
||||
TOOL.ClientConVar[ "type" ] = 1
|
||||
TOOL.ClientConVar[ "speed" ] = 1.5
|
||||
TOOL.ClientConVar[ "wide" ] = 6
|
||||
TOOL.ClientConVar[ "fx" ] = 0
|
||||
TOOL.ClientConVar[ "wire" ] = 0
|
||||
TOOL.ClientConVar[ "r"] = 255
|
||||
TOOL.ClientConVar[ "g" ] = 200
|
||||
TOOL.ClientConVar[ "b" ] = 0
|
||||
|
||||
if (SERVER) then
|
||||
CreateConVar('sbox_maxledscreens', 5)
|
||||
end
|
||||
|
||||
cleanup.Register("ledscreens")
|
||||
|
||||
TOOL.Information = {
|
||||
{ name = "left" },
|
||||
{ name = "right" }
|
||||
}
|
||||
|
||||
if (CLIENT) then
|
||||
language.Add("Tool.ledscreen.name", "LED screen")
|
||||
language.Add("Tool.ledscreen.desc", "Create a LED panel")
|
||||
|
||||
language.Add("Tool.ledscreen.left", "Spawn a LED panel");
|
||||
language.Add("Tool.ledscreen.right", "Update LED panel");
|
||||
language.Add("Tool.ledscreen.reload", "Copy LED panel's settings");
|
||||
|
||||
language.Add("Undone.ledscreens", "Undone ledscreen")
|
||||
language.Add("Undone_ledscreens", "Undone ledscreen")
|
||||
language.Add("Cleanup.ledscreens", "ledscreens")
|
||||
language.Add("Cleanup_ledscreens", "ledscreens")
|
||||
language.Add("Cleaned.ledscreens", "Cleaned up all ledscreens")
|
||||
language.Add("Cleaned_ledscreens", "Cleaned up all ledscreens")
|
||||
|
||||
language.Add("SBoxLimit.ledscreens", "You've hit the ledscreen limit!")
|
||||
language.Add("SBoxLimit_ledscreens", "You've hit the ledscreen limit!")
|
||||
end
|
||||
|
||||
local function GetConvars(self)
|
||||
local type = tonumber(self:GetClientInfo("type"))
|
||||
if !isnumber(type) then type = 1 end
|
||||
|
||||
local speed = tonumber(self:GetClientInfo("speed"))
|
||||
if !isnumber(speed) then speed = 1.5 end
|
||||
|
||||
local wide = tonumber(self:GetClientInfo("wide"))
|
||||
if !isnumber(wide) then wide = 6 end
|
||||
|
||||
local fx = tonumber(self:GetClientInfo("fx"))
|
||||
if !isnumber(fx) then fx = 0 end
|
||||
|
||||
local r, g, b = tonumber(self:GetClientInfo("r")), tonumber(self:GetClientInfo("g")), tonumber(self:GetClientInfo("b"))
|
||||
if !isnumber(r) or !isnumber(g) or !isnumber(b) then r, g, b = 255, 200, 100 end
|
||||
|
||||
return math.Clamp(type, 1, 4), math.Clamp(speed, 1, 10), math.Clamp(wide, 3, 8), math.Clamp(fx, 0, 1), r, g, b
|
||||
end
|
||||
|
||||
function TOOL:LeftClick(tr)
|
||||
if (tr.Entity:GetClass() == "player") then return false end
|
||||
if (CLIENT) then return true end
|
||||
|
||||
local Ply = self:GetOwner()
|
||||
local centerpos = {
|
||||
[3] = {18, 0},
|
||||
[4] = {11.5, 6},
|
||||
[5] = {18, 6},
|
||||
[6] = {36, 6},
|
||||
[7] = {42, 6},
|
||||
[8] = {48, 6},
|
||||
}
|
||||
|
||||
local type, speed, wide, fx, r, g, b = GetConvars(self)
|
||||
|
||||
local angle = tr.HitNormal:Angle()
|
||||
local SpawnPos = tr.HitPos + angle:Right() * centerpos[wide][1] - angle:Up() * centerpos[wide][2]
|
||||
|
||||
if not (self:GetWeapon():CheckLimit("ledscreens")) then return false end
|
||||
|
||||
local TextScreen
|
||||
if tonumber(self:GetClientInfo("wire")) > 0 then
|
||||
TextScreen = ents.Create("gb_rp_sign_wire")
|
||||
else
|
||||
TextScreen = ents.Create("gb_rp_sign")
|
||||
end
|
||||
TextScreen:SetPos(SpawnPos)
|
||||
TextScreen:Spawn()
|
||||
|
||||
angle:RotateAroundAxis(tr.HitNormal:Angle():Right(), -90)
|
||||
angle:RotateAroundAxis(tr.HitNormal:Angle():Forward(), 90)
|
||||
TextScreen:SetAngles(angle)
|
||||
TextScreen:SetText(self:GetClientInfo("text"))
|
||||
TextScreen:SetType(type)
|
||||
TextScreen:SetSpeed(speed)
|
||||
TextScreen:SetWide(wide)
|
||||
TextScreen:SetModel("models/squad/sf_plates/sf_plate1x"..wide..".mdl")
|
||||
TextScreen:SetTColor(Vector(r/100, g/100, b/100))
|
||||
TextScreen:SetFX(fx)
|
||||
TextScreen:Activate()
|
||||
local Phys = TextScreen:GetPhysicsObject()
|
||||
Phys:EnableMotion( false )
|
||||
|
||||
undo.Create("ledscreens")
|
||||
|
||||
undo.AddEntity(TextScreen)
|
||||
undo.SetPlayer(Ply)
|
||||
undo.Finish()
|
||||
|
||||
Ply:AddCount("ledscreens", TextScreen)
|
||||
Ply:AddCleanup("ledscreens", TextScreen)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function TOOL:RightClick(tr)
|
||||
if (tr.Entity:GetClass() == "player") then return false end
|
||||
if (CLIENT) then return true end
|
||||
|
||||
local TraceEnt = tr.Entity
|
||||
|
||||
local type, speed, wide, fx, r, g, b = GetConvars(self)
|
||||
|
||||
if (TraceEnt:IsValid() and TraceEnt:GetClass() == "gb_rp_sign") then
|
||||
TraceEnt:SetText(self:GetClientInfo("text"))
|
||||
TraceEnt:SetType(type)
|
||||
TraceEnt:SetSpeed(speed)
|
||||
TraceEnt:SetWide(wide)
|
||||
TraceEnt:SetFX(fx)
|
||||
TraceEnt:SetModel("models/squad/sf_plates/sf_plate1x"..wide..".mdl")
|
||||
TraceEnt:SetTColor(Vector(r/100, g/100, b/100))
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function TOOL:Reload(tr)
|
||||
|
||||
if !IsValid(tr.Entity) then return false end
|
||||
local TraceEnt = tr.Entity
|
||||
|
||||
if (TraceEnt:IsValid() and TraceEnt:GetClass() == "gb_rp_sign") then
|
||||
if CLIENT or game.SinglePlayer() then
|
||||
local color = TraceEnt:GetTColor()
|
||||
RunConsoleCommand("ledscreen_text", TraceEnt:GetText())
|
||||
RunConsoleCommand("ledscreen_type", TraceEnt:GetType())
|
||||
RunConsoleCommand("ledscreen_r", color.x*100)
|
||||
RunConsoleCommand("ledscreen_g", color.y*100)
|
||||
RunConsoleCommand("ledscreen_b", color.z*100)
|
||||
RunConsoleCommand("ledscreen_speed", TraceEnt:GetSpeed())
|
||||
RunConsoleCommand("ledscreen_wide", TraceEnt:GetWide())
|
||||
RunConsoleCommand("ledscreen_fx", TraceEnt:GetFX())
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
|
||||
function TOOL.BuildCPanel(CPanel)
|
||||
CPanel:AddControl("Header", { Text = "#Tool.ledscreen.name" } )
|
||||
resetall = vgui.Create("DButton", resetbuttons)
|
||||
resetall:SetSize(100, 25)
|
||||
resetall:SetText("Reset all")
|
||||
resetall.DoClick = function()
|
||||
RunConsoleCommand("ledscreen_text", "")
|
||||
RunConsoleCommand("ledscreen_type", 1)
|
||||
RunConsoleCommand("ledscreen_r", 255)
|
||||
RunConsoleCommand("ledscreen_g", 200)
|
||||
RunConsoleCommand("ledscreen_b", 0)
|
||||
RunConsoleCommand("ledscreen_speed", 1.5)
|
||||
RunConsoleCommand("ledscreen_wide", 6)
|
||||
RunConsoleCommand("ledscreen_fx", 0)
|
||||
RunConsoleCommand("ledscreen_wire", 0)
|
||||
slider:SetValue(1)
|
||||
slider2:SetValue(1.5)
|
||||
slider3:SetValue(6)
|
||||
TextBox:SetValue("")
|
||||
|
||||
end
|
||||
CPanel:AddItem(resetall)
|
||||
local font = "InfoRUS3"
|
||||
frame = vgui.Create( "DPanel" )
|
||||
frame:SetSize( CPanel:GetWide(), 50 )
|
||||
frame.appr = nil
|
||||
frame.Paint = function(self,w,h)
|
||||
draw.RoundedBox(0,0,0,w,h,Color(0,0,0))
|
||||
surface.SetFont(font)
|
||||
local alfa
|
||||
if GetConVarNumber("ledscreen_fx") > 0 then
|
||||
alfa = math.random(100,220)
|
||||
else
|
||||
alfa = 255
|
||||
end
|
||||
self.Text = GetConVarString("ledscreen_text")
|
||||
self.Type = GetConVarNumber("ledscreen_type")
|
||||
self.Speed = GetConVarNumber("ledscreen_speed")
|
||||
self.static = false
|
||||
local ww,hh = surface.GetTextSize(self.Text)
|
||||
local multiplier = self.Speed * 100
|
||||
self.Color = Color(GetConVarNumber("ledscreen_r"),GetConVarNumber("ledscreen_g"),GetConVarNumber("ledscreen_b"), alfa)
|
||||
if self.Type == 1 then
|
||||
|
||||
local xs = (math.fmod(SysTime() * multiplier,w+ww)) - ww
|
||||
draw.DrawText(self.Text,font,xs,0,self.Color,0)
|
||||
|
||||
elseif self.Type == 2 then
|
||||
|
||||
if !self.appr or self.appr > ww then
|
||||
self.appr = -w
|
||||
else
|
||||
self.appr = math.Approach(self.appr, ww+w, FrameTime() * multiplier)
|
||||
end
|
||||
|
||||
draw.DrawText(self.Text,font,self.appr * -1,0,self.Color,0)
|
||||
|
||||
else
|
||||
if !self.appr then
|
||||
self.appr = 0
|
||||
end
|
||||
|
||||
if w > ww then
|
||||
if self.Type == 3 then
|
||||
if self.appr < w-ww and !self.refl then
|
||||
self.appr = math.Approach(self.appr, ww+w, FrameTime() * multiplier)
|
||||
else
|
||||
if self.appr <= 0 then
|
||||
self.refl = nil
|
||||
else
|
||||
self.refl = true
|
||||
self.appr = math.Approach(self.appr, 0, FrameTime() * multiplier)
|
||||
end
|
||||
end
|
||||
else
|
||||
self.static = true
|
||||
end
|
||||
else
|
||||
if self.appr > w-ww-50 and !self.refl then
|
||||
self.appr = math.Approach(self.appr, w-ww-50, FrameTime() * multiplier)
|
||||
else
|
||||
if self.appr >= 50 then
|
||||
self.refl = nil
|
||||
else
|
||||
self.refl = true
|
||||
self.appr = math.Approach(self.appr, 50, FrameTime() * multiplier)
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.static then
|
||||
draw.DrawText(self.Text,font,w/2,0,self.Color,1)
|
||||
else
|
||||
draw.DrawText(self.Text,font,self.appr,0,self.Color,0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
CPanel:AddItem(frame)
|
||||
|
||||
|
||||
slider = vgui.Create("DNumSlider")
|
||||
slider:SetText("Type")
|
||||
slider:SetMinMax(1, 4)
|
||||
slider:SetDecimals(0)
|
||||
slider:SetValue(1)
|
||||
slider:SetConVar("ledscreen_type")
|
||||
CPanel:AddItem(slider)
|
||||
|
||||
slider2 = vgui.Create("DNumSlider")
|
||||
slider2:SetText("Speed")
|
||||
slider2:SetMinMax(1, 10)
|
||||
slider2:SetDecimals(1)
|
||||
slider2:SetValue(1)
|
||||
slider2:SetConVar("ledscreen_speed")
|
||||
CPanel:AddItem(slider2)
|
||||
|
||||
slider3 = vgui.Create("DNumSlider")
|
||||
slider3:SetText("Wide")
|
||||
slider3:SetMinMax(3, 8)
|
||||
slider3:SetDecimals(0)
|
||||
slider3:SetValue(6)
|
||||
slider3:SetConVar("ledscreen_wide")
|
||||
CPanel:AddItem(slider3)
|
||||
|
||||
TextBox = vgui.Create("DTextEntry")
|
||||
TextBox:SetUpdateOnType(true)
|
||||
TextBox:SetEnterAllowed(true)
|
||||
TextBox:SetConVar("ledscreen_text")
|
||||
TextBox:SetValue(GetConVarString("ledscreen_text"))
|
||||
CPanel:AddItem(TextBox)
|
||||
|
||||
CPanel:AddControl( "CheckBox", { Label = "Flicker effect", Description = "", Command = "ledscreen_fx" } )
|
||||
CPanel:AddControl( "CheckBox", { Label = "WireMod support", Description = "", Command = "ledscreen_wire" } )
|
||||
|
||||
CPanel:AddControl("Color", {
|
||||
Label = "LED color",
|
||||
Red = "ledscreen_r",
|
||||
Green = "ledscreen_g",
|
||||
Blue = "ledscreen_b",
|
||||
ShowHSV = 1,
|
||||
ShowRGB = 1,
|
||||
Multiplier = 255
|
||||
})
|
||||
|
||||
CPanel:AddControl("Label", { Text = "Gmod-Best.Ru ©2013-2019\nWith <3 from Mac" } )
|
||||
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
PermaProps
|
||||
Created by Entoros, June 2010
|
||||
Facepunch: http://www.facepunch.com/member.php?u=180808
|
||||
Modified By Malboro 28 / 12 / 2012
|
||||
|
||||
Ideas:
|
||||
Make permaprops cleanup-able
|
||||
|
||||
Errors:
|
||||
Errors on die
|
||||
|
||||
Remake:
|
||||
By Malboro the 28/12/2012
|
||||
*/
|
||||
|
||||
TOOL.Category = "Props Tool"
|
||||
TOOL.Name = "PermaProps"
|
||||
TOOL.Command = nil
|
||||
TOOL.ConfigName = ""
|
||||
|
||||
if CLIENT then
|
||||
language.Add("Tool.permaprops.name", "PermaProps")
|
||||
language.Add("Tool.permaprops.desc", "Save a props permanently")
|
||||
language.Add("Tool.permaprops.0", "LeftClick: Add RightClick: Remove Reload: Update")
|
||||
|
||||
surface.CreateFont("PermaPropsToolScreenFont", { font = "Arial", size = 40, weight = 1000, antialias = true, additive = false })
|
||||
surface.CreateFont("PermaPropsToolScreenSubFont", { font = "Arial", size = 30, weight = 1000, antialias = true, additive = false })
|
||||
end
|
||||
|
||||
function TOOL:LeftClick(trace)
|
||||
|
||||
if CLIENT then return true end
|
||||
|
||||
local ent = trace.Entity
|
||||
local ply = self:GetOwner()
|
||||
|
||||
if not PermaProps then ply:ChatPrint( "ERROR: Lib not found" ) return end
|
||||
|
||||
if !PermaProps.HasPermission( ply, "Save") then return end
|
||||
|
||||
if not ent:IsValid() then ply:ChatPrint( "That is not a valid entity !" ) return end
|
||||
if ent:IsPlayer() then ply:ChatPrint( "That is a player !" ) return end
|
||||
if ent.PermaProps then ply:ChatPrint( "That entity is already permanent !" ) return end
|
||||
|
||||
local content = PermaProps.PPGetEntTable(ent)
|
||||
if not content then return end
|
||||
|
||||
local max = tonumber(sql.QueryValue("SELECT MAX(id) FROM permaprops;"))
|
||||
if not max then max = 1 else max = max + 1 end
|
||||
|
||||
local new_ent = PermaProps.PPEntityFromTable(content, max)
|
||||
if !new_ent or !new_ent:IsValid() then return end
|
||||
|
||||
PermaProps.SparksEffect( ent )
|
||||
|
||||
PermaProps.SQL.Query("INSERT INTO permaprops (id, map, content) VALUES(NULL, ".. sql.SQLStr(game.GetMap()) ..", ".. sql.SQLStr(util.TableToJSON(content)) ..");")
|
||||
ply:ChatPrint("You saved " .. ent:GetClass() .. " with model ".. ent:GetModel() .. " to the database.")
|
||||
|
||||
ent:Remove()
|
||||
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
function TOOL:RightClick(trace)
|
||||
|
||||
if CLIENT then return true end
|
||||
|
||||
local ent = trace.Entity
|
||||
local ply = self:GetOwner()
|
||||
|
||||
if not PermaProps then ply:ChatPrint( "ERROR: Lib not found" ) return end
|
||||
|
||||
if !PermaProps.HasPermission( ply, "Delete") then return end
|
||||
|
||||
if not ent:IsValid() then ply:ChatPrint( "That is not a valid entity !" ) return end
|
||||
if ent:IsPlayer() then ply:ChatPrint( "That is a player !" ) return end
|
||||
if not ent.PermaProps then ply:ChatPrint( "That is not a PermaProp !" ) return end
|
||||
if not ent.PermaProps_ID then ply:ChatPrint( "ERROR: ID not found" ) return end
|
||||
|
||||
PermaProps.SQL.Query("DELETE FROM permaprops WHERE id = ".. ent.PermaProps_ID ..";")
|
||||
|
||||
ply:ChatPrint("You erased " .. ent:GetClass() .. " with a model of " .. ent:GetModel() .. " from the database.")
|
||||
|
||||
ent:Remove()
|
||||
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
function TOOL:Reload(trace)
|
||||
|
||||
if CLIENT then return true end
|
||||
|
||||
if not PermaProps then self:GetOwner():ChatPrint( "ERROR: Lib not found" ) return end
|
||||
|
||||
if (not trace.Entity:IsValid() and PermaProps.HasPermission( self:GetOwner(), "Update")) then self:GetOwner():ChatPrint( "You have reload all PermaProps !" ) PermaProps.ReloadPermaProps() return false end
|
||||
|
||||
if trace.Entity.PermaProps then
|
||||
|
||||
local ent = trace.Entity
|
||||
local ply = self:GetOwner()
|
||||
|
||||
if !PermaProps.HasPermission( ply, "Update") then return end
|
||||
|
||||
if ent:IsPlayer() then ply:ChatPrint( "That is a player !" ) return end
|
||||
|
||||
local content = PermaProps.PPGetEntTable(ent)
|
||||
if not content then return end
|
||||
|
||||
PermaProps.SQL.Query("UPDATE permaprops set content = ".. sql.SQLStr(util.TableToJSON(content)) .." WHERE id = ".. ent.PermaProps_ID .." AND map = ".. sql.SQLStr(game.GetMap()) .. ";")
|
||||
|
||||
local new_ent = PermaProps.PPEntityFromTable(content, ent.PermaProps_ID)
|
||||
if !new_ent or !new_ent:IsValid() then return end
|
||||
|
||||
PermaProps.SparksEffect( ent )
|
||||
|
||||
ply:ChatPrint("You updated the " .. ent:GetClass() .. " in the database.")
|
||||
|
||||
ent:Remove()
|
||||
|
||||
|
||||
else
|
||||
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
function TOOL.BuildCPanel(panel)
|
||||
|
||||
panel:AddControl("Header",{Text = "PermaProps", Description = "PermaProps\n\nSaves entities across map changes\n"})
|
||||
panel:AddControl("Button",{Label = "Open Configuration Menu", Command = "pp_cfg_open"})
|
||||
|
||||
end
|
||||
|
||||
function TOOL:DrawToolScreen(width, height)
|
||||
|
||||
if SERVER then return end
|
||||
|
||||
surface.SetDrawColor(17, 148, 240, 255)
|
||||
surface.DrawRect(0, 0, 256, 256)
|
||||
|
||||
surface.SetFont("PermaPropsToolScreenFont")
|
||||
local w, h = surface.GetTextSize(" ")
|
||||
surface.SetFont("PermaPropsToolScreenSubFont")
|
||||
local w2, h2 = surface.GetTextSize(" ")
|
||||
|
||||
draw.SimpleText("PermaProps", "PermaPropsToolScreenFont", 128, 100, Color(224, 224, 224, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, Color(17, 148, 240, 255), 4)
|
||||
draw.SimpleText("By Malboro", "PermaPropsToolScreenSubFont", 128, 128 + (h + h2) / 2 - 4, Color(224, 224, 224, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, Color(17, 148, 240, 255), 4)
|
||||
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user