feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39
@ -1043,36 +1043,172 @@ end)`;
|
|||||||
// ИГРА 13 — «Торговец»
|
// ИГРА 13 — «Торговец»
|
||||||
// ═══════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════
|
||||||
'trader': {
|
'trader': {
|
||||||
g13_main: `-- === ИГРА «ТОРГОВЕЦ» (Lua) ===
|
g13_main: `-- === ИГРА «ТОРГОВЕЦ» — главный скрипт (Lua) ===
|
||||||
local Players = game:GetService("Players")
|
${SNIPPET_BROADCAST}
|
||||||
|
|
||||||
Players.PlayerAdded:Connect(function(player)
|
|
||||||
local stats = Instance.new("Folder", player); stats.Name = "leaderstats"
|
|
||||||
local coins = Instance.new("IntValue", stats); coins.Name = "Монеты"; coins.Value = 10
|
|
||||||
end)
|
|
||||||
for _, p in ipairs(Players:GetPlayers()) do
|
|
||||||
if not p:FindFirstChild("leaderstats") then
|
|
||||||
local stats = Instance.new("Folder", p); stats.Name = "leaderstats"
|
|
||||||
local coins = Instance.new("IntValue", stats); coins.Name = "Монеты"; coins.Value = 10
|
|
||||||
end
|
|
||||||
end
|
|
||||||
print("У тебя 10 монет. Купи зелье у торговца!")`,
|
|
||||||
g13_npc: `-- === Скрипт торговца (Lua) ===
|
|
||||||
local Players = game:GetService("Players")
|
local Players = game:GetService("Players")
|
||||||
local part = script.Parent
|
local TweenService = game:GetService("TweenService")
|
||||||
part.Touched:Connect(function(hit)
|
local player = Players.LocalPlayer
|
||||||
local player = Players:GetPlayerFromCharacter(hit.Parent)
|
local hasKey = false
|
||||||
if not player then return end
|
local won = false
|
||||||
local stats = player:FindFirstChild("leaderstats")
|
|
||||||
if not stats then return end
|
__rbxl_show_text("Поговори с торговцем — нажми E у прилавка", 4)
|
||||||
if stats['Монеты'].Value >= 5 then
|
|
||||||
stats['Монеты'].Value = stats['Монеты'].Value - 5
|
local pickupSound = Instance.new("Sound", workspace)
|
||||||
local h = hit.Parent:FindFirstChild("Humanoid")
|
pickupSound.SoundId = "pickup"; pickupSound.Volume = 0.8
|
||||||
if h then h.Health = math.min(h.MaxHealth, h.Health + 50) end
|
local winSound = Instance.new("Sound", workspace)
|
||||||
print("Купил зелье! +50 HP. Осталось монет: " .. stats['Монеты'].Value)
|
winSound.SoundId = "win"; winSound.Volume = 1
|
||||||
else
|
|
||||||
print("Не хватает монет! Нужно 5")
|
-- Простой "инвентарь" в HUD: ключ
|
||||||
|
local screenGui = Instance.new("ScreenGui", player.PlayerGui)
|
||||||
|
local invLabel = Instance.new("TextLabel", screenGui)
|
||||||
|
invLabel.Size = UDim2.new(0, 220, 0, 40)
|
||||||
|
invLabel.Position = UDim2.new(1, -240, 0, 20)
|
||||||
|
invLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
|
||||||
|
invLabel.BackgroundTransparency = 0.4
|
||||||
|
invLabel.TextColor3 = Color3.fromRGB(255, 215, 0)
|
||||||
|
invLabel.TextScaled = true
|
||||||
|
invLabel.Font = Enum.Font.SourceSansBold
|
||||||
|
invLabel.Text = "Ключа нет"
|
||||||
|
|
||||||
|
-- Игрок заговорил с торговцем
|
||||||
|
local talkEvent = getEvent("TalkTrader")
|
||||||
|
talkEvent.Event:Connect(function()
|
||||||
|
if hasKey then
|
||||||
|
__rbxl_show_text("Торговец: Иди к двери, ключ у тебя!", 3)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
hasKey = true
|
||||||
|
invLabel.Text = "У тебя есть Ключ"
|
||||||
|
invLabel.TextColor3 = Color3.fromRGB(100, 255, 100)
|
||||||
|
__rbxl_show_text("Торговец: Привет! Вот тебе ключ от двери. Удачи!", 4)
|
||||||
|
pickupSound:Play()
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Игрок пытается открыть дверь
|
||||||
|
local openEvent = getEvent("OpenDoor")
|
||||||
|
openEvent.Event:Connect(function()
|
||||||
|
if not hasKey then
|
||||||
|
__rbxl_show_text("Дверь заперта. Нужен ключ от торговца.", 2)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
__rbxl_show_text("Ключ подошёл! Дверь открыта.", 3)
|
||||||
|
winSound:Play()
|
||||||
|
local door = workspace:FindFirstChild("Дверь")
|
||||||
|
if door then
|
||||||
|
local dp = door.Position
|
||||||
|
local goal = { Position = Vector3.new(dp.X, dp.Y + 6, dp.Z) }
|
||||||
|
TweenService:Create(door, TweenInfo.new(1.2), goal):Play()
|
||||||
|
door.CanCollide = false
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Игрок встал на финиш
|
||||||
|
local winEvent = getEvent("WinReached")
|
||||||
|
winEvent.Event:Connect(function()
|
||||||
|
if won then return end
|
||||||
|
won = true
|
||||||
|
__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)`,
|
||||||
|
g13_counter: `-- === Скрипт прилавка (Lua) ===
|
||||||
|
-- Подойди и нажми E чтобы поговорить с торговцем.
|
||||||
|
local UserInputService = game:GetService("UserInputService")
|
||||||
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local RunService = game:GetService("RunService")
|
||||||
|
local part = script.Parent
|
||||||
|
local hintVisible = false
|
||||||
|
|
||||||
|
local hintGui = Instance.new("BillboardGui", part)
|
||||||
|
hintGui.Size = UDim2.new(5, 0, 1, 0)
|
||||||
|
hintGui.StudsOffset = Vector3.new(0, 2.5, 0)
|
||||||
|
hintGui.AlwaysOnTop = true
|
||||||
|
local label = Instance.new("TextLabel", hintGui)
|
||||||
|
label.Size = UDim2.new(1, 0, 1, 0)
|
||||||
|
label.BackgroundTransparency = 1
|
||||||
|
label.TextColor3 = Color3.fromRGB(255, 255, 255)
|
||||||
|
label.TextStrokeTransparency = 0
|
||||||
|
label.TextScaled = true
|
||||||
|
label.Text = "[E] Поговорить с торговцем"
|
||||||
|
label.Visible = false
|
||||||
|
|
||||||
|
RunService.Heartbeat:Connect(function()
|
||||||
|
local px = __rbxl_player_x()
|
||||||
|
local pz = __rbxl_player_z()
|
||||||
|
local dx = part.Position.X - px
|
||||||
|
local dz = part.Position.Z - pz
|
||||||
|
local dist = math.sqrt(dx*dx + dz*dz)
|
||||||
|
local near = dist <= 4
|
||||||
|
if near ~= hintVisible then
|
||||||
|
hintVisible = near
|
||||||
|
label.Visible = near
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
UserInputService.InputBegan:Connect(function(input, gp)
|
||||||
|
if gp then return end
|
||||||
|
if not hintVisible then return end
|
||||||
|
if input.KeyCode ~= Enum.KeyCode.E then return end
|
||||||
|
local ev = ReplicatedStorage:FindFirstChild("TalkTrader")
|
||||||
|
if ev then ev:Fire() end
|
||||||
|
end)`,
|
||||||
|
g13_door: `-- === Скрипт двери (Lua) ===
|
||||||
|
-- Подойди и нажми E чтобы открыть дверь (нужен ключ).
|
||||||
|
local UserInputService = game:GetService("UserInputService")
|
||||||
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local RunService = game:GetService("RunService")
|
||||||
|
local part = script.Parent
|
||||||
|
local hintVisible = false
|
||||||
|
|
||||||
|
local hintGui = Instance.new("BillboardGui", part)
|
||||||
|
hintGui.Size = UDim2.new(4, 0, 1, 0)
|
||||||
|
hintGui.StudsOffset = Vector3.new(0, 3.5, 0)
|
||||||
|
hintGui.AlwaysOnTop = true
|
||||||
|
local label = Instance.new("TextLabel", hintGui)
|
||||||
|
label.Size = UDim2.new(1, 0, 1, 0)
|
||||||
|
label.BackgroundTransparency = 1
|
||||||
|
label.TextColor3 = Color3.fromRGB(255, 255, 255)
|
||||||
|
label.TextStrokeTransparency = 0
|
||||||
|
label.TextScaled = true
|
||||||
|
label.Text = "[E] Открыть дверь"
|
||||||
|
label.Visible = false
|
||||||
|
|
||||||
|
RunService.Heartbeat:Connect(function()
|
||||||
|
local px = __rbxl_player_x()
|
||||||
|
local pz = __rbxl_player_z()
|
||||||
|
local dx = part.Position.X - px
|
||||||
|
local dz = part.Position.Z - pz
|
||||||
|
local dist = math.sqrt(dx*dx + dz*dz)
|
||||||
|
local near = dist <= 4
|
||||||
|
if near ~= hintVisible then
|
||||||
|
hintVisible = near
|
||||||
|
label.Visible = near
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
UserInputService.InputBegan:Connect(function(input, gp)
|
||||||
|
if gp then return end
|
||||||
|
if not hintVisible then return end
|
||||||
|
if input.KeyCode ~= Enum.KeyCode.E then return end
|
||||||
|
local ev = ReplicatedStorage:FindFirstChild("OpenDoor")
|
||||||
|
if ev then ev:Fire() end
|
||||||
|
end)`,
|
||||||
|
g13_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("WinReached")
|
||||||
|
if ev then ev:Fire() end
|
||||||
end)`,
|
end)`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user