ServerStorage
*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.
İçeriği yalnızca sunucuda erişilebilen bir konteyner.ServerStorage'dan aşağıya inen nesneler, istemciye yansımayacak ve LocalScripts 'dan erişilemeyecek.
Sunucu Depolama bir hizmet olduğundan, yalnızca DataModel.GetService yöntemi kullanılarak erişilebilir.
Haritalar gibi büyük nesneleri ServerStorage'a saklayarak, bu nesneler oyuna katıldıklarında istendiğinde ağ trafiği kullanılmayacaktır.
Scripts ServerStorage'a ebeveyn olarak atandıklarında çalışmayacak, ancak ModuleScripts içinde bulunan erişilebilir ve çalıştırılabilir.Geliştiricilerin, sunucunun yürütmesini istedikleri Scripts için ServerScriptService kullanması önerilir.
Sunucu Depolama'nın içeriğinin yalnızca sunucu tarafından erişilebildiği unutmayın, böylece müşteriler onlara erişebilmeden önce içeriğin başka bir yere ebeveyn olması gerekecektir (örneğin Workspace ).Sunucu ve istemci tarafından erişilebilen bir konteynere ihtiyaç duyan geliştiricilerin yerine ReplicatedStorage kullanması önerilir.
Kod Örnekleri
This is a very simple example of how a multiple map system can be made using ServerStorage.
It creates three dummy models (to take the place of maps), that are parented to ServerStorage. Then, it will load a random map (different to the previous map) and wait a specified duration on a loop.
Developers wishing to integrate something similar into their games should consider measures to ensure players respawn correctly, or go to a lobby during intermission periods.
local ServerStorage = game:GetService("ServerStorage")
local ROUND_TIME = 5
local map1 = Instance.new("Model")
map1.Name = "Map1"
map1.Parent = ServerStorage
local map2 = Instance.new("Model")
map2.Name = "Map2"
map2.Parent = ServerStorage
local map3 = Instance.new("Model")
map3.Name = "Map3"
map3.Parent = ServerStorage
local maps = { map1, map2, map3 }
local RNG = Random.new()
local currentMap = nil
local lastPick = nil
while true do
print("New map!")
-- remove current map
if currentMap then
currentMap:Destroy()
end
-- pick a map
local randomPick = nil
if #maps > 1 then
repeat
randomPick = RNG:NextInteger(1, #maps)
until randomPick ~= lastPick
lastPick = randomPick
end
-- fetch new map
local map = maps[randomPick]
currentMap = map:Clone()
currentMap.Parent = workspace
task.wait(ROUND_TIME)
end