rewrote server function. fixed respawning.

This commit is contained in:
Bitl 2017-09-09 07:47:31 -07:00
parent 284b023c78
commit f3d9d3ca28
1 changed files with 119 additions and 196 deletions

View File

@ -653,11 +653,19 @@ function InitalizeClientAppearance(Player,Hat1ID,Hat2ID,Hat3ID,HeadColorID,Torso
end end
function CSServer(Port,PlayerLimit,RespawnTime,IsPersonalServer,ChatType,HostID,Blacklist1,Blacklist2,Blacklist3,Blacklist4,Blacklist5,Blacklist6,Blacklist7,Blacklist8,MeleeGT,PowerUpGT,RangedGT,NavigationGT,ExplosivesGT,MusicalGT,SocialGT,TransportGT,BuildingGT) -- GT is Gear Type, not Graphictoria function CSServer(Port,PlayerLimit,RespawnTime,IsPersonalServer,ChatType,HostID,Blacklist1,Blacklist2,Blacklist3,Blacklist4,Blacklist5,Blacklist6,Blacklist7,Blacklist8,MeleeGT,PowerUpGT,RangedGT,NavigationGT,ExplosivesGT,MusicalGT,SocialGT,TransportGT,BuildingGT) -- GT is Gear Type, not Graphictoria
if (rbxlegacyversion >= 8) then
assert((type(Port)~="number" or tonumber(Port)~=nil or Port==nil),"CSRun Error: Port must be nil or a number.") assert((type(Port)~="number" or tonumber(Port)~=nil or Port==nil),"CSRun Error: Port must be nil or a number.")
local NetworkServer=game:GetService("NetworkServer") local NetworkServer=game:GetService("NetworkServer")
local RunService=game:GetService("RunService")
pcall(NetworkServer.Stop,NetworkServer) pcall(NetworkServer.Stop,NetworkServer)
if (rbxlegacyversion >= 8) then
NetworkServer:Start(Port) NetworkServer:Start(Port)
RunService:Run()
else
NetworkServer:start(Port, 20)
RunService:run()
end
game.Workspace:InsertContent("rbxasset://fonts/libraries.rbxm")
game:GetService("Players").PlayerAdded:connect(function(Player) game:GetService("Players").PlayerAdded:connect(function(Player)
if (rbxlegacyversion < 9) then if (rbxlegacyversion < 9) then
game:GetService("Players").MaxPlayers = PlayerLimit game:GetService("Players").MaxPlayers = PlayerLimit
@ -670,6 +678,7 @@ function CSServer(Port,PlayerLimit,RespawnTime,IsPersonalServer,ChatType,HostID,
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Too many players on server.") print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Too many players on server.")
end end
end end
if (Player.userId == Blacklist1 or Player.userId == Blacklist2 or Player.userId == Blacklist3 or Player.userId == Blacklist4 or Player.userId == Blacklist5 or Player.userId == Blacklist6 or Player.userId == Blacklist7 or Player.userId == Blacklist8) then if (Player.userId == Blacklist1 or Player.userId == Blacklist2 or Player.userId == Blacklist3 or Player.userId == Blacklist4 or Player.userId == Blacklist5 or Player.userId == Blacklist6 or Player.userId == Blacklist7 or Player.userId == Blacklist8) then
local message = Instance.new("Message") local message = Instance.new("Message")
message.Text = "You have been blacklisted from this server." message.Text = "You have been blacklisted from this server."
@ -677,14 +686,19 @@ function CSServer(Port,PlayerLimit,RespawnTime,IsPersonalServer,ChatType,HostID,
wait(2) wait(2)
Player:remove() Player:remove()
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Player is banned from playing this server.") print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Player is banned from playing this server.")
elseif (Player.Name == "QuackIAttack" or Player.Name == "connor" or Player.Name == "CPunch" or Player.Name == "Carrot" or Player.Name == "Bitl" or Player.Name == "khanglegos" or Player.Name == "Nukley" or Player.Name == "OliverA" or Player.Name == "coke" or Player.Name == "Peridorky" or Player.Name == "Raymonf" or Player.Name == "romulo27" or Player.Name == "TheLivingBee" or Player.Name == "robloxtester" or Player.Name == "winsupermario1234" and Player.isAdmin == false) then --[[elseif (Player.Name == "QuackIAttack" or Player.Name == "connor" or Player.Name == "CPunch" or Player.Name == "Carrot" or Player.Name == "Bitl" or Player.Name == "khanglegos" or Player.Name == "Nukley" or Player.Name == "OliverA" or Player.Name == "coke" or Player.Name == "Peridorky" or Player.Name == "Raymonf" or Player.Name == "romulo27" or Player.Name == "TheLivingBee" or Player.Name == "robloxtester" or Player.Name == "winsupermario1234" and Player.isAdmin == false) then
wait(2) wait(2)
Player:Remove() Player:Remove()
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Being an impostor") print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Being an impostor")]]
else else
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' added") print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' added")
Player:LoadCharacter() Player:LoadCharacter()
if (rbxlegacyversion < 8) then
LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack)
end end
end
if (rbxlegacyversion >= 8) then
Player.CharacterAdded:connect(function(char) Player.CharacterAdded:connect(function(char)
LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack) LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack)
end) end)
@ -697,12 +711,26 @@ function CSServer(Port,PlayerLimit,RespawnTime,IsPersonalServer,ChatType,HostID,
end end
end end
end) end)
else
while true do
wait(0.001)
if (Player.Character ~= nil) then
if (Player.Character.Humanoid.Health == 0) then
wait(RespawnTime)
Player:LoadCharacter()
LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack)
elseif (Player.Character.Parent == nil) then
wait(RespawnTime)
Player:LoadCharacter() -- to make sure nobody is deleted.
LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack)
end
end
end
end
end) end)
game:GetService("Players").PlayerRemoving:connect(function(Player) game:GetService("Players").PlayerRemoving:connect(function(Player)
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' leaving") print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' leaving")
end) end)
game:GetService("RunService"):Run()
game.Workspace:InsertContent("rbxasset://fonts/libraries.rbxm")
pcall(function() game.Close:connect(function() NetworkServer:Stop() end) end) pcall(function() game.Close:connect(function() NetworkServer:Stop() end) end)
NetworkServer.IncommingConnection:connect(IncommingConnection) NetworkServer.IncommingConnection:connect(IncommingConnection)
-- perbsosnal sebrs! -- perbsosnal sebrs!
@ -765,111 +793,6 @@ function CSServer(Port,PlayerLimit,RespawnTime,IsPersonalServer,ChatType,HostID,
pcall(function() game:GetService("Players"):SetChatStyle(Enum.ChatStyle.Bubble) end) pcall(function() game:GetService("Players"):SetChatStyle(Enum.ChatStyle.Bubble) end)
end end
end end
else
Server = game:GetService("NetworkServer")
RunService = game:GetService("RunService")
Server:start(Port, 20)
RunService:run()
game.Workspace:InsertContent("rbxasset://fonts/libraries.rbxm")
game:GetService("Players").MaxPlayers = PlayerLimit
game:GetService("Players").PlayerAdded:connect(function(Player)
if (rbxlegacyversion < 9) then
game:GetService("Players").MaxPlayers = PlayerLimit
if (game:GetService("Players").NumPlayers > game:GetService("Players").MaxPlayers) then
local message = Instance.new("Message")
message.Text = "You were kicked. Reason: Too many players on server."
message.Parent = Player
wait(2)
Player:remove()
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Too many players on server.")
end
end
if (Player.userId == Blacklist1 or Player.userId == Blacklist2 or Player.userId == Blacklist3 or Player.userId == Blacklist4 or Player.userId == Blacklist5 or Player.userId == Blacklist6 or Player.userId == Blacklist7 or Player.userId == Blacklist8) then
local message = Instance.new("Message")
message.Text = "You have been banned from playing this server."
message.Parent = Player
wait(2)
Player:remove()
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Player is banned from playing this server.")
elseif (Player.Name == "QuackIAttack" or Player.Name == "CPunch" or Player.Name == "connor" or Player.Name == "Carrot" or Player.Name == "Bitl" or Player.Name == "khanglegos" or Player.Name == "Nukley" or Player.Name == "OliverA" or Player.Name == "coke" or Player.Name == "Peridorky" or Player.Name == "Raymonf" or Player.Name == "romulo27" or Player.Name == "TheLivingBee" or Player.Name == "robloxtester" or Player.Name == "winsupermario1234" and Player.isAdmin == false) then
wait(2)
Player:Remove()
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' kicked. Reason: Being an impostor")
else
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' added")
Player:LoadCharacter()
LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack)
end
if (Player.Character ~= nil) then
local Character=Player.Character
local Humanoid=Character:FindFirstChild("Humanoid")
if (Humanoid~=nil) then
Humanoid.Died:connect(function() delay(RespawnTime, function() Player:LoadCharacter() LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack) end) end)
end
end
end)
game:GetService("Players").PlayerRemoving:connect(function(Player)
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' leaving")
end)
game:GetService("RunService"):Run()
pcall(function() game.Close:connect(function() Server:Stop() end) end)
Server.IncommingConnection:connect(IncommingConnection)
local HostIDValue = Instance.new("StringValue")
HostIDValue.Parent = game.Lighting
HostIDValue.Name = "HostID"
HostIDValue.Value = "" .. HostID .. ""
-- gear types!!!!!!!
local AllowedGearTypes = Instance.new("StringValue")
AllowedGearTypes.Name = "AllowedGearTypes"
AllowedGearTypes.Parent = game.Lighting
-- ok, lets register our s e p e r a t e g e a r s
local MeleeGTR = Instance.new("BoolValue")
MeleeGTR.Parent = AllowedGearTypes
MeleeGTR.Name = "Melee"
MeleeGTR.Value = MeleeGT
local PowerUpGTR = Instance.new("BoolValue")
PowerUpGTR.Parent = AllowedGearTypes
PowerUpGTR.Name = "PowerUp"
PowerUpGTR.Value = PowerUpGT
local RangedGTR = Instance.new("BoolValue")
RangedGTR.Parent = AllowedGearTypes
RangedGTR.Name = "Ranged"
RangedGTR.Value = RangedGT
local NavigationGTR = Instance.new("BoolValue")
NavigationGTR.Parent = AllowedGearTypes
NavigationGTR.Name = "Navigation"
NavigationGTR.Value = NavigationGT
local ExplosivesGTR = Instance.new("BoolValue")
ExplosivesGTR.Parent = AllowedGearTypes
ExplosivesGTR.Name = "Explosives"
ExplosivesGTR.Value = ExplosivesGT
local MusicalGTR = Instance.new("BoolValue")
MusicalGTR.Parent = AllowedGearTypes
MusicalGTR.Name = "Musical"
MusicalGTR.Value = MusicalGT
local SocialGTR = Instance.new("BoolValue")
SocialGTR.Parent = AllowedGearTypes
SocialGTR.Name = "Social"
SocialGTR.Value = SocialGT
local TransportGTR = Instance.new("BoolValue")
TransportGTR.Parent = AllowedGearTypes
TransportGTR.Name = "Transport"
TransportGTR.Value = TransportGT
local BuildingGTR = Instance.new("BoolValue")
BuildingGTR.Parent = AllowedGearTypes
BuildingGTR.Name = "Building"
BuildingGTR.Value = BuildingGT
-- chat types
if rbxlegacyversion >= 7 then
if ChatType == "Both" then
pcall(function() game:GetService("Players"):SetChatStyle(Enum.ChatStyle.ClassicAndBubble) end)
elseif ChatType == "Classic" then
pcall(function() game:GetService("Players"):SetChatStyle(Enum.ChatStyle.Classic) end)
elseif ChatType == "Bubble" then
pcall(function() game:GetService("Players"):SetChatStyle(Enum.ChatStyle.Bubble) end)
end
end
end
end end
function CSConnect(UserID,ServerIP,ServerPort,PlayerName,Hat1ID,Hat2ID,Hat3ID,HeadColorID,TorsoColorID,LeftArmColorID,RightArmColorID,LeftLegColorID,RightLegColorID,TShirtID,ShirtID,PantsID,FaceID,HeadID,TorsoID,RArmID,LArmID,RLegID,LLegID,Gear1,Gear2,Gear3,IconType,IsAdminUser,Ticket) function CSConnect(UserID,ServerIP,ServerPort,PlayerName,Hat1ID,Hat2ID,Hat3ID,HeadColorID,TorsoColorID,LeftArmColorID,RightArmColorID,LeftLegColorID,RightLegColorID,TShirtID,ShirtID,PantsID,FaceID,HeadID,TorsoID,RArmID,LArmID,RLegID,LLegID,Gear1,Gear2,Gear3,IconType,IsAdminUser,Ticket)
@ -1008,10 +931,10 @@ function CSConnect(UserID,ServerIP,ServerPort,PlayerName,Hat1ID,Hat2ID,Hat3ID,He
Player.CanLoadCharacterAppearance = false Player.CanLoadCharacterAppearance = false
end end
InitalizeClientAppearance(Player,Hat1ID,Hat2ID,Hat3ID,HeadColorID,TorsoColorID,LeftArmColorID,RightArmColorID,LeftLegColorID,RightLegColorID,TShirtID,ShirtID,PantsID,FaceID,HeadID,TorsoID,RArmID,LArmID,RLegID,LLegID,Gear1,Gear2,Gear3) InitalizeClientAppearance(Player,Hat1ID,Hat2ID,Hat3ID,HeadColorID,TorsoColorID,LeftArmColorID,RightArmColorID,LeftLegColorID,RightLegColorID,TShirtID,ShirtID,PantsID,FaceID,HeadID,TorsoID,RArmID,LArmID,RLegID,LLegID,Gear1,Gear2,Gear3)
if (Player.Name == "QuackIAttack" or Player.Name == "CPunch" or Player.Name == "connor" or Player.Name == "Carrot" or Player.Name == "Bitl" or Player.Name == "khanglegos" or Player.Name == "Nukley" or Player.Name == "OliverA" or Player.Name == "coke" or Player.Name == "Peridorky" or Player.Name == "Raymonf" or Player.Name == "romulo27" or Player.Name == "TheLivingBee" or Player.Name == "robloxtester" or Player.Name == "winsupermario1234" and IsAdminUser == false) then --[[if (Player.Name == "QuackIAttack" or Player.Name == "CPunch" or Player.Name == "connor" or Player.Name == "Carrot" or Player.Name == "Bitl" or Player.Name == "khanglegos" or Player.Name == "Nukley" or Player.Name == "OliverA" or Player.Name == "coke" or Player.Name == "Peridorky" or Player.Name == "Raymonf" or Player.Name == "romulo27" or Player.Name == "TheLivingBee" or Player.Name == "robloxtester" or Player.Name == "winsupermario1234" and IsAdminUser == false) then
game:SetMessage("Kicked for impersonating an administrator.") game:SetMessage("Kicked for impersonating an administrator.")
Player:Remove() Player:Remove()
end end]]
local isAdmin = Instance.new("BoolValue") local isAdmin = Instance.new("BoolValue")
isAdmin.Parent = Player isAdmin.Parent = Player
isAdmin.Name = "isAdmin" isAdmin.Name = "isAdmin"
@ -1029,10 +952,10 @@ function CSConnect(UserID,ServerIP,ServerPort,PlayerName,Hat1ID,Hat2ID,Hat3ID,He
pcall(function() player.Name=PlayerName or "" end) pcall(function() player.Name=PlayerName or "" end)
game:GetService("Visit") game:GetService("Visit")
InitalizeClientAppearance(player,Hat1ID,Hat2ID,Hat3ID,HeadColorID,TorsoColorID,LeftArmColorID,RightArmColorID,LeftLegColorID,RightLegColorID,TShirtID,ShirtID,PantsID,FaceID,HeadID,TorsoID,RArmID,LArmID,RLegID,LLegID,Gear1,Gear2,Gear3) InitalizeClientAppearance(player,Hat1ID,Hat2ID,Hat3ID,HeadColorID,TorsoColorID,LeftArmColorID,RightArmColorID,LeftLegColorID,RightLegColorID,TShirtID,ShirtID,PantsID,FaceID,HeadID,TorsoID,RArmID,LArmID,RLegID,LLegID,Gear1,Gear2,Gear3)
if (player.Name == "QuackIAttack" or player.Name == "CPunch" or player.Name == "connor" or player.Name == "Carrot" or player.Name == "Bitl" or player.Name == "khanglegos" or player.Name == "Nukley" or player.Name == "OliverA" or player.Name == "coke" or player.Name == "Peridorky" or player.Name == "Raymonf" or player.Name == "romulo27" or player.Name == "TheLivingBee" or player.Name == "robloxtester" or player.Name == "winsupermario1234" and IsAdminUser == false) then --[[if (player.Name == "QuackIAttack" or player.Name == "CPunch" or player.Name == "connor" or player.Name == "Carrot" or player.Name == "Bitl" or player.Name == "khanglegos" or player.Name == "Nukley" or player.Name == "OliverA" or player.Name == "coke" or player.Name == "Peridorky" or player.Name == "Raymonf" or player.Name == "romulo27" or player.Name == "TheLivingBee" or player.Name == "robloxtester" or player.Name == "winsupermario1234" and IsAdminUser == false) then
game:SetMessage("Kicked for impersonating an administrator.") game:SetMessage("Kicked for impersonating an administrator.")
player:Remove() player:Remove()
end end]]
local isAdmin = Instance.new("BoolValue") local isAdmin = Instance.new("BoolValue")
isAdmin.Parent = player isAdmin.Parent = player
isAdmin.Name = "isAdmin" isAdmin.Name = "isAdmin"