|
1 | | ---- |
2 | | -title: Data store observability |
3 | | -description: Explains how to use the observability dashboard for data stores. |
4 | | ---- |
| 1 | +-- X LAVT — Полная система: деньги, работа, имущество, банкротство, телефон, транспорт |
5 | 2 |
|
6 | | -The data stores observability dashboard provides real-time charts on your request counts and on your usage against future data store limits, and allows you to filter the request data by standard or ordered data stores. |
| 3 | +local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") |
7 | 4 |
|
8 | | - |
| 5 | +-- RemoteEvents local gainXPEvent = Instance.new("RemoteEvent", ReplicatedStorage) gainXPEvent.Name = "GainXP" |
9 | 6 |
|
10 | | -## Access the dashboard |
| 7 | +local buyItemEvent = Instance.new("RemoteEvent", ReplicatedStorage) buyItemEvent.Name = "BuyItem" |
11 | 8 |
|
12 | | -The data stores dashboard is available for any experience that uses `Class.DataStoreService`, but you must either be the experience owner or have [analytics group permissions](../../production/analytics/analytics-dashboard.md#grant-group-permission) to access the dashboard. |
| 9 | +local sellItemEvent = Instance.new("RemoteEvent", ReplicatedStorage) sellItemEvent.Name = "SellItem" |
13 | 10 |
|
14 | | -1. Navigate to the [Creations](https://create.roblox.com/dashboard/creations) page on the **Creator Hub**. |
15 | | -2. Under the **Creator Hub** dropdown, select your account or the group owning the target experience. |
16 | | -3. Select the experience. |
17 | | -4. In the **Monitoring** dropdown, select **Data Stores**. |
| 11 | +-- Предметы и цены local items = { House = 1000, Car = 1500, Yacht = 5000, Jet = 10000, Phone = 300 } |
18 | 12 |
|
19 | | -## Available charts |
| 13 | +-- Создание статистики Players.PlayerAdded:Connect(function(player) local stats = Instance.new("Folder", player) stats.Name = "leaderstats" |
20 | 14 |
|
21 | | -- **Request Count by API** on API request count per minute by API method, such as `Class.DataStore:SetAsync()` or `Class.OrderedDataStore:GetSortedAsync()`. |
22 | | -- **Request Count by Status** on API request count by [response status](#response-status-codes). |
23 | | -- **Request by API x Status** on response statuses returned by all or a specific API method. |
24 | | -- **Read Request Type Quota Usage** on number of read API method calls against future read category limits. |
25 | | -- **Write Request Type Quota Usage** on number of write API method calls against future write category limits. |
26 | | -- **List Request Type Quota Usage** on number of list API method calls against future list category limits. |
27 | | -- **Remove Request Type Quota Usage** on number of remove API method calls against future remove category limits. |
| 15 | +local cash = Instance.new("IntValue", stats) |
| 16 | +cash.Name = "Cash" |
| 17 | +cash.Value = 0 |
28 | 18 |
|
29 | | -Use the selector at the top of the page to filter by standard or ordered data stores. The default view includes both. |
| 19 | +local level = Instance.new("IntValue", stats) |
| 20 | +level.Name = "Level" |
| 21 | +level.Value = 1 |
30 | 22 |
|
31 | | -Each chart contains data for the past 30 days, and you can select to view a custom time range with the selector at the top of the page. If you select a time range earlier than 30 days, the system returns a **Request Failed** error. |
| 23 | +local xp = Instance.new("IntValue", stats) |
| 24 | +xp.Name = "XP" |
| 25 | +xp.Value = 0 |
32 | 26 |
|
33 | | -Data from the most recent three minutes might be incomplete, so it's normal to see a drop at the end of the charts. |
| 27 | +local inv = Instance.new("Folder", player) |
| 28 | +inv.Name = "Inventory" |
| 29 | +for itemName in pairs(items) do |
| 30 | + local b = Instance.new("BoolValue", inv) |
| 31 | + b.Name = itemName |
| 32 | + b.Value = false |
| 33 | +end |
34 | 34 |
|
35 | | -## Response status codes |
| 35 | +end) |
36 | 36 |
|
37 | | -The dashboard's **Request Count by Status** and **Requests by API x Status** charts include status codes of API responses that you can use to understand usage and troubleshoot errors. For a table that lists and describes all of these status codes (aside from `200 OK`), see [Error codes](error-codes-and-limits.md#error-code-reference). |
| 37 | +-- XP и уровень gainXPEvent.OnServerEvent:Connect(function(player, amount) local stats = player:FindFirstChild("leaderstats") local xp = stats and stats:FindFirstChild("XP") local level = stats and stats:FindFirstChild("Level") if xp and level then xp.Value += amount local req = level.Value * 100 if xp.Value >= req then xp.Value -= req level.Value += 1 end end end) |
| 38 | + |
| 39 | +-- Работающая зона local function setupJobZone(part, money, xp) local prompt = part:FindFirstChildOfClass("ProximityPrompt") or Instance.new("ProximityPrompt", part) prompt.ActionText = "Работать" prompt.ObjectText = part.Name prompt.HoldDuration = 2 |
| 40 | + |
| 41 | +prompt.Triggered:Connect(function(player) |
| 42 | + local stats = player:FindFirstChild("leaderstats") |
| 43 | + local cash = stats and stats:FindFirstChild("Cash") |
| 44 | + local level = stats and stats:FindFirstChild("Level") |
| 45 | + if cash and level then |
| 46 | + local earned = money + (level.Value - 1) * 10 |
| 47 | + cash.Value += earned |
| 48 | + gainXPEvent:FireServer(player, xp) |
| 49 | + |
| 50 | + if cash.Value < 0 then |
| 51 | + local inv = player:FindFirstChild("Inventory") |
| 52 | + if inv then |
| 53 | + for _, item in ipairs(inv:GetChildren()) do |
| 54 | + if item:IsA("BoolValue") then item.Value = false end |
| 55 | + end |
| 56 | + end |
| 57 | + cash.Value = 0 |
| 58 | + end |
| 59 | + end |
| 60 | +end) |
| 61 | + |
| 62 | +end |
| 63 | + |
| 64 | +-- Настройка всех рабочих зон local function initJobs() local jobs = { {name = "FarmZone", money = 50, xp = 20}, {name = "ShopZone", money = 30, xp = 15}, {name = "FactoryZone", money = 70, xp = 25}, } |
| 65 | + |
| 66 | +for _, job in ipairs(jobs) do |
| 67 | + local part = workspace:FindFirstChild(job.name) |
| 68 | + if part then |
| 69 | + setupJobZone(part, job.money, job.xp) |
| 70 | + end |
| 71 | +end |
| 72 | + |
| 73 | +end |
| 74 | + |
| 75 | +-- Выдать транспорт при покупке local function giveVehicle(player, itemName) local modelName = itemName .. "Model" local template = workspace:FindFirstChild(modelName) if template then local clone = template:Clone() clone.Name = player.Name .. "_" .. itemName clone:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame * CFrame.new(10, 0, 0)) |
| 76 | + |
| 77 | +local ownerId = clone:FindFirstChild("OwnerId") |
| 78 | + if ownerId then |
| 79 | + ownerId.Value = player.UserId |
| 80 | + end |
| 81 | + |
| 82 | + clone.Parent = workspace |
| 83 | +end |
| 84 | + |
| 85 | +end |
| 86 | + |
| 87 | +-- Покупка buyItemEvent.OnServerEvent:Connect(function(player, itemName) local price = items[itemName] if not price then return end |
| 88 | + |
| 89 | +local stats = player:FindFirstChild("leaderstats") |
| 90 | +local inv = player:FindFirstChild("Inventory") |
| 91 | +local cash = stats and stats:FindFirstChild("Cash") |
| 92 | +local owned = inv and inv:FindFirstChild(itemName) |
| 93 | + |
| 94 | +if cash and owned and not owned.Value and cash.Value >= price then |
| 95 | + cash.Value -= price |
| 96 | + owned.Value = true |
| 97 | + if itemName == "Car" or itemName == "Yacht" or itemName == "Jet" then |
| 98 | + giveVehicle(player, itemName) |
| 99 | + end |
| 100 | +end |
| 101 | + |
| 102 | +end) |
| 103 | + |
| 104 | +-- Продажа sellItemEvent.OnServerEvent:Connect(function(player, itemName) local price = items[itemName] if not price then return end |
| 105 | + |
| 106 | +local stats = player:FindFirstChild("leaderstats") |
| 107 | +local inv = player:FindFirstChild("Inventory") |
| 108 | +local cash = stats and stats:FindFirstChild("Cash") |
| 109 | +local owned = inv and inv:FindFirstChild(itemName) |
| 110 | + |
| 111 | +if cash and owned and owned.Value then |
| 112 | + owned.Value = false |
| 113 | + cash.Value += math.floor(price * 0.5) |
| 114 | +end |
| 115 | + |
| 116 | +end) |
| 117 | + |
| 118 | +-- Проверка транспорта local function setupSeat(seat) seat:GetPropertyChangedSignal("Occupant"):Connect(function() local humanoid = seat.Occupant if humanoid then local character = humanoid.Parent local player = Players:GetPlayerFromCharacter(character) local model = seat:FindFirstAncestorOfClass("Model") local ownerId = model and model:FindFirstChild("OwnerId") if player and ownerId and ownerId.Value ~= player.UserId then humanoid.Sit = false player:Kick("Ты не владеешь этим транспортом!") end end end) end |
| 119 | + |
| 120 | +-- Настройка транспорта local function setupAllVehicles() for _, model in ipairs(workspace:GetChildren()) do if model:IsA("Model") and model:FindFirstChild("OwnerId") then for _, d in ipairs(model:GetDescendants()) do if d:IsA("VehicleSeat") then setupSeat(d) end end end end end |
| 121 | + |
| 122 | +-- Запуск initJobs() setupAllVehicles() |
38 | 123 |
|
39 | | -## Service limits |
40 | 124 |
|
41 | | -For information on current limits, usage quotas, and future limits, see [Limits](error-codes-and-limits.md#limits). |
|
0 commit comments