diff --git a/src/community/docsGamesBuildersLua.js b/src/community/docsGamesBuildersLua.js index 7c94e26..0b76eef 100644 --- a/src/community/docsGamesBuildersLua.js +++ b/src/community/docsGamesBuildersLua.js @@ -4484,7 +4484,67 @@ end)`, }, // ═══════════════════════════════════════════════════════════════ - // ИГРЫ 49-50: явных Lua-версий пока нет. + // ИГРА 49 — «Мультиплеер: Гонка» + // ═══════════════════════════════════════════════════════════════ + 'mp-race': { + g49_main: `-- === ИГРА «МУЛЬТИПЛЕЕР: ГОНКА» — главный скрипт (Lua) === +-- Мультиплеерная гонка. Чтобы соревноваться с друзьями — опубликуй +-- игру с галочкой «Мультиплеер». +${SNIPPET_BROADCAST} + +local Players = game:GetService("Players") +local winnerName = nil +local won = false + +__rbxl_show_text("Гонка! Беги к финишу первым", 3) + +local winSound = Instance.new("Sound", workspace) +winSound.SoundId = "win"; winSound.Volume = 1 + +local function refresh() + local n = #Players:GetPlayers() + local txt = "Игроков: " .. n + if winnerName then txt = txt .. " | Победил: " .. winnerName end + __rbxl_hud_set("info", txt, 50, 8, "#ffe066", 22) +end +refresh() + +Players.PlayerAdded:Connect(refresh) +Players.PlayerRemoving:Connect(refresh) + +-- Финиш +local finEvent = getEvent("FinishReached") +finEvent.Event:Connect(function() + if won then return end + won = true + -- В одиночке — мы и есть первый + local me = Players.LocalPlayer + winnerName = me and me.Name or "Игрок" + refresh() + __rbxl_show_text("Ты пришёл первым! Победа!", 5) + winSound:Play() + local px = __rbxl_player_x() + local py = __rbxl_player_y() + local pz = __rbxl_player_z() + __rbxl_spawn_particles("confetti", px, py + 3, pz, 3, 3) +end)`, + g49_finish: `-- === Скрипт финиша (Lua) === +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local part = script.Parent +local fired = false + +part.Touched:Connect(function(hit) + if fired then return end + local h = hit.Parent and hit.Parent:FindFirstChild("Humanoid") + if not h then return end + fired = true + local ev = ReplicatedStorage:FindFirstChild("FinishReached") + if ev then ev:Fire() end +end)`, + }, + + // ═══════════════════════════════════════════════════════════════ + // ИГРА 50: явных Lua-версий пока нет. // buildGameProject в docsGamesBuilders.js использует generateFallbackLua. 'clicker': { g46_main: `-- === ИГРА «КЛИКЕР» — главный скрипт (Lua) === diff --git a/src/community/docsLessons.jsx b/src/community/docsLessons.jsx index 45fc99c..36c6bc7 100644 --- a/src/community/docsLessons.jsx +++ b/src/community/docsLessons.jsx @@ -6969,7 +6969,7 @@ game.self.onTouch(() => {
{`// === ИГРА «МУЛЬТИПЛЕЕР: САЛКИ» — главный скрипт ===
+ {`// === ИГРА «МУЛЬТИПЛЕЕР: САЛКИ» — главный скрипт ===
//
// Это МУЛЬТИПЛЕЕРНАЯ игра. Чтобы играть с друзьями, опубликуй её
// с галочкой «Мультиплеер» — тогда в комнату смогут зайти несколько
@@ -7006,7 +7006,7 @@ game.room.onChange('tagger', (taggerId) => {
} else {
game.ui.showText('Убегай от водящего!', 3);
}
-});`}
+});`}
Разберём:
game.players.count() — сколько игроков