Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 31 additions & 33 deletions content/en-us/matchmaking/attributes-and-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ local DataStoreService = game:GetService("DataStoreService")
local eloStore = DataStoreService:GetDataStore("PlayerElo")

function onMatchEnded(players: {Player}, winners: {Player}, losers: {Player})
for _, player in players do
local updatedElo = CalculateUpdatedElo(player, winners, losers)
local success, errorMessage = pcall(function()
eloStore:SetAsync(player.UserId, updatedElo)
end)
end
for _, player in players do
local updatedElo = CalculateUpdatedElo(player, winners, losers)
local success, errorMessage = pcall(function()
eloStore:SetAsync(player.UserId, updatedElo)
end)
end
end
```

Expand All @@ -225,30 +225,28 @@ local MatchmakingService = game:GetService("MatchmakingService")
local RunService = game:GetService("RunService")

if RunService:IsStudio() then
-- Sets up initial attributes and schema for testing
MatchmakingService:InitializeServerAttributesForStudio(
{
Level = "Advanced",
Elo = 123.456,
TrainingMode = true
})
-- Sets up initial attributes and schema for testing
MatchmakingService:InitializeServerAttributesForStudio({
Level = "Advanced",
Elo = 123.456,
TrainingMode = true
})
end

-- Retrieves the Level attribute
local currentLevel, error = MatchmakingService:GetServerAttribute("Level")

if error then
print(error)
local currentLevel, errorMessage = MatchmakingService:GetServerAttribute("Level")
if errorMessage then
warn(errorMessage)
else
print("Current level: " .. currentLevel)
print("Current level: " .. currentLevel)
end

-- Updates the Level attribute value to Advanced
local success, error = MatchmakingService:SetServerAttribute("Level", "Advanced")
local success, errorMessage = MatchmakingService:SetServerAttribute("Level", "Advanced")
if not success then
print("Failed to update server attribute [Level] to [Advanced] due to error: " .. error)
warn("Failed to update server attribute [Level] to [Advanced] due to error: " .. errorMessage)
else
print("Successfully set [Level] to [Advanced]")
print("Successfully set [Level] to [Advanced]")
end
```

Expand Down Expand Up @@ -386,21 +384,21 @@ local score = math.min(diff / max_relevant_difference, 1)
The score is 1 when the server's attribute value (for example, Game Mode) is equal to the player's attribute value (for example, Preferred Game Mode). Otherwise, the signal score is 0.

```lua title="Joining player formula for server categorical signal"
if server_{attribute_name} = joining_player_{attribute_name} then
return 1
if server_{attribute_name} == joining_player_{attribute_name} then
return 1
else
return 0
return 0
end
```

```lua title="Joining player example for server categorical signal"
local server_GameMode = "Survival"
local joining_player_GameMode = "Survival"

if server_GameMode = joining_player_GameMode then
return 1
if server_GameMode == joining_player_GameMode then
return 1
else
return 0
return 0
end
```

Expand All @@ -409,19 +407,19 @@ end
The score is 1 when the server's attribute value is equal to a constant value of true. Otherwise, the signal score is 0.

```lua title="Constant value formula for server categorical signal"
if server_{attribute_name} = constant_value then
return 1
if server_{attribute_name} == constant_value then
return 1
else
return 0
return 0
end
```

```lua title="Constant value example for server categorical signal"
local server_GameNotStarted = true

if server_GameNotStarted = true then
return 1
if server_GameNotStarted == true then
return 1
else
return 0
return 0
end
```