--[[
	menu_plugins/joinspam.lua
	-MLFR- Anthr4X (Swe) | (STEAM_0:1:33687954)
	===DStream===
]]

CreateClientConVar("fls_spamtimer", "0.1", true, false)

local function JoinSpam()
	RunConsoleCommand("retry")
end

local function JoinMenu()
	local Frame = vgui.Create("DFrame")
		Frame:SetSize(200, 140)
		Frame:SetPos((ScrW() / 2) - 300, 20)
		Frame:SetTitle("Join Spamming")
		Frame:SetSizable(false)
		Frame:SetDraggable(true)
		Frame:MakePopup()
	local TimeAmount = vgui.Create("DTextEntry", Frame)
		TimeAmount:SetSize(150, 20)
		TimeAmount:SetPos(10, 30)
		TimeAmount:SetText("Interval, (Use ping / 1000 like 0.1 for 100ms)")
	local SpamButton = vgui.Create("DButton", Frame)
		SpamButton:SetSize(100, 30)
		SpamButton:SetPos(10, 60)
		SpamButton:SetText("Start Spamming")
		SpamButton.DoClick = function()
			RunConsoleCommand("fls_spamtimer", TimeAmount:GetValue())
			timer.Simple(0.02, function()
				RunConsoleCommand("disconnect")
			end)
			RunConsoleCommand("fls_joinspam")
		end

	local StopSpam = vgui.Create("DButton", Frame)
		StopSpam:SetSize(100, 30)
		StopSpam:SetPos(10, 100)
		StopSpam:SetText("Stop Spamming")
		StopSpam.DoClick = function()
			RunConsoleCommand("fls_stopspam")
		end
end

concommand.Add("fls_joinmenu", JoinMenu)

concommand.Add("fls_joinspam", function()
	timer.Create("JoinSpamming", GetConVar("fls_spamtimer"):GetFloat(), 0, JoinSpam)
end)

concommand.Add("fls_stopspam", function()
	timer.Destroy("JoinSpamming")
	RunConsoleCommand("disconnect")
end)