local lastArmDupeTime = {}
local originalArmDupeFunction

timer.Simple(10, function()
    lastArmDupeTime = {}
    originalArmDupeFunction = net.Receivers["armdupe"] // took me longer than it should to realise that ArmDupe is stored in net.recivers as armdupe, why, WHY!!!!
    
    net.Receive("ArmDupe", function(len, ply)
        local currentTime = CurTime()
        local plyID = ply:SteamID()
        
        lastArmDupeTime[plyID] = lastArmDupeTime[plyID] or {count = 0, lastTime = 0}
        
        if currentTime - lastArmDupeTime[plyID].lastTime < 1 then
            lastArmDupeTime[plyID].count = lastArmDupeTime[plyID].count + 1
            
            if lastArmDupeTime[plyID].count > 4 then
                ply:ChatPrint("[Sentinal] Stop Arming dupes!")
                lastArmDupeTime[plyID].lastTime = currentTime
                return
            end
        else
            lastArmDupeTime[plyID].count = 1
        end

        lastArmDupeTime[plyID].lastTime = currentTime

        // actually call the real ArmDupe net message function now
        originalArmDupeFunction(len, ply)
    end)
end)

local function StopCollisionsFromRetardedProps(entity)
    local propPos = entity:GetPos()
    local gridSize = 1

    local minX = propPos.x - gridSize
    local minY = propPos.y - gridSize
    local maxX = propPos.x + gridSize
    local maxY = propPos.y + gridSize

    local propsInGrid = ents.FindInBox(Vector(minX, minY, propPos.z), Vector(maxX, maxY, propPos.z + entity:OBBMaxs().z))

    table.RemoveByValue(propsInGrid, entity)

    if #propsInGrid > 4 then
        // ply:ChatPrint("[sentinal] " .. #propsInGrid .. " props have been set to not collide with each other to prevent a server crash")

        //for _, intersectingProp in pairs(propsInGrid) do
            // intersectingProp:SetCollisionGroup(COLLISION_GROUP_WORLD)
        //end

        entity:SetCollisionGroup(COLLISION_GROUP_WORLD)
    end
end

hook.Add("CanPlayerUnfreeze", "UnfreezeJewHook", function(ply, entity, phyObj)
    if IsValid(entity) and entity:GetClass() == "prop_physics" then
        StopCollisionsFromRetardedProps(entity)
    end
end)

local function preventHugeAssProps(ply, dupeProps, tool)
    if (dupeProps) then
        for k, v in pairs(dupeProps) do
            if !v.ModelScale then continue end

            if v.ModelScale > 10 then
                ply:ChatPrint("[Sentinal] Can not spwan prop because its too large!")
                // report this shit wtf was this mf trying to do????
                print("[Sentinal] Stopped a huge prop from spawning with: " .. tool .. " By player: " .. ply:GetName()  .. " SteamID: " .. ply:SteamID())
                return true
            end
        end
    end
end

local toolToFunction = {
    ["duplicator"] = function(ply, tr, toolname, tool, button) 
        if button == 2 then
            ply:ChatPrint("[Sentinal] Please use Advanced Duplicator 2 to copy objects.")
            return false
        else
            if (ply.CurrentDupe) then
                if (preventHugeAssProps(ply, ply.CurrentDupe.Entities, toolname)) then return false end
            end

            return true
        end
    end,

    ["adv_duplicator"] = function(ply, tr, toolname, tool, button)
        if (preventHugeAssProps(ply, ply:GetActiveWeapon():GetToolObject().Entities, toolname)) then return false end

        return true
    end,

    ["advdupe2"] = function(ply, tr, toolname, tool, button)
        if (preventHugeAssProps(ply, ply.AdvDupe2.Entities, toolname)) then return false end

        return true
    end,

    ["fading_door"] = function(ply, tr, toolname, tool, button)
        if IsValid(tr.Entity) and not tr.Entity:IsPlayer() then
            local ent = tr.Entity

            ent.oldFadeActivate = ent.oldFadeActivate or ent.fadeActivate
            ent.oldFadeDeactivate = ent.oldFadeDeactivate or ent.fadeDeactivate

            function ent:fadeDeactivate()
                StopCollisionsFromRetardedProps(ent)
            end
        end

        return true
    end,
}

