File size: 6,085 Bytes
0712d5f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | -- src/StarterGui/MarketGUI.client.lua
-- Live market prices display with trend indicators
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local EconomyConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("EconomyConfig"))
local Utility = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Utility"))
local MarketUpdateEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("MarketUpdateEvent")
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "MarketGUI"
screenGui.ResetOnSpawn = false
screenGui.Parent = player:WaitForChild("PlayerGui")
local mainFrame = Instance.new("Frame")
mainFrame.Name = "MarketFrame"
mainFrame.Size = UDim2.new(0, 300, 0, 380)
mainFrame.Position = UDim2.new(0, 10, 0.5, -190)
mainFrame.BackgroundColor3 = Color3.fromRGB(20, 25, 30)
mainFrame.BackgroundTransparency = 0.1
mainFrame.BorderSizePixel = 0
mainFrame.Visible = false
mainFrame.Parent = screenGui
local frameCorner = Instance.new("UICorner")
frameCorner.CornerRadius = UDim.new(0, 12)
frameCorner.Parent = mainFrame
local frameStroke = Instance.new("UIStroke")
frameStroke.Color = Color3.fromRGB(200, 160, 60)
frameStroke.Thickness = 2
frameStroke.Parent = mainFrame
local titleBar = Instance.new("Frame")
titleBar.Size = UDim2.new(1, 0, 0, 35)
titleBar.BackgroundColor3 = Color3.fromRGB(150, 120, 30)
titleBar.BorderSizePixel = 0
titleBar.Parent = mainFrame
local titleCorner = Instance.new("UICorner")
titleCorner.CornerRadius = UDim.new(0, 12)
titleCorner.Parent = titleBar
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, -50, 1, 0)
titleLabel.Position = UDim2.new(0, 10, 0, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "Market Prices"
titleLabel.TextColor3 = Color3.new(1, 1, 1)
titleLabel.TextScaled = true
titleLabel.Font = Enum.Font.GothamBold
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.Parent = titleBar
local closeBtn = Instance.new("TextButton")
closeBtn.Size = UDim2.new(0, 28, 0, 28)
closeBtn.Position = UDim2.new(1, -32, 0, 3)
closeBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50)
closeBtn.Text = "X"
closeBtn.TextColor3 = Color3.new(1, 1, 1)
closeBtn.TextScaled = true
closeBtn.Font = Enum.Font.GothamBold
closeBtn.Parent = titleBar
local closeCorner = Instance.new("UICorner")
closeCorner.CornerRadius = UDim.new(0, 6)
closeCorner.Parent = closeBtn
closeBtn.MouseButton1Click:Connect(function()
mainFrame.Visible = false
end)
local scrollFrame = Instance.new("ScrollingFrame")
scrollFrame.Size = UDim2.new(1, -16, 1, -45)
scrollFrame.Position = UDim2.new(0, 8, 0, 38)
scrollFrame.BackgroundTransparency = 1
scrollFrame.BorderSizePixel = 0
scrollFrame.ScrollBarThickness = 5
scrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
scrollFrame.Parent = mainFrame
local listLayout = Instance.new("UIListLayout")
listLayout.SortOrder = Enum.SortOrder.LayoutOrder
listLayout.Padding = UDim.new(0, 3)
listLayout.Parent = scrollFrame
-- Previous rates for trend arrows
local previousRates = {}
local function updateMarketDisplay(rates)
-- Clear old entries
for _, child in pairs(scrollFrame:GetChildren()) do
if child:IsA("Frame") then child:Destroy() end
end
local idx = 0
for woodType, rate in pairs(rates) do
idx = idx + 1
local baseValue = EconomyConfig.WoodBaseValues[woodType] or 0
local currentPrice = math.floor(baseValue * rate)
local prevRate = previousRates[woodType] or 1.0
local trend = ""
local trendColor = Color3.new(1, 1, 1)
if rate > prevRate + 0.01 then
trend = " ^"
trendColor = Color3.fromRGB(100, 255, 100)
elseif rate < prevRate - 0.01 then
trend = " v"
trendColor = Color3.fromRGB(255, 100, 100)
else
trend = " ="
trendColor = Color3.fromRGB(200, 200, 200)
end
local row = Instance.new("Frame")
row.Size = UDim2.new(1, 0, 0, 22)
row.LayoutOrder = idx
row.BackgroundColor3 = idx % 2 == 0 and Color3.fromRGB(30, 33, 40) or Color3.fromRGB(25, 28, 35)
row.BorderSizePixel = 0
row.Parent = scrollFrame
local rowCorner = Instance.new("UICorner")
rowCorner.CornerRadius = UDim.new(0, 4)
rowCorner.Parent = row
local nameLabel = Instance.new("TextLabel")
nameLabel.Size = UDim2.new(0.45, 0, 1, 0)
nameLabel.Position = UDim2.new(0, 5, 0, 0)
nameLabel.BackgroundTransparency = 1
nameLabel.Text = woodType
nameLabel.TextColor3 = Color3.new(1, 1, 1)
nameLabel.TextScaled = true
nameLabel.Font = Enum.Font.GothamMedium
nameLabel.TextXAlignment = Enum.TextXAlignment.Left
nameLabel.Parent = row
local priceLabel = Instance.new("TextLabel")
priceLabel.Size = UDim2.new(0.3, 0, 1, 0)
priceLabel.Position = UDim2.new(0.45, 0, 0, 0)
priceLabel.BackgroundTransparency = 1
priceLabel.Text = "$" .. tostring(currentPrice) .. "/vol"
priceLabel.TextColor3 = Color3.fromRGB(255, 215, 0)
priceLabel.TextScaled = true
priceLabel.Font = Enum.Font.GothamMedium
priceLabel.Parent = row
local trendLabel = Instance.new("TextLabel")
trendLabel.Size = UDim2.new(0.2, 0, 1, 0)
trendLabel.Position = UDim2.new(0.78, 0, 0, 0)
trendLabel.BackgroundTransparency = 1
trendLabel.Text = string.format("%.0f%%", rate * 100) .. trend
trendLabel.TextColor3 = trendColor
trendLabel.TextScaled = true
trendLabel.Font = Enum.Font.GothamBold
trendLabel.Parent = row
end
previousRates = rates
task.wait()
scrollFrame.CanvasSize = UDim2.new(0, 0, 0, listLayout.AbsoluteContentSize.Y + 10)
end
-- Listen for market updates
MarketUpdateEvent.OnClientEvent:Connect(function(rates)
updateMarketDisplay(rates)
end)
-- Toggle with M key
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.M then
mainFrame.Visible = not mainFrame.Visible
end
end)
|