local shrekTimerName = "shrek_psay_loop"
local shrekActive = false
 
concommand.Add("shrek_psay_all", function()
    if shrekActive then
        print("[Shrek PSAY] Already running.")
        return
    end
 
    local shrekLines = {
        "Once upon a time...",
        "In a far, far away kingdom...",
        "People take one look at me and go, 'Ahh! Help! Run! A big, stupid, ugly ogre!'",
        "They judge me before they even know me.",
        "Ogres are like onions. They have layers.",
        "No! You dense, irritating, miniature beast of burden!",
        "What are you doing in my swamp?!",
        "Some of you may die, but it’s a sacrifice I’m willing to make.",
        "Don’t mess with me. I’m an ogre!",
        "That’ll do, Donkey. That’ll do.",
        "I live in a swamp! I put up signs! I'm a terrifying ogre! What do I have to do to get a little privacy?!",
        "And in the morning, I'm making waffles!",
        "You know what ELSE everybody likes? Parfaits!",
        "Donkey, you have the right to remain silent. What you lack is the capacity.",
        "It's not that bad. You're not that ugly. Well, you are ugly... but you only look like this at night.",
        "You were expecting Prince Charming?",
        "Let's do that again!",
        "Ogres are not like cakes!",
        "You can't tell me you're afraid of heights.",
        "Stop singing! It's no wonder you don’t have any friends.",
        "I’m an ogre! You know, 'Grab your torch and pitchforks!' Doesn’t that bother you?",
        "I was just kidding! HAHA! That was a good one!",
        "That’s another thing we have in common. Like parfaits, and layers, and rejection.",
        "Hey, now. You’re an all-star, get your game on, go play.",
        "She’s as nasty as you are!",
        "We can stay up late, swapping manly stories, and in the morning... I’m making waffles!",
        "What? It’s a compliment! Better out than in, I always say!",
        "Man, did you see the size of that onion?",
        "I like my privacy.",
        "It’s on my to-do list, okay?",
        "They were hiding in the bushes, the whole time!",
        "Not everybody likes onions.",
        "You cut me deep, Shrek. You cut me real deep just now.",
        "Whoa, Shrek! Did you do that? Man, you gotta warn somebody before you just crack one off!",
        "This is gonna be fun! We’ll stay up late, tell stories...",
        "Do you remember your first kiss?",
        "Oh sure, blame it on the little guy!",
        "Wait a minute, I know what’s going on here. You’re afraid of the dark, aren’t you?",
        "Maybe it's a perk!",
        "This is worse than the time I got stuck in a porta-potty!",
        "Why don’t you just pull some of that ogre stuff on him?",
        "Oh, you're gonna love it there, Fiona. It's got everything!",
        "That's the most beautiful thing I've ever seen.",
        "You're not exactly what I expected.",
        "You don't have to waste good manners on the ogre. It's not like it has feelings.",
        "Mirror, mirror, on the wall, is this not the most perfect kingdom of them all?",
        "Bachelorette number two is a cape-wearing girl from the land of fancy. Although she lives with seven other men, she's not easy.",
        "And remember, dear people, if you see a strange creature, report it immediately!",
        "You really ARE something special, Donkey.",
        "The world is more complicated than you think.",
        "I don't have time for this! I have to save my [removed]!",
        "You have the right to remain silent. Anything you say will be ignored, because you're an ogre."
    }
 
    local lineIndex = 1
    shrekActive = true
 
    timer.Create(shrekTimerName, 2, 0, function()
        if not shrekActive then
            timer.Remove(shrekTimerName)
            return
        end
 
        if lineIndex > #shrekLines then
            print("[Shrek PSAY] All lines sent.")
            shrekActive = false
            timer.Remove(shrekTimerName)
            return
        end
 
        local line = shrekLines[lineIndex]
        for _, ply in ipairs(player.GetAll()) do
            if IsValid(ply) then
                RunConsoleCommand("ulx", "psay", ply:Nick(), line)
            end
        end
 
        lineIndex = lineIndex + 1
    end)
 
    print("[Shrek PSAY] Started sending Shrek quotes.")
end)
 
concommand.Add("shrek_psay_stop", function()
    if shrekActive then
        shrekActive = false
        timer.Remove(shrekTimerName)
        print("[Shrek PSAY] Stopped.")
    else
        print("[Shrek PSAY] Was not running.")
    end
end)