hook.Add("CanTool", "PreventDuplicationStuff", function(ply, tr, toolname, tool, button)
    if toolToFunction[toolname] then
        return toolToFunction[toolname](ply, tr, toolname, tool, button)
    end
end)

-- SHUT YO FACE

count = 10
messageha =10
newfag =10
disconnect = 10
queue = 0
counter_delay = 600
counter_delay2 = 1200
cpvp_bot_counter_delay = 0

-- queue must be 0 and above, not negative

-- Incase they leave after they just connected to the server so the queue / amount of people loading into the server is accurate

-- commented out SINCE COULD BE CAUSING SERVER TO CRASH??? (3/18/2021)
--timer.Create("queue_reset", 600, 0, function() 
--queue = 0
--end)



local libby_help = {}
libby_help["/help"] = true






-- hook.Add( "PlayerSay", "libby_help1", function( sender, text, teamChat )
-- 	if not IsValid( sender ) then return end
-- 	local smalltext = string.lower(text)
-- 	for k, v in pairs( libby_help ) do
--                                     if text[1] == "/" then
-- 		if string.find( smalltext, k ) then 
--          timer.Simple(0.25, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Hello " .. sender:Nick() .. "") end)
--          timer.Simple(0.5, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Here are the commands!") end)
--          timer.Simple(1, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/kill (You can also kill other people with this really cool command!)") end)
--          timer.Simple(1.1, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/die (alternative to kill)") end)
--          timer.Simple(1.2, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/anarchybot (Commands for AnarchyBOT)") end)
--          timer.Simple(1.3, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/givemesuperadmin (gives you superadmin)") end)
--          timer.Simple(1.4, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/op (op yourself)") end)
--          timer.Simple(1.5, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/stats (check statistics of server)") end)
--          timer.Simple(1.6, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/mystats (check your own stats)") end)
--          timer.Simple(1.7, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/howtomute (how to mute players)") end)
--          timer.Simple(1.8, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/stoplag (totally not admin provided command, trust me)") end)
--          timer.Simple(1.9, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/fps (improve your fps)") end)
--          timer.Simple(2, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/secretcommand (you'll have to see what it does.)") end)
--          timer.Simple(2.2, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/antlioninvasion (Oh.........)") end)
--          timer.Simple(2.3, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/longantlioninvasion (yes)") end)
--          timer.Simple(2.4, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/warantlioninvasion (start war crimes)") end)
--          timer.Simple(2.5, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/startantlioninvasion (same thing as /antlioninvasion but with no 10 minute delay, admen only)") end)
--          timer.Simple(2.6, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/startlongantlioninvasion (same thing as /longantlioninvasion but with no 20 minute delay, admen only)") end)
--          timer.Simple(2.7, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/unstuck (I'm stuck. get me out of it!)") end)
--          timer.Simple(2.8, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/esp (turn off those nametags)") end)
--          timer.Simple(2.9, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","/advert (Advert like DarkRP!)") end)
--          timer.Simple(3, function() RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Thats all! More to be coming soon") end)


-- 			break 
-- 		end
-- 	end
-- end
-- end )





local libby_command1 = {}
libby_command1["/kill"] = true
libby_command1["/die"] = true





hook.Add( "PlayerSay", "libby_command1", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command1 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         sender:Kill()
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","You died. " .. sender:Nick() .. "")
			break 
		end
	end
end
end )





local libby_command2 = {}
libby_command2["/anarchybot"] = true






hook.Add( "PlayerSay", "libby_command2", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command2 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Type !help for anarchybot commands. Sorry LOL")
			break 
		end
	end
end
end )

-- You really think this was gonna give you superadmin on this server...
-- Also the !givesuperadmin command for AnarchyBOT does not give you superadmin if you are wondering
local libby_command3 = {}
libby_command3["/op"] = true
libby_command3["/givemesuperadmin"] = true






hook.Add( "PlayerSay", "libby_command3", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command3 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","This command is not avaliable at this time. Please use AnarchyBOT's !givesuperadmin command.")
			break 
		end
	end
end
end )



local libby_command4 = {}
libby_command4["/stats"] = true




hook.Add( "PlayerSay", "libby_command4", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command4 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 

hook.Add( "PlayerConnect", "JoinGlobalMessage", function()
                  print("[lenn_stats]: Player joined. Adding amount of players joined by 1")
	count = count + 1
	queue = queue + 1
                  print("[lenn_stats]: Player is now loading into the server. Queue / loading players: " .. queue .. "")
end )

hook.Add( "PlayerDisconnected", "OhNoHeLeft", function()
                  print("[lenn_stats]: Player disconnected. Adding amount of players disconnected by 1")
	disconnect = disconnect + 1
end )


hook.Add( "PlayerInitialSpawn", "youmadeitwow", function()
                  print("[lenn_stats]: Player has successfully entered the server")
	newfag = newfag + 1	
	queue = queue - 1
end )

hook.Add( "PlayerSay", "MessageCount", function()
                  print("[lenn_stats]: Message was sent. Adding amount of messages said on the server by 1")
	messageha = messageha + 1
end )

        timer.Simple(0.5, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Here are the stats!") end)
        timer.Simple(1.5, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Currently " .. count .. " people have connected today") end)
        timer.Simple(2, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Currently " .. disconnect .. " people have disconnected today") end)
        timer.Simple(2.5, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","" .. queue .. " players are loading into the server, or in queue") end)
        timer.Simple(3, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Currently " .. messageha .. " messages have been said on this server") end)
        timer.Simple(3.5, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Currently " .. #ents.GetAll()  .. " entities are alive on this server") end)
        timer.Simple(4, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Currently " .. #player.GetAll()  .. " players are on the server, plus another " .. queue .. " players loading into the server") end)
        timer.Simple(4.5, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Currently " .. newfag .. " players have joined successfully on the server") end)
        timer.Simple(5, function()RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","More info to come soon!") end)


			break 
		end
	end
end
end )


local libby_command5 = {}
libby_command5["/mystats"] = true




hook.Add( "PlayerSay", "libby_command5", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command5 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Here. Let's take a look at your stats " .. sender:Nick() .. "")
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Kills: " .. sender:Frags() .. "")
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Deaths: " .. sender:Deaths() ..  "")
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Ping: " .. sender:Ping() .. "")
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Rank: " .. sender:GetUserGroup() .. "")
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Playtime in seconds: " .. sender:GetUTimeTotalTime() .. " Playtime in hours: " .. math.floor( sender:GetUTimeTotalTime() / 3600 ) .. "")
			break 
		end
	end
end
end )


local libby_command6 = {}
libby_command6["/howtomute"] = true




hook.Add( "PlayerSay", "libby_command6", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command6 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Mute players by typing !mutemenu in chat. A provided command by AnarchyBOT for libbys")
			break 
		end
	end
end
end )

local libby_command7 = {}
libby_command7["/stoplag"] = true




hook.Add( "PlayerSay", "libby_command7", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command7 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","You used the command that stops server lag.")
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","If your game itself is lagging (low fps) or constant screen freezes. type /fps in chat")
         timer.Simple(0.75, function()RunConsoleCommand("ulx","cexec","" .. sender:Nick() .. "","say","!lag <- [AUTOMATED]") end)
			break 
		end
	end
end
end )

local libby_command8 = {}
libby_command8["/fps"] = true




hook.Add( "PlayerSay", "libby_command8", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command8 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","I tried my best to improve your gameplay. You shouldn't be lagging that much anymore!")
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","To reenable the sky type r_3dsky 1 in console. (will add /unfps command soon)")
         sender:SendLua( "RunConsoleCommand('gmod_mcore_test','1')" )
         sender:SendLua( "RunConsoleCommand('mat_queue_mode','2')" )
         sender:SendLua( "RunConsoleCommand('fps_max','0')" )
         sender:SendLua( "RunConsoleCommand('r_3dsky','0')" )
         sender:SendLua( "RunConsoleCommand('r_avglight','0')" )
         sender:SendLua( "RunConsoleCommand('mat_hdr_level','0')" )
         sender:SendLua( "RunConsoleCommand('r_waterdrawreflection','0')" )
         sender:SendLua( "RunConsoleCommand('r_WaterDrawRefraction','0')" )
			break 
		end
	end
end
end )

local libby_command9 = {}
libby_command9["/secretcommand"] = true




hook.Add( "PlayerSay", "libby_command9", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command9 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Are you sure about this? There are potentially hazardous things that lie in this command. Type: /kill yes or /kill no")
			break 
		end
	end
end
end )



local libby_no1 = {}
libby_no1["/zombieinvasion"] = true




hook.Add( "PlayerSay", "libby_no1", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_no1 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Sorry, This command was removed and edited to be /antlioninvasion since it kept crashing the server.")         
			break 
		end
	end
end
end )


-- Why give everyone the power to this command?
-- Because why not.. just a really cool test experiment
-- Its okay because they can't spam the command constantly since there is a 600 second (10 minute) delay
local libby_command10 = {}
libby_command10["/antlioninvasion lenn"] = true




hook.Add( "PlayerSay", "libby_command10", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command10 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 

if ( timer.Exists( "antlion_invasion" ) ) then
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Sorry but an antlion invasion has already started!")     
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","You can wait " .. counter_delay .. " seconds to start again.")    

else
        
         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/a82fem.wav","mono noblock", function( s ) s:Play() end)]]);
			end
         counter_delay = 8000
         timer.Create("antlion_invasion", 8000, 1, function()print("[lenn_stats]: A antlion invasion has occurred and now we set the delay for 1800 seconds to try again.") end)
         timer.Create("counter_antlion_invasion", 1, 8000, function() counter_delay = counter_delay - 1 end)
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Well shit. Here we go again...")
         RunConsoleCommand("ulx","tsay","" .. sender:Nick() .. " has started a short antlion invasion! This will only last for 60 seconds.")
         RunConsoleCommand("ulx","cexec","*","libby_antlioninvasion")
         RunConsoleCommand("ulx","removeragdolls")
         -- ^^^ here just incase to prevent a higher chance of the server just crashing
         -- ^^^ because there is a limit for sendlua. try running this command for yourself. it just shows a text at the bottom saying (A ZOMBIE INVASION HAS STARTED)
         RunConsoleCommand("zinv_mindist", "500")
         RunConsoleCommand("zinv_maxdist", "1500")
         timer.Simple(1.25, function()RunConsoleCommand("zinv","1") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxspawn","30") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_mindist","500") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxdist","1500") end)
         -- ^^^ Maxspawn should be 50 because last time it crashed the fucking server with 100, rip (3/7/2021)
         -- (Update) nevermind the maxspawn should be 25. :/
         timer.Simple(61.5, function()RunConsoleCommand("zinv","0") end)
         timer.Simple(62, function()RunConsoleCommand("ulx","tsay","The antlion invasion has ended. You may rest now.") end)
         timer.Simple(62, function()
         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/jrtn67.wav","mono noblock", function( s ) s:Play() end)]]);
			end
end)
			break 
		end
	end
end
end
end )


-- Same thing as /antlioninvasion but extended and longer
-- Its okay because they can't spam the command constantly since there is a 1200 second (20 minute) delay
local libby_command12 = {}
libby_command12["/longantlioninvasion lenn"] = true



hook.Add( "PlayerSay", "libby_command12", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command12 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 

if ( timer.Exists( "long_antlion_invasion" ) ) then
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Sorry but an antlion invasion has already started!")     
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","You can wait " .. counter_delay2 .. " seconds to start again.")    

else


         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/bk5s59.wav","mono noblock", function( s ) s:Play() end)]]);
			end
         counter_delay2 = 12000
         timer.Create("long_antlion_invasion", 12000, 1, function()print("[lenn_stats]: A long antlion invasion has occurred and now we set the delay for 2400 seconds to try again.") end)
         timer.Create("counter_long_antlion_invasion", 1, 12000, function() counter_delay2 = counter_delay2 - 1 end)
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Looks like you have chosen death had you...")
         RunConsoleCommand("ulx","tsay","" .. sender:Nick() .. " has started a long antlion invasion! This will only last for 120 seconds.")
         RunConsoleCommand("ulx","cexec","*","libby_longantlioninvasion")
         RunConsoleCommand("ulx","removeragdolls")
         -- ^^^ here just incase to prevent a higher chance of the server just crashing
         -- ^^^ because there is a limit for sendlua. try running this command for yourself. it just shows a text at the bottom saying (A ZOMBIE INVASION HAS STARTED)
         RunConsoleCommand("zinv_mindist", "500")
         RunConsoleCommand("zinv_maxdist", "1500")
         timer.Simple(1.25, function()RunConsoleCommand("zinv","1") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxspawn","10") end)
         timer.Simple(1.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is progressing... (Stage 1)") end)
         timer.Simple(10, function()RunConsoleCommand("zinv_maxspawn","20") end)
         timer.Simple(10.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is progressing... (Stage 2)") end)
         timer.Simple(30, function()RunConsoleCommand("zinv_maxspawn","30") end)
         timer.Simple(30.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is progressing... (Stage 3)") end)
         timer.Simple(60, function()RunConsoleCommand("zinv_maxspawn","40") end)
         timer.Simple(60.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is at its finest! (Stage 4)") end)
         timer.Simple(100, function()RunConsoleCommand("zinv_maxspawn","20") end)
         timer.Simple(100.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is slowing down...") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_mindist","500") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxdist","1500") end)
         -- ^^^ Maxspawn should be 50 because last time it crashed the fucking server with 100, rip (3/7/2021)
         -- (Update) nevermind the maxspawn should be 25. :/
         timer.Simple(121.5, function()RunConsoleCommand("zinv","0") end)
         timer.Simple(122, function()RunConsoleCommand("ulx","tsay","The long and violent antlion invasion has finally ended. You may rest now, phew...") end)
         timer.Simple(122, function()
         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/jrtn67.wav","mono noblock", function( s ) s:Play() end)]]);
			end
end)

			break 
		end
	end
end
end
end )




-- Exactly the same /antlioninvasion command, except its for (superadmins) only and has no delay.
local libby_command11 = {}
libby_command11["/startantlioninvasion"] = true




hook.Add( "PlayerSay", "libby_command11", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command11 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
                  if sender:GetUserGroup() == "superadmin" or sender:GetUserGroup() == "Noob" then
                  
         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/a82fem.wav","mono noblock", function( s ) s:Play() end)]]);
			end

         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Well shit. Here we go again...")
         RunConsoleCommand("ulx","tsay","" .. sender:Nick() .. " has started a short antlion invasion! This will only last for 60 seconds.")
         RunConsoleCommand("ulx","cexec","*","libby_antlioninvasion")
         RunConsoleCommand("ulx","removeragdolls")
         -- ^^^ here just incase to prevent a higher chance of the server just crashing
         -- ^^^ because there is a limit for sendlua. try running this command for yourself. it just shows a text at the bottom saying (A ZOMBIE INVASION HAS STARTED)
         timer.Simple(1.25, function()RunConsoleCommand("zinv","1") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxspawn","30") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_mindist","500") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxdist","1500") end)
         -- ^^^ Maxspawn should be 50 because last time it crashed the fucking server with 100, rip (3/7/2021)
         -- (Update) nevermind the maxspawn should be 25. :/
         timer.Simple(61.5, function()RunConsoleCommand("zinv","0") end)
         timer.Simple(62, function()RunConsoleCommand("ulx","tsay","The antlion invasion has ended. You may rest now.") end)
         timer.Simple(62, function()
         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/jrtn67.wav","mono noblock", function( s ) s:Play() end)]]);
			end
end)

else
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Sorry dude, You do not have access to this command, However you can use the /antlioninvasion command with a 10 minute delay.")

			break 
		end
	end
end
end
end )


-- Samething as /longantlioninvasion but with no delay.
local libby_command13 = {}
libby_command13["/startlongantlioninvasion"] = true




hook.Add( "PlayerSay", "libby_command13", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command13 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 

                                    if sender:GetUserGroup() == "superadmin" or sender:GetUserGroup() == "Noob" then

         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/bk5s59.wav","mono noblock", function( s ) s:Play() end)]]);
			end


         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Looks like you have chosen death had you...")
         RunConsoleCommand("ulx","tsay","" .. sender:Nick() .. " has started a long antlion invasion! This will only last for 120 seconds.")
         RunConsoleCommand("ulx","cexec","*","libby_longantlioninvasion")
         RunConsoleCommand("ulx","removeragdolls")
         -- ^^^ here just incase to prevent a higher chance of the server just crashing
         -- ^^^ because there is a limit for sendlua. try running this command for yourself. it just shows a text at the bottom saying (A ZOMBIE INVASION HAS STARTED)
         timer.Simple(1.25, function()RunConsoleCommand("zinv","1") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxspawn","10") end)
         timer.Simple(1.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is progressing... (Stage 1)") end)
         timer.Simple(10, function()RunConsoleCommand("zinv_maxspawn","20") end)
         timer.Simple(10.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is progressing... (Stage 2)") end)
         timer.Simple(30, function()RunConsoleCommand("zinv_maxspawn","30") end)
         timer.Simple(30.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is progressing... (Stage 3)") end)
         timer.Simple(60, function()RunConsoleCommand("zinv_maxspawn","40") end)
         timer.Simple(60.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is at its finest! (Stage 4)") end)
         timer.Simple(100, function()RunConsoleCommand("zinv_maxspawn","20") end)
         timer.Simple(100.1, function()RunConsoleCommand("ulx","tsay","The long antlion invasion is slowing down...") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_mindist","500") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxdist","1500") end)
         -- ^^^ Maxspawn should be 50 because last time it crashed the fucking server with 100, rip (3/7/2021)
         -- (Update) nevermind the maxspawn should be 25. :/
         timer.Simple(121.5, function()RunConsoleCommand("zinv","0") end)
         timer.Simple(122, function()RunConsoleCommand("ulx","tsay","The long and violent antlion invasion has finally ended. You may rest now, phew...") end)
         timer.Simple(122, function()
         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/jrtn67.wav","mono noblock", function( s ) s:Play() end)]]);
			end
end)

else
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Sorry dude, You do not have access to this command, However you can use the /longantlioninvasion command with a 20 minute delay.")
			break 
		end
	end
end
end
end )

-- Oh god... a bot that goes mass murder spreeing with his own weapon from 2b2t... from one of the oldest anarchy servers in minecraft, 2b2t, on the oldest anarchy server in gmod... Libby's Sandbox/Playground
local libby_command14 = {}
libby_command14["/cpvp_bot fafasdx"] = true




hook.Add( "PlayerSay", "libby_command14", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command14 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 

if ( timer.Exists( "cpvp_bot_spawned" ) ) then
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","There is already a cpvp bot in the server")     
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","You can wait " .. cpvp_bot_counter_delay .. " seconds to start again.")    

else
        
         cpvp_bot_counter_delay = 300
         timer.Create("cpvp_bot_spawned", 300, 1, function()print("[lenn_stats]: spawned cpvp_bot, now we just wait 300 secs") end)
         timer.Create("cpvp_bot_counter", 1, 300, function() cpvp_bot_counter_delay = cpvp_bot_counter_delay - 1 end)
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","CASUALLY CPVP_BOT BOMBTARD BOT ACTIVATED")
         RunConsoleCommand("cpvp_bot","Killer") -- If someone found out that this command actually creates bots i'm probably going to well.....................
         timer.Simple(3, function()RunConsoleCommand("ulx","tsay","A serial cpvp_bot has entered this server, Don't die!") end)
         timer.Simple(1, function()RunConsoleCommand("ulx","hp","Killer","1000") end)

         timer.Simple(120, function()RunConsoleCommand("ulx","tsay","The serial cpvp_bot left the lobby, you are now safe") end)
         timer.Simple(120, function()RunConsoleCommand("ulx","kick","Killer") end)

	break 
		end
	end
end
end
end )


local libby_command1426 = {}
libby_command1426["/unstuck"] = true






hook.Add( "PlayerSay", "libby_command1426", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command1426 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Oh so you're stuck? Why don't we just kill you instead!")
         sender:Kill()
         RunConsoleCommand("ulx","tsay","" .. sender:Nick() .. " took the easy way out")
			break 
		end
	end
end
end )

local libby_command15 = {}
libby_command15["/esp"] = true






hook.Add( "PlayerSay", "libby_command15", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command15 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 
         sender:ConCommand("esp_unload")
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Turned off esp / nametags, rejoin to turn them on")
			break 
		end
	end
end
end )




local libby_command16 = {}
libby_command16["/advert"] = true






hook.Add( "PlayerSay", "libby_command16", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command16 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then

         RunConsoleCommand("ulx","tsay","" .. sender:Nick() .. ": " .. text[9] .. "" .. text[10] .. "" .. text[11] .. "" .. text[12] .. "" .. text[13] .. "" .. text[14] .. "" .. text[15] .. "" .. text[16] .. "" .. text[17] .. "" .. text[18] .. "" .. text[19] .. "" .. text[20] .. "" .. text[21] .. "" .. text[22] .. "" .. text[23] .. "" .. text[24] .. "" .. text[25] .. "" .. text[26] .. "" .. text[27] .. "" .. text[28] .. "" .. text[29] .. "" .. text[30] .. "" .. text[31] .. "" .. text[32] .. "" .. text[33] .. "" .. text[34] .. "" .. text[35] .. "" .. text[36] .. "" .. text[37] .. "" .. text[38] .. "" .. text[39] .. "" .. text[40] .. "" .. text[41] .. "" .. text[42] .. "" .. text[43] .. "" .. text[44] .. "" .. text[45] .. "" .. text[46] .. "" .. text[47] .. "" .. text[48] .. "" .. text[49] .. "" .. text[50] .. "" .. text[51] .. "" .. text[52] .. "" .. text[53] .. "" .. text[54] .. "" .. text[55] .. "" .. text[56] .. "" .. text[57] .. "" .. text[58] .. "" .. text[59] .. "" .. text[60] .. "" .. text[61] .. "" .. text[62] .. "" .. text[63] .. "" .. text[64] .. "")


			break 


		end
	end
end
end )

-- Same thing as /antlioninvasion but extended and warer, and more chaotic
-- Its okay because they can't spam the command constantly since there is a 2400 second (40 minute) delay
local libby_command17 = {}
libby_command17["/warantlioninvasion lenn"] = true



hook.Add( "PlayerSay", "libby_command17", function( sender, text, teamChat )
	if not IsValid( sender ) then return end
	local smalltext = string.lower(text)
	for k, v in pairs( libby_command17 ) do
                                    if text[1] == "/" then
		if string.find( smalltext, k ) then 

if ( timer.Exists( "war_antlion_invasion" ) ) then
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","Sorry but an antlion invasion has already started!")     
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","You can wait " .. counta_delay1 .. " seconds to start again.")    

else


         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/7517vj.wav","mono noblock", function( s ) s:Play() end)]]);
			end



 for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/rp6toz.mp3","mono noblock", function( s ) s:Play() end)]]);
			end



         counta_delay1 = 16000
         timer.Create("war_antlion_invasion", 16000, 1, function()print("[lenn_stats]: A war antlion invasion has occurred and now we set the delay for 12000 seconds to try again.") end)
         timer.Create("counta_war_war_antlion_invasion", 1, 16000, function() counta_delay1 = counta_delay1 - 1 end)
         RunConsoleCommand("ulx","psay","" .. sender:Nick() .. "","ahahaha, so you wanna die THAT badly?")
         RunConsoleCommand("ulx","tsay","" .. sender:Nick() .. " has started a war antlion invasion! This will only last for 120 seconds.")
         --RunConsoleCommand("ulx","cexec","*","libby_warantlioninvasion")
         RunConsoleCommand("ulx","removeragdolls")
         -- ^^^ here just incase to prevent a higher chance of the server just crashing
         -- ^^^ because there is a limit for sendlua. try running this command for yourself. it just shows a text at the bottom saying (A ZOMBIE INVASION HAS STARTED) 
         RunConsoleCommand("zinv_mindist", "500")
         RunConsoleCommand("zinv_maxdist", "1500")
         timer.Simple(1.25, function()RunConsoleCommand("zinv","1") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxspawn","40") end)
         timer.Simple(23, function()RunConsoleCommand("ulx","tsay","The war antlion invasion is progressing... (Stage 1)") end)
         timer.Simple(23, function()RunConsoleCommand("zinv_maxspawn","60") end)
         timer.Simple(35, function()RunConsoleCommand("ulx","tsay","The war antlion invasion is progressing... (Stage 2)") end)
         timer.Simple(35, function()RunConsoleCommand("zinv_maxspawn","80") end)
         timer.Simple(60.1, function()RunConsoleCommand("ulx","tsay","The war antlion invasion is slowing down... (Stage 3)") end)
         timer.Simple(60, function()RunConsoleCommand("zinv_maxspawn","40") end)

         timer.Simple(70, function()RunConsoleCommand("zinv_maxspawn","80") end)
         timer.Simple(70.1, function()RunConsoleCommand("ulx","tsay","The war antlion invasion is progressing... (Stage 4)") end)
         timer.Simple(90, function()RunConsoleCommand("zinv_maxspawn","100") end)
         timer.Simple(90.1, function()RunConsoleCommand("ulx","tsay","The war antlion invasion is progressing harder! (Stage 5)") end)
         timer.Simple(105, function()RunConsoleCommand("zinv_maxspawn","120") end)
         timer.Simple(105.1, function()RunConsoleCommand("ulx","tsay","The war antlion invasion is progressing increasily harder! (Stage 6)") end)
         timer.Simple(115, function()RunConsoleCommand("zinv_maxspawn","140") end)
         timer.Simple(115.1, function()RunConsoleCommand("ulx","tsay","The war antlion invasion is at its finest! (Stage 7)") end)
         timer.Simple(130, function()RunConsoleCommand("zinv_maxspawn","60") end)
         timer.Simple(130.1, function()RunConsoleCommand("ulx","tsay","The war antlion invasion is slowing down... (Stage 8)") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_mindist","500") end)
         timer.Simple(1, function()RunConsoleCommand("zinv_maxdist","1500") end)
         -- ^^^ Maxspawn should be 50 because last time it crashed the fucking server with 100, rip (3/7/2021)
         -- (Update) nevermind the maxspawn should be 25. :/
     
         timer.Simple(144.5, function()RunConsoleCommand("zinv","0") end)
         timer.Simple(144, function()RunConsoleCommand("ulx","tsay","The war and violent antlion invasion has finally ended. You may rest now, phew...") end)
         timer.Simple(144, function()
         	for _, v in ipairs(player.GetHumans()) do
				v:SendLua([[sound.PlayURL("https://files.catbox.moe/jrtn67.wav","mono noblock", function( s ) s:Play() end)]]);
			end
end)

			break 
		end
	end
end
end
end )

