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,38 +653,52 @@ function InitalizeClientAppearance(Player,Hat1ID,Hat2ID,Hat3ID,HeadColorID,Torso
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
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 RunService=game:GetService("RunService")
pcall(NetworkServer.Stop,NetworkServer)
if (rbxlegacyversion >= 8) then
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")
pcall(NetworkServer.Stop,NetworkServer)
NetworkServer:Start(Port)
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
RunService:Run()
else
NetworkServer:start(Port, 20)
RunService:run()
end
game.Workspace:InsertContent("rbxasset://fonts/libraries.rbxm")
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 have been blacklisted from this server."
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: 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
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()
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 blacklisted from 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 == "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)
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()
if (rbxlegacyversion < 8) then
LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack)
end
end
if (rbxlegacyversion >= 8) then
Player.CharacterAdded:connect(function(char)
LoadCharacterNew(newWaitForChild(Player,"Appearance"),Player.Character,Player.Backpack)
end)
@ -697,178 +711,87 @@ function CSServer(Port,PlayerLimit,RespawnTime,IsPersonalServer,ChatType,HostID,
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()
game.Workspace:InsertContent("rbxasset://fonts/libraries.rbxm")
pcall(function() game.Close:connect(function() NetworkServer:Stop() end) end)
NetworkServer.IncommingConnection:connect(IncommingConnection)
-- perbsosnal sebrs!
if IsPersonalServer == true then
pcall(function() game:GetService("PersonalServerService") end)
pcall(function() game.IsPersonalServer(true) end)
end
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
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
else
while true do
wait(0.001)
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)
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)
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)
game:GetService("Players").PlayerRemoving:connect(function(Player)
print("Player '" .. Player.Name .. "' with ID '" .. Player.userId .. "' leaving")
end)
pcall(function() game.Close:connect(function() NetworkServer:Stop() end) end)
NetworkServer.IncommingConnection:connect(IncommingConnection)
-- perbsosnal sebrs!
if IsPersonalServer == true then
pcall(function() game:GetService("PersonalServerService") end)
pcall(function() game.IsPersonalServer(true) end)
end
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
@ -1008,10 +931,10 @@ function CSConnect(UserID,ServerIP,ServerPort,PlayerName,Hat1ID,Hat2ID,Hat3ID,He
Player.CanLoadCharacterAppearance = false
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)
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.")
Player:Remove()
end
end]]
local isAdmin = Instance.new("BoolValue")
isAdmin.Parent = Player
isAdmin.Name = "isAdmin"
@ -1029,10 +952,10 @@ function CSConnect(UserID,ServerIP,ServerPort,PlayerName,Hat1ID,Hat2ID,Hat3ID,He
pcall(function() player.Name=PlayerName or "" end)
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)
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.")
player:Remove()
end
end]]
local isAdmin = Instance.new("BoolValue")
isAdmin.Parent = player
isAdmin.Name = "isAdmin"