Budget
Category
Applications
Views
I have a rather strange problem, I tried to add the effect of falling snow to my TTTT scoreboard, but something strange happens.
This is the script for snow animation (located in autorun / client):
local NEGPI2 = math.pi * -2 local snowmaxstartheight = -1.5 local snowflakeminsize = 0.1 local segmentslowerbound,segmentsupperbound = 6,9 local radiuslowerbound,radiusupperbound = 2,5 local snowflakefallspeed = 80 local snowflakeshrinkspeed = 1 local Segments = {} local function GenerateSegments(seg) Segments[seg] = {} for i = 1, seg do local a = (i / seg) * NEGPI2 Segments[seg][i] = {math.sin( a ),math.cos( a )} end return Segments[seg] end function draw.Circle( x, y, radius, seg ) local cir = {} local segments = Segments[seg] or GenerateSegments(seg) for i = 1,seg do cir[i] = {x = x + segments[i][1] * radius, y = y + segments[i][2] * radius} end surface.DrawPoly( cir ) end function DrawSnow(pnl, amt) pnl.snowtbl = {} for i = 1,amt do pnl.snowtbl[i] = {math.random(pnl:GetTall() * snowmaxstartheight, 0),math.random(pnl:GetWide()),math.random(radiuslowerbound,radiusupperbound),math.random(segmentslowerbound,segmentsupperbound)} end local snowtbl = pnl.snowtbl surface.SetDrawColor(230, 230, 250, 200) draw.NoTexture() for i = 1, amt do if (snowtbl[i][1] >= pnl:GetTall()) then snowtbl[i][3] = Lerp(snowflakeshrinkspeed * FrameTime(), snowtbl[i][3], 0) if (snowtbl[i][3] <= snowflakeminsize) then snowtbl[i][1] = math.random(pnl:GetTall() * snowmaxstartheight,0) snowtbl[i][2] = math.random(pnl:GetWide()) snowtbl[i][3] = math.random(radiuslowerbound,radiusupperbound) snowtbl[i][4] = math.random(segmentslowerbound,segmentsupperbound) end else snowtbl[i][1] = math.Approach(snowtbl[i][1], pnl:GetTall(), snowflakefallspeed * FrameTime()) end draw.Circle( snowtbl[i][2], snowtbl[i][1], snowtbl[i][3], snowtbl[i][4] ) end end
In sb_main, in "function PANEL:Paint()" I have this:
DrawSnow(self, 50)
And here the problem arises - when everything is done as I have presented, the snow blocks on the upper edge and does not fall down, only after removing this part everything works as it should:
pnl.snowtbl = {} for i = 1,amt do pnl.snowtbl[i] = {math.random(pnl:GetTall() * snowmaxstartheight, 0),math.random(pnl:GetWide()),math.random(radiuslowerbound,radiusupperbound),math.random(segmentslowerbound,segmentsupperbound)} end
However, after rebooting the server or changing map without providing this part of function, the script does not work again, so to make it works, I have to do the following:
- Use the entire script that I gave at the beginning,
- delete the given part of the function when the server is on.
However, just change the map, and again nothing works - I need a person who can fix it.