I have a /ready command to activate killing and turn noclip on, etc, but I doesn't want to run on the server for some reason. I added /adminready and /adminover to the existing /ready and /over to make it easier for admins to control the game. This is what I have now:
[code]local ready = {}
local over = {}
if ply:IsAdmin() then
ply:PrintMessage( HUD_PRINTTALK, "Type /ready to vote to start the round. As an admin, you can type /adminready to automatically begin the round.")
else
ply:PrintMessage( HUD_PRINTTALK, "Type /ready to vote to start the round. Once 3/4ths of the server have voted, the round will start." )
end
hook.Add("PlayerSay", "War", function(ply,text,toall)
local id = ply:UniqueID()
local var = GetConVarNumber("sbox_plpldamage")
local players = player.GetAll()
if string.sub(text,1,11) and ply:IsAdmin() == "/adminready" then
if var == 0 then ply:ChatPrint("The round has already started. You can type /adminover to automatically end it.") return end
else
game.ConsoleCommand("sbox_plpldamage 0\n")
game.ConsoleCommand("sbox_noclip 0\n")
for _, v in pairs(players) do
v:ChatPrint("The round has been started by an admin. Killing is now enabled and no-clip is disabled. Type /over to vote to end the round.")
v:Kill()
end
ready = {}
over = {}
end
return
elseif string.sub(text,1,6) == "/ready" then
if var == 0 then ply:ChatPrint("The round has already started. Killing is enabled and no-clip is disabled. Type /over to vote to end the round.") return end
if table.HasValue(ready, id) then
ply:ChatPrint("You have already voted to start the round")
else
ply:ChatPrint("You have voted to start the round.")
table.insert(ready, id)
for _, v in pairs(players) do
v:ChatPrint(math.Round(#players*0.75)-#ready.." more vote(s) required to start the round.")
end
if #ready >= math.Round(#players*0.75) then
game.ConsoleCommand("sbox_plpldamage 0\n")
game.ConsoleCommand("sbox_noclip 0\n")
for _, v in pairs(players) do
v:ChatPrint("The round has started. Killing is now enabled and no-clip is disabled. Type /over to vote to end the round.")
v:Kill()
end
ready = {}
over = {}
end
end
return
elseif string.sub(text,1,11) and ply:IsAdmin() == "/adminover" then
if var == 0 then ply:ChatPrint("The round has already ended. You can type /adminready to automatically start the round") return end
if var == 1 then
game.ConsoleCommand("sbox_plpldamage 0\n")
game.ConsoleCommand("sbox_noclip 0\n")
for _, v in pairs(players) do
v:ChatPrint("The round has been ended by an admin. Killing will be disabled and no-clip will be enabled after the map restart.")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
end
ready = {}
over = {}
timer.Simple( 10, game.ConsoleCommand, "changelevel gm_flatgrass\n" )
return
elseif string.sub(text,1,5) == "/over" then
if var == 1 then ply:ChatPrint("The round is already over. Killing is disabled and no-clip is enabled.") return end
if table.HasValue(over, id) then
ply:ChatPrint("You have already voted to end the round.")
else
ply:ChatPrint("You have voted to end the round.")
table.insert(over, id)
for _, v in pairs(players) do
v:ChatPrint(math.Round(#players*0.75)-#over.." more vote(s) required to end the round.")
end
if #over >= math.Round(#players*0.75) then
for _, v in pairs(players) do
v:ChatPrint("The round has ended. Killing will be disabled and no-clip will be enabled after the map restart.")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
end
ready = {}
over = {}
timer.Simple( 10, game.ConsoleCommand, "changelevel gm_flatgrass\n" )
end
end
else
return text
end
end)
hook.Add("PlayerDisconnected", "WarDisconnect", function(ply)
local id = ply:UniqueID()
for k, v in pairs(ready) do
if v == id then
table.remove(ready, k)
end
end
for k, v in pairs(over) do
if v == id then
table.remove(over, k)
end
end
end)[/code]
And this was my last successful build:
[code]local ready = {}
local over = {}
hook.Add("PlayerSay", "War", function(ply,text,toall)
local id = ply:UniqueID()
local var = GetConVarNumber("sbox_plpldamage")
local players = player.GetAll()
if string.sub(text,1,6) == "/ready" then
if var == 0 then ply:ChatPrint("The round has already started. Killing is enabled and no-clip is disabled.") return end
if table.HasValue(ready, id) then
ply:ChatPrint("You have already voted to start the round")
else
ply:ChatPrint("You have voted to start the round.")
table.insert(ready, id)
for _, v in pairs(players) do
v:ChatPrint(math.Round(#players*0.75)-#ready.." more vote(s) required to start the round.")
end
if #ready >= math.Round(#players*0.75) then
game.ConsoleCommand("sbox_plpldamage 0\n")
game.ConsoleCommand("sbox_noclip 0\n")
for _, v in pairs(players) do
v:ChatPrint("The round has started. Killing is now enabled and no-clip is disabled.")
v:Kill()
end
ready = {}
over = {}
end
end
return
elseif string.sub(text,1,5) == "/over" then
if var == 1 then ply:ChatPrint("The round is already over. Killing is disabled and no-clip is enabled.") return end
if table.HasValue(over, id) then
ply:ChatPrint("You have already voted to end the round.")
else
ply:ChatPrint("You have voted to end the round.")
table.insert(over, id)
for _, v in pairs(players) do
v:ChatPrint(math.Round(#players*0.75)-#over.." more vote(s) required to end the round.")
end
if #over >= math.Round(#players*0.75) then
for _, v in pairs(players) do
v:ChatPrint("The round has ended. Killing will be disabled and no-clip will be enabled after the map restart.")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
v:ChatPrint("THE MAP WILL RESET IN 10 SECONDS!")
end
ready = {}
over = {}
timer.Simple( 10, game.ConsoleCommand, "changelevel gm_flatgrass\n" )
end
end
else
return text
end
end)
hook.Add("PlayerDisconnected", "WarDisconnect", function(ply)
local id = ply:UniqueID()
for k, v in pairs(ready) do
if v == id then
table.remove(ready, k)
end
end
for k, v in pairs(over) do
if v == id then
table.remove(over, k)
end
end
end)[/code]
I tried, but it removed them... I'll put them in [code] tags.
[editline]01:03PM[/editline]
Fixed that, but it's still not loading on the server. I think I may have screwed up with my "end"s. I'm just so unfamiliar with lua that I just have no idea where to look.
Sorry, you need to Log In to post a reply to this thread.