Advertisement
JxnaHub

Untitled

Jul 17th, 2025
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.04 KB | None | 0 0
  1. -- The Unknown Racing Club Welcome Popup for Assetto Corsa
  2. -- Place this in your server's LUA script folder
  3. --
  4. -- Logo loads directly from: https://i.ibb.co/DfZ87CPq/logo.png
  5.  
  6. local showWelcomePopup = true
  7. local popupTimer = 0
  8. local fadeAnimation = 0
  9. local buttonHovered = false
  10.  
  11. -- UI scaling factor
  12. local uiScale = 1.0
  13.  
  14. -- Function to draw clean rectangle (no rounded corners to avoid circle artifacts)
  15. function drawRoundedRect(x, y, width, height, color, borderColor, borderWidth, cornerRadius)
  16.     -- Just draw a regular rectangle to avoid corner circle artifacts
  17.     ui.drawRectFilled(vec2(x, y), vec2(x + width, y + height), color)
  18.    
  19.     -- Draw border if specified
  20.     if borderWidth and borderWidth > 0 and borderColor then
  21.         ui.drawRect(vec2(x, y), vec2(x + width, y + height), borderColor, 0, borderWidth)
  22.     end
  23. end
  24.  
  25. -- Function to draw logo image using URL
  26. function drawLogo(x, y, width, height)
  27.     -- Use the new logo URL
  28.     local logoURL = "https://i.ibb.co/SX2Nb2fm/Nieuw-project-39.png"
  29.    
  30.     -- Try to draw image using drawImageQuad for better compatibility
  31.     local success = pcall(function()
  32.         ui.drawImageQuad(
  33.             logoURL,
  34.             vec2(x, y),              -- top-left
  35.             vec2(x + width, y),      -- top-right  
  36.             vec2(x + width, y + height), -- bottom-right
  37.             vec2(x, y + height),     -- bottom-left
  38.             rgbm(1, 1, 1, 1)        -- white tint (preserves transparency)
  39.         )
  40.     end)
  41.    
  42.     -- Fallback if URL loading fails
  43.     if not success then
  44.         ui.pushFont(ui.Font.Title)
  45.         local fallbackText = "SNEAKY'S PARADISE"
  46.         local textSize = ui.measureText(fallbackText)
  47.         local textX = x + (width - textSize.x) / 2
  48.         local textY = y + (height - textSize.y) / 2
  49.        
  50.         -- Draw with glow effect
  51.         for i = 1, 2 do
  52.             local glowAlpha = (3 - i) * 0.3
  53.             local glowColor = rgbm(0.2, 0.5, 1.0, glowAlpha)
  54.             for xOffset = -i, i do
  55.                 for yOffset = -i, i do
  56.                     if not(xOffset == 0 and yOffset == 0) then
  57.                         ui.setCursor(vec2(textX + xOffset, textY + yOffset))
  58.                         ui.textColored(fallbackText, glowColor)
  59.                     end
  60.                 end
  61.             end
  62.         end
  63.        
  64.         ui.setCursor(vec2(textX, textY))
  65.         ui.textColored(fallbackText, rgbm(0.2, 0.5, 1.0, 1))
  66.        
  67.         -- "RACE CLUB" below
  68.         ui.pushFont(ui.Font.Main)
  69.         local subText = "RACE CLUB"
  70.         local subSize = ui.measureText(subText)
  71.         ui.setCursor(vec2(x + (width - subSize.x) / 2, textY + textSize.y + 5))
  72.         ui.textColored(subText, rgbm(1, 1, 1, 1))
  73.         ui.popFont()
  74.         ui.popFont()
  75.     end
  76. end
  77.  
  78. -- Function to draw bullet point
  79. function drawBulletPoint(x, y, icon, text, iconColor)
  80.     ui.pushFont(ui.Font.Main)
  81.    
  82.     -- Draw icon
  83.     ui.setCursor(vec2(x, y))
  84.     ui.textColored(icon, iconColor or rgbm(1, 1, 1, 1))
  85.    
  86.     -- Draw text
  87.     ui.setCursor(vec2(x + 20, y))
  88.     ui.textColored(text, rgbm(1, 1, 1, 1))
  89.    
  90.     ui.popFont()
  91.    
  92.     return ui.measureText(text).y + 5
  93. end
  94.  
  95. -- Main script update function
  96. function script.update(dt)
  97.     if showWelcomePopup then
  98.         popupTimer = popupTimer + dt
  99.         fadeAnimation = math.min(1.0, popupTimer * 2) -- Fade in over 0.5 seconds
  100.     end
  101. end
  102.  
  103. -- Main drawing function
  104. function script.drawUI()
  105.     local uiState = ac.getUiState()
  106.    
  107.     if not showWelcomePopup then
  108.         return
  109.     end
  110.    
  111.     local screenWidth = ui.windowSize().x
  112.     local screenHeight = ui.windowSize().y
  113.    
  114.     -- Calculate popup dimensions
  115.     local popupWidth = 500 * uiScale  -- Keep width the same
  116.     local popupHeight = 530 * uiScale  -- Increased from 510 to 530 to accommodate larger logo
  117.     local popupX = (screenWidth - popupWidth) / 2
  118.     local popupY = (screenHeight - popupHeight) / 2
  119.    
  120.     -- Apply fade animation
  121.     local alpha = fadeAnimation
  122.    
  123.     -- No dark background overlay - removed for clean view
  124.    
  125.     -- Begin popup window
  126.     ui.beginTransparentWindow("MidnightClubWelcome", vec2(popupX, popupY), vec2(popupWidth, popupHeight))
  127.    
  128.     -- Draw popup background with clean edges (no rounded corners)
  129.     drawRoundedRect(0, 0, popupWidth, popupHeight,
  130.         rgbm(0.1, 0.1, 0.1, 0.5 * alpha),  -- Half transparency
  131.         rgbm(0.3, 0.3, 0.3, alpha), 2)     -- Clean border
  132.    
  133.     local currentY = 15  -- Start a bit higher
  134.    
  135.     -- Draw logo at the top center - increased size
  136.     local logoWidth = 280 * uiScale   -- Increased from 200 to 280 for bigger visibility
  137.     local logoHeight = 112 * uiScale  -- Increased from 80 to 112 to maintain aspect ratio
  138.     local logoX = (popupWidth - logoWidth) / 2
  139.     drawLogo(logoX, currentY, logoWidth, logoHeight)
  140.     currentY = currentY + logoHeight + 15
  141.    
  142.     -- Welcome message - centered
  143.     ui.pushFont(ui.Font.Main)
  144.     local welcomeText = "🏎️ Welcome to The Sneaky's Paradise Server"
  145.     local welcomeSize = ui.measureText(welcomeText)
  146.     ui.setCursor(vec2((popupWidth - welcomeSize.x) / 2, currentY))
  147.     ui.textColored(welcomeText, rgbm(1, 1, 1, alpha))
  148.     currentY = currentY + 30
  149.    
  150.     -- Warning message - split into two lines to fit properly
  151.     ui.pushFont(ui.Font.Small)
  152.     local warningText1 = "⚠️ Sneaky's Racing Club runs smooth, immersive, and unique."
  153.     local warningText2 = "Please follow these few rules."
  154.    
  155.     local warningSize1 = ui.measureText(warningText1)
  156.     ui.setCursor(vec2((popupWidth - warningSize1.x) / 2, currentY))
  157.     ui.textColored(warningText1, rgbm(1.0, 0.8, 0.2, alpha))
  158.     currentY = currentY + 20
  159.    
  160.     local warningSize2 = ui.measureText(warningText2)
  161.     ui.setCursor(vec2((popupWidth - warningSize2.x) / 2, currentY))
  162.     ui.textColored(warningText2, rgbm(1.0, 0.8, 0.2, alpha))
  163.     currentY = currentY + 25
  164.     ui.popFont()
  165.     ui.popFont()
  166.    
  167.     -- RULES section
  168.     ui.pushFont(ui.Font.Title)
  169.     ui.setCursor(vec2(20, currentY))
  170.     ui.textColored("RULES", rgbm(1, 1, 1, alpha))
  171.     currentY = currentY + 30
  172.     ui.popFont()
  173.    
  174.     -- Rules list
  175.     currentY = currentY + drawBulletPoint(30, currentY, "💡", "Lights on at night.",
  176.         rgbm(1.0, 0.8, 0.2, alpha))
  177.     currentY = currentY + drawBulletPoint(30, currentY, "🏁", "Drive clean.",
  178.         rgbm(1, 1, 1, alpha))
  179.     currentY = currentY + drawBulletPoint(30, currentY, "🚫", "Don't block roads.",
  180.         rgbm(1, 1, 1, alpha))
  181.     currentY = currentY + drawBulletPoint(30, currentY, "🗳️", "Use Discord to vote.",
  182.         rgbm(0.2, 0.5, 1.0, alpha))
  183.     currentY = currentY + drawBulletPoint(30, currentY, "🔇", "No spam or drama.",
  184.         rgbm(1, 1, 1, alpha))
  185.    
  186.     currentY = currentY + 15  -- Better spacing before requirements
  187.    
  188.     -- REQUIRED section
  189.     ui.pushFont(ui.Font.Title)
  190.     ui.setCursor(vec2(20, currentY))
  191.     ui.textColored("REQUIRED", rgbm(1, 1, 1, alpha))
  192.     currentY = currentY + 25
  193.     ui.popFont()
  194.    
  195.     -- Requirements list
  196.     currentY = currentY + drawBulletPoint(30, currentY, "✅", "Content Manager (latest)",
  197.         rgbm(0.2, 0.8, 0.2, alpha))
  198.     currentY = currentY + drawBulletPoint(30, currentY, "✅", "CSP 0.1.79+ / Sol or Pure",
  199.         rgbm(0.2, 0.8, 0.2, alpha))
  200.     currentY = currentY + drawBulletPoint(30, currentY, "✅", "Full car pack",
  201.         rgbm(0.2, 0.8, 0.2, alpha))
  202.    
  203.     currentY = currentY + 25  -- Space before instruction text
  204.    
  205.     -- Instruction text - updated
  206.     ui.pushFont(ui.Font.Main)
  207.     local instructionText = "🎮 Blip throttle or click to close."
  208.     local instructionSize = ui.measureText(instructionText)
  209.     ui.setCursor(vec2((popupWidth - instructionSize.x) / 2, currentY))  -- Center the instruction text
  210.     ui.textColored(instructionText, rgbm(0.7, 0.7, 0.7, alpha))
  211.     currentY = currentY + 30  -- Space before button
  212.     ui.popFont()
  213.    
  214.     -- Let's Go button - back to original size
  215.     local buttonWidth = 200  -- Back to original 200px width
  216.     local buttonHeight = 35  -- Back to original 35px height
  217.     local buttonX = (popupWidth - buttonWidth) / 2
  218.     local buttonY = currentY
  219.    
  220.     -- Ensure button fits within popup (add bottom padding check)
  221.     if buttonY + buttonHeight > popupHeight - 15 then
  222.         buttonY = popupHeight - buttonHeight - 15  -- 15px bottom padding
  223.     end
  224.    
  225.     -- Check if mouse is over button
  226.     local mousePos = ui.mousePos()
  227.     local relativeMousePos = vec2(mousePos.x - popupX, mousePos.y - popupY)
  228.     buttonHovered = relativeMousePos.x >= buttonX and relativeMousePos.x <= buttonX + buttonWidth and
  229.                    relativeMousePos.y >= buttonY and relativeMousePos.y <= buttonY + buttonHeight
  230.    
  231.     -- Draw button with clean edges
  232.     drawRoundedRect(buttonX, buttonY, buttonWidth, buttonHeight,
  233.         rgbm(1.0, buttonHovered and 0.5 or 0.4, buttonHovered and 0.2 or 0.1, alpha))
  234.    
  235.     -- Button text
  236.     ui.pushFont(ui.Font.Title)
  237.     local buttonText = "🏁 Let's Go"
  238.     local buttonTextSize = ui.measureText(buttonText)
  239.     ui.setCursor(vec2(buttonX + (buttonWidth - buttonTextSize.x) / 2, buttonY + (buttonHeight - buttonTextSize.y) / 2))
  240.     ui.textColored(buttonText, rgbm(1, 1, 1, alpha))
  241.     ui.popFont()
  242.    
  243.     -- Handle button click OR throttle blip to close popup
  244.     if buttonHovered and ui.mouseClicked(0) then
  245.         showWelcomePopup = false
  246.     end
  247.    
  248.     ui.endTransparentWindow()
  249.    
  250.     -- Check for throttle blip to close
  251.     local player = ac.getCarState(1)
  252.     if player and player.gas > 0.8 then
  253.         showWelcomePopup = false
  254.     end
  255. end
  256.  
  257. -- Initialize the popup when script starts
  258. function script.prepare(dt)
  259.     showWelcomePopup = true
  260.     popupTimer = 0
  261.     fadeAnimation = 0
  262.     return true
  263. end
  264.  
  265. -- Optional: Reset popup for new connections
  266. function script.onClientConnected(connectedCarIndex, connectedSessionID)
  267.     -- You can reset the popup for new players if needed
  268.     -- showWelcomePopup = true
  269.     -- popupTimer = 0
  270.     -- fadeAnimation = 0
  271. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement