User:Anaminus/PlaceTransfer: Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Anaminus m Some ideas... |
>Anaminus mNo edit summary |
||
Line 13: | Line 13: | ||
Function -> GetDataString | Function -> GetDataString | ||
Description -> | Description -> | ||
Return the string that was passed with the player when | |||
transfered. If the player was not transerfered, | transfered. If the player was not transerfered, return | ||
nil. | nil. | ||
</pre> | </pre> | ||
Line 37: | Line 37: | ||
local player = game.Players:GetPlayerFromCharacter(hit.Parent) | local player = game.Players:GetPlayerFromCharacter(hit.Parent) | ||
if player then | if player then | ||
local data = "teleportername | local data = "teleportername{" .. script.Parent.Name .. "}\n" | ||
if player:FindFirstChild("leaderstats") then | if player:FindFirstChild("leaderstats") then | ||
for i,v in pairs(player.leaderstats:GetChildren()) do | for i,v in pairs(player.leaderstats:GetChildren()) do | ||
local str = "" | local str = "" | ||
if v.className == "IntValue" then | if v.className == "IntValue" then | ||
str = str .. "stat" .. i .. "name | str = str .. "stat" .. i .. "name{" .. v.Name .. "}\n" | ||
str = str .. "stat" .. i .. "value | str = str .. "stat" .. i .. "value{" .. v.Value .. "}\n" | ||
end | end | ||
data = data .. str | data = data .. str | ||
Line 51: | Line 51: | ||
local str = "" | local str = "" | ||
if v.className == "Tool" or v.className == "HopperBin" then | if v.className == "Tool" or v.className == "HopperBin" then | ||
str = str .. "weapon" .. i .. "name | str = str .. "weapon" .. i .. "name{" .. v.Name .. "}\n" | ||
end | end | ||
data = data .. str | data = data .. str |
Revision as of 23:03, 31 August 2008
Breakdown
Object -> Player Function -> Transfer Argument -> float PlaceId Argument -> string DataString Description -> If the current place is allowed in the target place's configuration, then exit from current place and load the target place. The string ''DataString'' gets passed along with the player. Function -> GetDataString Description -> Return the string that was passed with the player when transfered. If the player was not transerfered, return nil.
Place (ID: 12345): Configure: Allowable transfer places: 67890 54321 98765 +
Examples
Place teleporter
e = true function Touched(hit) if not e then return end e = false local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then local data = "teleportername{" .. script.Parent.Name .. "}\n" if player:FindFirstChild("leaderstats") then for i,v in pairs(player.leaderstats:GetChildren()) do local str = "" if v.className == "IntValue" then str = str .. "stat" .. i .. "name{" .. v.Name .. "}\n" str = str .. "stat" .. i .. "value{" .. v.Value .. "}\n" end data = data .. str end end for i,v in pairs(player.Backpack:GetChildren()) do local str = "" if v.className == "Tool" or v.className == "HopperBin" then str = str .. "weapon" .. i .. "name{" .. v.Name .. "}\n" end data = data .. str end player:Transfer(67890,data) end e = true end script.Parent.Touched:connect(Touched)
Handle transfer
function PlayerEntered(player) local data = player:GetDataString() if data == nil then player:Remove() recent:Remove() end recent = nil local stats = {} local teleporter = string.gsub(data,"teleportername{(.-)}","%1") for id,value in str:gmatch("stat(%d+)name{(.-)}") do stats[(tonumber(id) or id)] = value end for id,value in str:gmatch("stat(%d+)value{(.-)}") do stats[stats[(tonumber(id) or id)]] = (tonumber(value) or value) stats[(tonumber(id) or id)] = nil end local board = Instance.new("IntValue") board.Name = "leaderstats" for i,v in pairs(stats) do local stat = Instance.new("IntValue") stat.Name = i stat.Value = v stat.Parent = board end while true do if player.Character ~= nil then break end wait() end local teleporter = workspace:FindFirstChild(teleporter) if teleporter ~= nil then player.Character.CFrame = CFrame.new(0,5,0) + teleporter.Position end end recent = nil game.Players.PlayerAdded:connect(PlayerEntered) game.NetworkServer.ChildAdded:connect(function(client) recent = client end)