freeslot("sfx_aaaa", "sfx_lneon", "sfx_lstar")



local function drawgif(v, p)
	--if p.rickrolled == nil then
		--return -- aint no overflow anymore
	--end
	if p.timer == nil then -- dunno this got me errors so whatever
		return
	end
	local padthething = "ANIM"
	local scale = FRACUNIT
	if p.rickrolled == 2 then
		scale = FRACUNIT/2
		padthething = "FRAME_"
		if p.timer < 10 then
			padthething = "FRAME_0"
		end
	end
	local string = padthething .. tostring(p.timer)
	local patch = v.cachePatch(string)
	v.drawScaled(0, 0, scale, patch)
	-- feels too much like some snes antipiracy thing
	-- Jon prefers no mercy but i prefer funnies
	-- since they already were put to an end
	if p.rickrolled == 2 then
		v.drawString(32, 320/2 - 8, "youtube upload coming like, in a day or two hopefully\nhappy april fools lmaaaooooooo", V_ALLOWLOWERCASE, "small")
	end
end
hud.add(drawgif) 
local function timer(p)
	if p.rickrolled == nil then
		p.rickrolled = 1
	end
	if p.subtimer == nil then
		p.subtimer = 0
		p.timer = 0
	end
	-- sounds
	if p.rickrolled == 1 and p.subtimer & 1 == 0 then
		if p.timer == 1 then
			S_StartSoundAtVolume(p.mo, sfx_lneon, 150)
		end
		if p.timer == 19 then
			S_StartSound(p.mo, sfx_lstar)
		end
		if p.timer == 19 then
			S_StartSound(p.mo, sfx_lstar)
		end
		if p.timer == 64 then
			S_StartSound(p.mo, sfx_s3k9e)
		end
		if p.timer == 82 then
			S_StartSound(p.mo, sfx_aaaa)
		end
	end
	if p.rickrolled == 2 then
		S_StopSoundByID(p.mo, sfx_aaaa)
	end
	
	p.subtimer = p.subtimer+1
	if p.subtimer & 1 == 0 then
		p.timer = p.timer + 1
	end
	if p.rickrolled == 2 then
		COM_BufInsertText(p, "tunes VSRICK")
	else
		COM_BufInsertText(p, "tunes -none")
	end
	if p.timer == 31 and p.rickrolled == 2 then
		p.timer = 0 
	end
	if p.timer > 86 then
		p.timer = 0
		p.rickrolled = 2
	end
end
addHook("PlayerThink",timer)

-- old code when people were concerned about that chat overflow that crashed shit, long gone now but appearently people dont like funny rickroll when attempt to crash the server

--i take from some guy on discord called Jon#2538
--[[addHook("PlayerMsg", function(p, _, _, m)
    if #m > 220 then
        --COM_BufInsertText(p, "quit")
		p.rickrolled = "something that exists"
        return true
    end
end)
haha yeah no

]]