Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The Unknown Racing Club Welcome Popup for Assetto Corsa
- -- Place this in your server's LUA script folder
- --
- -- Logo loads directly from: https://i.ibb.co/DfZ87CPq/logo.png
- local showWelcomePopup = true
- local popupTimer = 0
- local fadeAnimation = 0
- local buttonHovered = false
- -- UI scaling factor
- local uiScale = 1.0
- -- Function to draw clean rectangle (no rounded corners to avoid circle artifacts)
- function drawRoundedRect(x, y, width, height, color, borderColor, borderWidth, cornerRadius)
- -- Just draw a regular rectangle to avoid corner circle artifacts
- ui.drawRectFilled(vec2(x, y), vec2(x + width, y + height), color)
- -- Draw border if specified
- if borderWidth and borderWidth > 0 and borderColor then
- ui.drawRect(vec2(x, y), vec2(x + width, y + height), borderColor, 0, borderWidth)
- end
- end
- -- Function to draw logo image using URL
- function drawLogo(x, y, width, height)
- -- Use the new logo URL
- local logoURL = "https://i.ibb.co/SX2Nb2fm/Nieuw-project-39.png"
- -- Try to draw image using drawImageQuad for better compatibility
- local success = pcall(function()
- ui.drawImageQuad(
- logoURL,
- vec2(x, y), -- top-left
- vec2(x + width, y), -- top-right
- vec2(x + width, y + height), -- bottom-right
- vec2(x, y + height), -- bottom-left
- rgbm(1, 1, 1, 1) -- white tint (preserves transparency)
- )
- end)
- -- Fallback if URL loading fails
- if not success then
- ui.pushFont(ui.Font.Title)
- local fallbackText = "SNEAKY'S PARADISE"
- local textSize = ui.measureText(fallbackText)
- local textX = x + (width - textSize.x) / 2
- local textY = y + (height - textSize.y) / 2
- -- Draw with glow effect
- for i = 1, 2 do
- local glowAlpha = (3 - i) * 0.3
- local glowColor = rgbm(0.2, 0.5, 1.0, glowAlpha)
- for xOffset = -i, i do
- for yOffset = -i, i do
- if not(xOffset == 0 and yOffset == 0) then
- ui.setCursor(vec2(textX + xOffset, textY + yOffset))
- ui.textColored(fallbackText, glowColor)
- end
- end
- end
- end
- ui.setCursor(vec2(textX, textY))
- ui.textColored(fallbackText, rgbm(0.2, 0.5, 1.0, 1))
- -- "RACE CLUB" below
- ui.pushFont(ui.Font.Main)
- local subText = "RACE CLUB"
- local subSize = ui.measureText(subText)
- ui.setCursor(vec2(x + (width - subSize.x) / 2, textY + textSize.y + 5))
- ui.textColored(subText, rgbm(1, 1, 1, 1))
- ui.popFont()
- ui.popFont()
- end
- end
- -- Function to draw bullet point
- function drawBulletPoint(x, y, icon, text, iconColor)
- ui.pushFont(ui.Font.Main)
- -- Draw icon
- ui.setCursor(vec2(x, y))
- ui.textColored(icon, iconColor or rgbm(1, 1, 1, 1))
- -- Draw text
- ui.setCursor(vec2(x + 20, y))
- ui.textColored(text, rgbm(1, 1, 1, 1))
- ui.popFont()
- return ui.measureText(text).y + 5
- end
- -- Main script update function
- function script.update(dt)
- if showWelcomePopup then
- popupTimer = popupTimer + dt
- fadeAnimation = math.min(1.0, popupTimer * 2) -- Fade in over 0.5 seconds
- end
- end
- -- Main drawing function
- function script.drawUI()
- local uiState = ac.getUiState()
- if not showWelcomePopup then
- return
- end
- local screenWidth = ui.windowSize().x
- local screenHeight = ui.windowSize().y
- -- Calculate popup dimensions
- local popupWidth = 500 * uiScale -- Keep width the same
- local popupHeight = 530 * uiScale -- Increased from 510 to 530 to accommodate larger logo
- local popupX = (screenWidth - popupWidth) / 2
- local popupY = (screenHeight - popupHeight) / 2
- -- Apply fade animation
- local alpha = fadeAnimation
- -- No dark background overlay - removed for clean view
- -- Begin popup window
- ui.beginTransparentWindow("MidnightClubWelcome", vec2(popupX, popupY), vec2(popupWidth, popupHeight))
- -- Draw popup background with clean edges (no rounded corners)
- drawRoundedRect(0, 0, popupWidth, popupHeight,
- rgbm(0.1, 0.1, 0.1, 0.5 * alpha), -- Half transparency
- rgbm(0.3, 0.3, 0.3, alpha), 2) -- Clean border
- local currentY = 15 -- Start a bit higher
- -- Draw logo at the top center - increased size
- local logoWidth = 280 * uiScale -- Increased from 200 to 280 for bigger visibility
- local logoHeight = 112 * uiScale -- Increased from 80 to 112 to maintain aspect ratio
- local logoX = (popupWidth - logoWidth) / 2
- drawLogo(logoX, currentY, logoWidth, logoHeight)
- currentY = currentY + logoHeight + 15
- -- Welcome message - centered
- ui.pushFont(ui.Font.Main)
- local welcomeText = "🏎️ Welcome to The Sneaky's Paradise Server"
- local welcomeSize = ui.measureText(welcomeText)
- ui.setCursor(vec2((popupWidth - welcomeSize.x) / 2, currentY))
- ui.textColored(welcomeText, rgbm(1, 1, 1, alpha))
- currentY = currentY + 30
- -- Warning message - split into two lines to fit properly
- ui.pushFont(ui.Font.Small)
- local warningText1 = "⚠️ Sneaky's Racing Club runs smooth, immersive, and unique."
- local warningText2 = "Please follow these few rules."
- local warningSize1 = ui.measureText(warningText1)
- ui.setCursor(vec2((popupWidth - warningSize1.x) / 2, currentY))
- ui.textColored(warningText1, rgbm(1.0, 0.8, 0.2, alpha))
- currentY = currentY + 20
- local warningSize2 = ui.measureText(warningText2)
- ui.setCursor(vec2((popupWidth - warningSize2.x) / 2, currentY))
- ui.textColored(warningText2, rgbm(1.0, 0.8, 0.2, alpha))
- currentY = currentY + 25
- ui.popFont()
- ui.popFont()
- -- RULES section
- ui.pushFont(ui.Font.Title)
- ui.setCursor(vec2(20, currentY))
- ui.textColored("RULES", rgbm(1, 1, 1, alpha))
- currentY = currentY + 30
- ui.popFont()
- -- Rules list
- currentY = currentY + drawBulletPoint(30, currentY, "💡", "Lights on at night.",
- rgbm(1.0, 0.8, 0.2, alpha))
- currentY = currentY + drawBulletPoint(30, currentY, "🏁", "Drive clean.",
- rgbm(1, 1, 1, alpha))
- currentY = currentY + drawBulletPoint(30, currentY, "🚫", "Don't block roads.",
- rgbm(1, 1, 1, alpha))
- currentY = currentY + drawBulletPoint(30, currentY, "🗳️", "Use Discord to vote.",
- rgbm(0.2, 0.5, 1.0, alpha))
- currentY = currentY + drawBulletPoint(30, currentY, "🔇", "No spam or drama.",
- rgbm(1, 1, 1, alpha))
- currentY = currentY + 15 -- Better spacing before requirements
- -- REQUIRED section
- ui.pushFont(ui.Font.Title)
- ui.setCursor(vec2(20, currentY))
- ui.textColored("REQUIRED", rgbm(1, 1, 1, alpha))
- currentY = currentY + 25
- ui.popFont()
- -- Requirements list
- currentY = currentY + drawBulletPoint(30, currentY, "✅", "Content Manager (latest)",
- rgbm(0.2, 0.8, 0.2, alpha))
- currentY = currentY + drawBulletPoint(30, currentY, "✅", "CSP 0.1.79+ / Sol or Pure",
- rgbm(0.2, 0.8, 0.2, alpha))
- currentY = currentY + drawBulletPoint(30, currentY, "✅", "Full car pack",
- rgbm(0.2, 0.8, 0.2, alpha))
- currentY = currentY + 25 -- Space before instruction text
- -- Instruction text - updated
- ui.pushFont(ui.Font.Main)
- local instructionText = "🎮 Blip throttle or click to close."
- local instructionSize = ui.measureText(instructionText)
- ui.setCursor(vec2((popupWidth - instructionSize.x) / 2, currentY)) -- Center the instruction text
- ui.textColored(instructionText, rgbm(0.7, 0.7, 0.7, alpha))
- currentY = currentY + 30 -- Space before button
- ui.popFont()
- -- Let's Go button - back to original size
- local buttonWidth = 200 -- Back to original 200px width
- local buttonHeight = 35 -- Back to original 35px height
- local buttonX = (popupWidth - buttonWidth) / 2
- local buttonY = currentY
- -- Ensure button fits within popup (add bottom padding check)
- if buttonY + buttonHeight > popupHeight - 15 then
- buttonY = popupHeight - buttonHeight - 15 -- 15px bottom padding
- end
- -- Check if mouse is over button
- local mousePos = ui.mousePos()
- local relativeMousePos = vec2(mousePos.x - popupX, mousePos.y - popupY)
- buttonHovered = relativeMousePos.x >= buttonX and relativeMousePos.x <= buttonX + buttonWidth and
- relativeMousePos.y >= buttonY and relativeMousePos.y <= buttonY + buttonHeight
- -- Draw button with clean edges
- drawRoundedRect(buttonX, buttonY, buttonWidth, buttonHeight,
- rgbm(1.0, buttonHovered and 0.5 or 0.4, buttonHovered and 0.2 or 0.1, alpha))
- -- Button text
- ui.pushFont(ui.Font.Title)
- local buttonText = "🏁 Let's Go"
- local buttonTextSize = ui.measureText(buttonText)
- ui.setCursor(vec2(buttonX + (buttonWidth - buttonTextSize.x) / 2, buttonY + (buttonHeight - buttonTextSize.y) / 2))
- ui.textColored(buttonText, rgbm(1, 1, 1, alpha))
- ui.popFont()
- -- Handle button click OR throttle blip to close popup
- if buttonHovered and ui.mouseClicked(0) then
- showWelcomePopup = false
- end
- ui.endTransparentWindow()
- -- Check for throttle blip to close
- local player = ac.getCarState(1)
- if player and player.gas > 0.8 then
- showWelcomePopup = false
- end
- end
- -- Initialize the popup when script starts
- function script.prepare(dt)
- showWelcomePopup = true
- popupTimer = 0
- fadeAnimation = 0
- return true
- end
- -- Optional: Reset popup for new connections
- function script.onClientConnected(connectedCarIndex, connectedSessionID)
- -- You can reset the popup for new players if needed
- -- showWelcomePopup = true
- -- popupTimer = 0
- -- fadeAnimation = 0
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement