Hello! I'm attempting to create a countdown billboard from the Counter Strike billboard model. I'm not sure if I should use 2d3d or if animated text on a 2d3d would even work or if I'm making more work for myself, which I often do.
I just want a timer on the billboard that everyone on the server can see if they walk past it. I would imagine you could do a simple timer "tostring" for the text but... I'm not sure where to start. Can someone give me a bit of direction? I've been fiddling with the 2d3d on the billboard for a while now and got the roundedbox where I want it but it needs to be pushed outwards and to the left a bit. Is there any way to move the entire axis rotation point?
Can anyone recommend a countdown tutorial/addon I can take a look at? I've spent all day trying to figure it out and I can't wrap my head around how the net messages or draw function or global variables work without actually seeing/reading the code.
Look into Networking Entities to figure out how to network a value. If you want your countdown shared across every billboard, you might want to use SetGlobalFloat instead.
Network the time at which you want your countdown to end OR network the time at which the countdown started and for how long it will be counting down.
function ENT:Draw()
self:DrawModel() --If you don't do this, the actual model won't render.
local pos = self:GetPos()
local ang = self:GetAngles()
ang:RotateAroundAxis(ang:Forward(),90) -- If you add a static angle, it'll mess up badly. Do this instead.
ang:RotateAroundAxis(ang:Right(),-90)
pos = pos + ang:Forward() * -111.2 --Same here: if you just add a vector, this won't be correct on different rotations.
pos = pos + ang:Right() * -57 --Every value here was essentially bruteforced,
pos = pos + ang:Up() * 1 --but if you roll something like easylua, you can do something like ".p this:WorldToLocal(there)" while looking at where you want the cam to be.
cam.Start3D2D(pos, ang, 0.2) --Start the 3D2D rendering context at the new pos&ang
surface.SetDrawColor(0, 0, 0)
surface.DrawRect(0, 0, 1115, 574) --These were bruteforced.
local w, h = 1115, 574 --This will be the width and height of your billboard.
local text = "Some text right here."
--Once you have some way to fetch the time, you can replace "text" with that and it will write out the countdown instead.
draw.SimpleText(text, "Default", w/2, h/2, Color(255, 255, 255, 255), 1) --Also, might want to change the font.
cam.End3D2D()
end
--If formatting is broken, blame facepunch
Thank you I'm having an issue with the countdown.
//Clientside
include("shared.lua")
surface.CreateFont("Whatever", {
font = "Arial",
size = 50,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
} )
killtime = CurTime()
function ENT:Initialize()
self:SetModel("models/props/cs_assault/Billboard.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
net.Receive("killstart", function()
killtime = net.ReadInt(32)
end)
function ENT:Draw()
self:DrawModel()
killtime = killtime - CurTime()
cam.Start3D2D(self:LocalToWorld(Vector(1,-113,60)),self:LocalToWorldAngles(Angle(0,90,90)), .1)
draw.RoundedBox(0,0,0,2250,1200,Color(15,15,15))
draw.RoundedBox(0,200,200,2250-400,1200-400,Color(250,250,120))
draw.SimpleText(killtime,"Whatever",1125,600,Color(120,120,120),1,1)
cam.End3D2D()
end
and
//Server
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
util.AddNetworkString("killstart")
function ENT:Initialize()
self:SetModel("models/props/cs_assault/Billboard.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:Activate()
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
killcountdown()
end
function killcountdown()
net.Start("killstart")
net.WriteInt(CurTime()+1800,32) //I Want the time to be 30 mins (1800 seconds)
net.Broadcast()
end
CurTime() is not behaving like it should, it's counting way faster than a second even with the extra decimals removed.
You're overriding a global "killtime" clientside for every ENTITY:Draw() call.
Use locals:
function ENT:Draw()
self:DrawModel()
local remaining = killtime - CurTime()
cam.Start3D2D(self:LocalToWorld(Vector(1,-113,60)),self:LocalToWorldAngles(Angle(0,90,90)), .1)
draw.RoundedBox(0,0,0,2250,1200,Color(15,15,15))
draw.RoundedBox(0,200,200,2250-400,1200-400,Color(250,250,120))
draw.SimpleText(remaining,"Whatever",1125,600,Color(120,120,120),1,1)
cam.End3D2D()
end
Is there any way to make text bigger than draw.SimpleText ? I've tried draw.DrawText with the same results... the font won't exceed 128.
You can enlarge last argument in 3d2d
tyvm
Sorry, you need to Log In to post a reply to this thread.