Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ENT.Type = "anim"
- ENT.Base = "base_anim"
- if SERVER then
- function ENT:Initialize()
- self.Entity:SetModel( "models/props_gameplay/sign_gameplay01.mdl" )
- self.Entity:PhysicsInit( SOLID_VPHYSICS )
- self.Entity:SetMoveType( MOVETYPE_NONE )
- self.Entity:SetSolid( SOLID_VPHYSICS )
- self.Entity:SetCollisionGroup( COLLISION_GROUP_WORLD )
- self.Entity:DrawShadow( true )
- if SERVER then self:SetUseType(SIMPLE_USE) end
- local phys = self:GetPhysicsObject()
- if (phys:IsValid()) then
- phys:Wake()
- //phys:EnableMotion(false)
- end
- end
- local function SignCon( player, command, a )
- local ent = Entity(tonumber(a[1]))
- if player != ent.dt.Owner then return end
- ent.dt.Line1 = tostring(a[2])
- ent.dt.Line2 = tostring(a[3])
- ent.dt.LineCol = Vector(tonumber(a[4]), tonumber(a[5]), tonumber(a[6]))
- ent.dt.BackCol = Vector(tonumber(a[7]), tonumber(a[8]), tonumber(a[9]))
- ent.dt.Spin = tonumber(a[10])
- end
- concommand.Add( "UpdateSign", SignCon )
- end
- function ENT:SetupDataTables()
- self:DTVar( "String", 0, "Line1" );
- self:DTVar( "String", 1, "Line2" );
- self:DTVar( "Vector", 0, "LineCol" );
- self:DTVar( "Vector", 1, "BackCol" );
- self:DTVar( "Angle", 0, "BeginAngle" );
- self:DTVar( "Int", 0, "Spin" );
- self:DTVar( "Entity", 0, "Owner" );
- end
- function ENT:Setup( owner )
- if owner:IsPlayer() == false then return end
- self.dt.Owner = owner
- local ply = owner
- local trace = ply:GetEyeTrace()
- local ang = trace.HitNormal:Angle()
- self.dt.BeginAngle = ang
- self.dt.LineCol = Vector(255,255,255)
- self.dt.Line1 = "Test 1"
- self.dt.Line2 = "Test 2"
- print(ang, type(ang), self.dt.BeginAngle)
- self:SetPos( trace.HitPos )
- self:SetAngles( ang )
- end
- function ENT:Think()
- local ang = self.dt.BeginAngle
- ang:RotateAroundAxis( ang:Forward(), self.dt.Spin )
- self:SetAngles(ang)
- self:NextThink(CurTime())
- return true
- end
- function ENT:AcceptInput( t, activator )
- if t~="Use" then return end
- local owner=self.dt and IsValid(self.dt.Owner) and self.dt.Owner or self.CPPIGetOwner and IsValid(self:CPPIGetOwner()) and self:CPPIGetOwner()
- if IsValid(owner) then
- if owner~=activator then
- return
- end
- end
- activator:SendLua("Entity("..self:EntIndex().."):ClientUse()")
- end
- if CLIENT then
- ENT.Menu = nil
- local fontdata = {
- font = "coolvetica",
- size = 100,
- weight = 500,
- antialias = true
- }
- surface.CreateFont( "SignNormal", fontdata )
- function ENT:UpdateServer( t1, t2, lcol, bcol, spin )
- print(t1, t2, lcol, bcol, spin)
- LocalPlayer():ConCommand("UpdateSign "..self:EntIndex().." "..t1.." "..t2.." "..lcol.x.." "..lcol.y.." "..lcol.z.." "..bcol.x.." "..bcol.y.." "..bcol.z.." "..spin)
- end
- function ENT:ClientUse()
- self.Menu = vgui.Create("DFrame")
- self.Menu:SetSize(350, 200)
- self.Menu:SetPos(ScrW()/2 - 175, ScrH()/2)
- self.Menu:SetTitle("Edit Sign")
- self.Menu:ShowCloseButton(false)
- self.Menu:MakePopup()
- local Close = vgui.Create("DButton", self.Menu)
- Close:SetText( "Close" )
- Close:SetPos( self.Menu:GetWide() - 50 , 5 )
- Close:SetSize( 40, 15 )
- local Rotate = vgui.Create( "DNumSlider", self.Menu )
- Rotate:SetPos( 10,25 )
- Rotate:SetWide( 360 )
- Rotate:SetText( "Sign Rotation" )
- Rotate:SetMin( 0 )
- Rotate:SetMax( 360 )
- Rotate:SetDecimals( 0 )
- Rotate:SetValue(self.dt.Spin)
- Rotate.OnValueChanged = function(s, val)
- self.dt.Spin = val
- end
- local LineColLabel = vgui.Create("DLabel", self.Menu)
- LineColLabel:SetPos(10,60) // Position
- LineColLabel:SetColor(Color(255,255,255,150)) // Color
- LineColLabel:SetFont("DermaDefault")
- LineColLabel:SetText("Set Line Color:") // Text
- LineColLabel:SizeToContents()
- local LineCol = vgui.Create( "DColorMixer", self.Menu )
- LineCol:SetPos( 10, 80 )
- LineCol:SetSize( 159, 75 )
- if LineCol.SetPalette != nil then
- LineCol:SetPalette(false)
- end
- LineCol:SetAlphaBar(false)
- LineCol.ValueChanged = function(s, col)
- self.dt.LineCol = Vector(col.r, col.g, col.b)
- end
- local dtlc = self.dt.LineCol
- LineCol:SetColor(Color(dtlc.x,dtlc.y,dtlc.z))
- local BackColLabel = vgui.Create("DLabel", self.Menu)
- BackColLabel:SetPos(180,60) // Position
- BackColLabel:SetColor(Color(255,255,255,150)) // Color
- BackColLabel:SetFont("DermaDefault")
- BackColLabel:SetText("Set Back Color:") // Text
- BackColLabel:SizeToContents()
- local BackCol = vgui.Create( "DColorMixer", self.Menu )
- BackCol:SetPos( 180, 80 )
- BackCol:SetSize( 159, 75 )
- if BackCol.SetPalette != nil then
- BackCol:SetPalette(false)
- end
- BackCol:SetAlphaBar(false)
- BackCol:SetAlphaBar(false)
- BackCol.ValueChanged = function(s, col)
- self.dt.BackCol = Vector(col.r, col.g, col.b)
- end
- local dtlc2 = self.dt.BackCol
- BackCol:SetColor(Color(dtlc2.x,dtlc2.y,dtlc2.z))
- local LineTextLabel = vgui.Create("DLabel", self.Menu)
- LineTextLabel:SetPos(10,169) // Position
- LineTextLabel:SetColor(Color(255,255,255,150)) // Color
- LineTextLabel:SetFont("DermaDefault")
- LineTextLabel:SetText("Text 1") // Text
- LineTextLabel:SizeToContents()
- local LineText = vgui.Create("DTextEntry", self.Menu)
- LineText:SetPos( 50, 165 )
- LineText:SetSize( 120, 24 )
- LineText:SetText(self.dt.Line1)
- LineText.OnChange = function(s)
- local val = s:GetValue()
- self.dt.Line1 = val
- end
- LineText.AllowInput = function( s, val )
- if string.len(s:GetValue()) >= 20 then return true end
- end
- local Line2TextLabel = vgui.Create("DLabel", self.Menu)
- Line2TextLabel:SetPos(180,169) // Position
- Line2TextLabel:SetColor(Color(255,255,255,150)) // Color
- Line2TextLabel:SetFont("DermaDefault")
- Line2TextLabel:SetText("Text 2") // Text
- Line2TextLabel:SizeToContents()
- local Line2Text = vgui.Create("DTextEntry", self.Menu)
- Line2Text:SetPos( 220, 165 )
- Line2Text:SetSize( 120, 24 )
- Line2Text:SetText(self.dt.Line2)
- Line2Text.OnChange = function(s)
- local val = s:GetValue()
- self.dt.Line2 = val
- end
- Line2Text.AllowInput = function( s, val )
- if string.len(s:GetValue()) >= 20 then return true end
- end
- Close.DoClick = function()
- self.Menu:Close()
- self.Menu = nil
- self:UpdateServer( self.dt.Line1, self.dt.Line2, self.dt.LineCol, self.dt.BackCol, self.dt.Spin )
- end
- end
- function ENT:Draw()
- local scrx, scry = (self:GetPos() - Vector( 64, 0, 12 )):ToScreen().x, (self:GetPos() - Vector( 64, 0, 12 )):ToScreen().y
- local scrx2, scry2 = (self:GetPos() + Vector( 64, 0, 12 )):ToScreen().x, (self:GetPos() + Vector( 64, 0, 12 )):ToScreen().y
- self:DrawModel()
- local ang = self:GetAngles()
- ang:RotateAroundAxis(ang:Right(), -90)
- ang:RotateAroundAxis(ang:Up(), 90)
- local LineCol = Color(self.dt.LineCol.x, self.dt.LineCol.y, self.dt.LineCol.z, 255)
- local BackCol = Color(self.dt.BackCol.x, self.dt.BackCol.y, self.dt.BackCol.z, 255)
- cam.Start3D2D( self:GetPos() + self:GetForward() * 2, ang, 0.1 )
- draw.RoundedBox( 0, -330, -100, 660, 200, BackCol )
- draw.DrawText(self.dt.Line1, "SignNormal", 0, -100, LineCol, TEXT_ALIGN_CENTER)
- draw.DrawText(self.dt.Line2, "SignNormal", 0, 0, LineCol, TEXT_ALIGN_CENTER)
- cam.End3D2D()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment