I was wandering if it was possible if someone could make an addon or script that counts down from 30 seconds for a server restart.
Players on my server can get very frustrated when the restart Just happens. Is there a way it can be made so it counts down when a command is typed, and it restarts when it gets to 0 automatically?
P.S The server is DarkRP
Thanks,
Jonny
What kinda server restart?
A map change or full SRCDS restart?
Just a restart that restarts all files, say, if a new addon is installed, it will restart so the addon can then be shown, I guess thats a full SRCDS restart?
Also, The countdown shows up like this..
[IMG]http://i47.tinypic.com/2n893xd.png[/IMG] (THE TOP ONE, NOT PAYDAY ONE)
But the writing would say: Server restart in 30 seconds
Then every second, another one of those comes up, so it would look like
Server restart in 30 seconds
*1 second later*
Server restart in 29 seconds
*all the way to 0, which is when server restarts*
Sorry for the long wait, I had to do something.
Put in lua/autorun/restart.lua
Type dorestart in console to perform the restart, and edit the CONFIG table to your likings.
[lua]
if( SERVER )then
local ADMIN, SUPERADMIN = 1, 2;
/* EDIT BELOW THIS AREA */
local CONFIG = {
Access = ADMIN, // Make it so only admins can run the command. Give people admin/superadmin with settings/users.txt
TimeToWait = 25, // Make it wait 25 minutes until it restarts
Increments = { .5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 23, 24, 24.5 }, // When should we display a notification that the server is restarting
};
/* EDIT ABOVE THIS AREA */
local function Thiink( ... )
if( !_G[ "ServerRestart" ] || !_G[ "ServerRestart" ].Enabled )then error( "Tried to restart the server by accident?" ); return; end
if( _G[ "ServerRestart" ].IncQue == 0 )then game.ConsoleCommand( "changelevel " .. game.GetMap() ); return; end
// If we didn't notify the player yet, send them a notification in TimeToWait - Increments[ #Increments ], else do LastIncrement - CurrentIncrement
local Delay = ( _G[ "ServerRestart" ].IncQue == #CONFIG.Increments )and( CONFIG.TimeToWait - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] ) or ( CONFIG.Increments[ _G[ "ServerRestart" ].IncQue + 1 ] - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] );
timer.Create( "ShowRestartNotifications", Delay * 60, 1, function( ... )
NotifyAll( 1, 3, "Server restart in " .. CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] .. " minutes!" );
_G[ "ServerRestart" ].IncQue = _G[ "ServerRestart" ].IncQue - 1;
Thiink();
end );
end
concommand.Add( "dorestart", function( ply, cmd, args )
if( !NotifyAll )then
print( "The person that requested this script wanted it for DarkRP. Sorry :[" );
return;
end
if( IsValid( ply ) && ((CONFIG.Access == ADMIN && ply:IsAdmin()) || (CONFIG.Access == SUPERADMIN && ply:IsSuperAdmin())) )then
if( _G[ "ServerRestart" ] && _G[ "ServerRestart" ].Enabled )then
ply:ChatPrint( "A server restart is already in progress!" );
return;
end
_G[ "ServerRestart" ] = {
Enabled = true,
IncQue = #CONFIG.Increments,
Length = CONFIG.TimeToWait * 60,
Date = os.time() + CONFIG.TimeToWait * 60,
EDate = CurTime() + CONFIG.TimeToWait * 60,
};
NotifyAll( 1, 3, "Server restart in " .. CONFIG.TimeToWait .. " minutes!" );
Thiink();
end
end );
end
[/lua]
thank you!
I added you on steam btw!
P.S I create restart.lua yes?
Yea. Make sure you make restart.lua inside lua/autorun
And, I want to make it for OWNER and HEAD ADMIN rank, Do i just check out what there TEAM_ name is in shared.lua for gamemode?
Meaning, Owner would be TEAM_OWNER
[lua]
if( SERVER )then
/* EDIT BELOW THIS AREA */
local CONFIG = {
TimeToWait = 25, // Make it wait 25 minutes until it restarts
Increments = { .5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 23, 24, 24.5 }, // When should we display a notification that the server is restarting
};
/* EDIT ABOVE THIS AREA */
local function Thiink( ... )
if( !_G[ "ServerRestart" ] || !_G[ "ServerRestart" ].Enabled )then error( "Tried to restart the server by accident?" ); return; end
if( _G[ "ServerRestart" ].IncQue == 0 )then game.ConsoleCommand( "changelevel " .. game.GetMap() ); return; end
// If we didn't notify the player yet, send them a notification in TimeToWait - Increments[ #Increments ], else do LastIncrement - CurrentIncrement
local Delay = ( _G[ "ServerRestart" ].IncQue == #CONFIG.Increments )and( CONFIG.TimeToWait - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] ) or ( CONFIG.Increments[ _G[ "ServerRestart" ].IncQue + 1 ] - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] );
timer.Create( "ShowRestartNotifications", Delay * 60, 1, function( ... )
NotifyAll( 1, 3, "Server restart in " .. CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] .. " minutes!" );
_G[ "ServerRestart" ].IncQue = _G[ "ServerRestart" ].IncQue - 1;
Thiink();
end );
end
concommand.Add( "dorestart", function( ply, cmd, args )
if( !NotifyAll )then
print( "The person that requested this script wanted it for DarkRP. Sorry :[" );
return;
end
if( IsValid( ply ) && (ply:Team() == TEAM_OWNER || ply:Team() == TEAM_HEAD_ADMIN) )then
if( _G[ "ServerRestart" ] && _G[ "ServerRestart" ].Enabled )then
ply:ChatPrint( "A server restart is already in progress!" );
return;
end
_G[ "ServerRestart" ] = {
Enabled = true,
IncQue = #CONFIG.Increments,
Length = CONFIG.TimeToWait * 60,
Date = os.time() + CONFIG.TimeToWait * 60,
EDate = CurTime() + CONFIG.TimeToWait * 60,
};
NotifyAll( 1, 3, "Server restart in " .. CONFIG.TimeToWait .. " minutes!" );
Thiink();
end
end );
end
[/lua]
Change the team names in line 37 to your liking, although I think you should give owners/head admins a rank in the users.txt so that they don't have to be a specific job to restart the server.
[QUOTE=zzaacckk;38541105][lua]
if( SERVER )then
/* EDIT BELOW THIS AREA */
local CONFIG = {
TimeToWait = 25, // Make it wait 25 minutes until it restarts
Increments = { .5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 23, 24, 24.5 }, // When should we display a notification that the server is restarting
};
/* EDIT ABOVE THIS AREA */
local function Thiink( ... )
if( !_G[ "ServerRestart" ] || !_G[ "ServerRestart" ].Enabled )then error( "Tried to restart the server by accident?" ); return; end
if( _G[ "ServerRestart" ].IncQue == 0 )then game.ConsoleCommand( "changelevel " .. game.GetMap() ); return; end
// If we didn't notify the player yet, send them a notification in TimeToWait - Increments[ #Increments ], else do LastIncrement - CurrentIncrement
local Delay = ( _G[ "ServerRestart" ].IncQue == #CONFIG.Increments )and( CONFIG.TimeToWait - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] ) or ( CONFIG.Increments[ _G[ "ServerRestart" ].IncQue + 1 ] - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] );
timer.Create( "ShowRestartNotifications", Delay * 60, 1, function( ... )
NotifyAll( 1, 3, "Server restart in " .. CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] .. " minutes!" );
_G[ "ServerRestart" ].IncQue = _G[ "ServerRestart" ].IncQue - 1;
Thiink();
end );
end
concommand.Add( "dorestart", function( ply, cmd, args )
if( !NotifyAll )then
print( "The person that requested this script wanted it for DarkRP. Sorry :[" );
return;
end
if( IsValid( ply ) && (ply:Team() == TEAM_OWNER || ply:Team() == TEAM_HEAD_ADMIN) )then
if( _G[ "ServerRestart" ] && _G[ "ServerRestart" ].Enabled )then
ply:ChatPrint( "A server restart is already in progress!" );
return;
end
_G[ "ServerRestart" ] = {
Enabled = true,
IncQue = #CONFIG.Increments,
Length = CONFIG.TimeToWait * 60,
Date = os.time() + CONFIG.TimeToWait * 60,
EDate = CurTime() + CONFIG.TimeToWait * 60,
};
NotifyAll( 1, 3, "Server restart in " .. CONFIG.TimeToWait .. " minutes!" );
Thiink();
end
end );
end
[/lua]
Change the team names in line 37 to your liking, although I think you should give owners/head admins a rank in the users.txt so that they don't have to be a specific job to restart the server.[/QUOTE]
They have a rank in the Evolve menu, we have 'Guest, VIP, admin, Super admin, Head admin, Owner'
What I meant is, I want it so Head admin and Owner can only do the restart,
So this line..
Access = ADMIN, // Make it so only admins can run the command. Give people admin/superadmin with settings/users.txt
should be changed to
Access = OWNER, HEAD ADMIN // Make it so only owners or head admins can run the command. Give people admin/superadmin with settings/users.txt
?
I doubt thats correct, but yeah :S
I just tried it on the server and it didnt work :/
It just says
Unknown command "restartnow"
] rcon dorestart
The person that requested this script wanted it for DarkRP. Sorry :[
restartnow didnt work
so i did rcon restartnow
then this comes up.. The person that requested this script wanted it for DarkRP. Sorry :[
(I tried the first one you did)
[img]http://puu.sh/1t3Nl[/img]
What version of DarkRP are you running?
the latest
I think it uses GAMEMODE.NotifyAll now, not just NotifyAll
How would it look on the script?
(I'm shit at lua..)
[lua]
if( SERVER )then
/* EDIT BELOW THIS AREA */
local CONFIG = {
TimeToWait = 25, // Make it wait 25 minutes until it restarts
Increments = { .5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 23, 24, 24.5 }, // When should we display a notification that the server is restarting
};
/* EDIT ABOVE THIS AREA */
local function Thiink( ... )
if( !_G[ "ServerRestart" ] || !_G[ "ServerRestart" ].Enabled )then error( "Tried to restart the server by accident?" ); return; end
if( _G[ "ServerRestart" ].IncQue == 0 )then game.ConsoleCommand( "changelevel " .. game.GetMap() ); return; end
// If we didn't notify the player yet, send them a notification in TimeToWait - Increments[ #Increments ], else do LastIncrement - CurrentIncrement
local Delay = ( _G[ "ServerRestart" ].IncQue == #CONFIG.Increments )and( CONFIG.TimeToWait - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] ) or ( CONFIG.Increments[ _G[ "ServerRestart" ].IncQue + 1 ] - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] );
timer.Create( "ShowRestartNotifications", Delay * 60, 1, function( ... )
GAMEMODE:NotifyAll( 1, 3, "Server restart in " .. CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] .. " minutes!" );
_G[ "ServerRestart" ].IncQue = _G[ "ServerRestart" ].IncQue - 1;
Thiink();
end );
end
concommand.Add( "dorestart", function( ply, cmd, args )
if( GAMEMODE.NotifyAll )then
print( "The person that requested this script wanted it for DarkRP. Sorry :[" );
return;
end
if( IsValid( ply ) && (ply:Team() == TEAM_OWNER || ply:Team() == TEAM_HEAD_ADMIN) )then
if( _G[ "ServerRestart" ] && _G[ "ServerRestart" ].Enabled )then
ply:ChatPrint( "A server restart is already in progress!" );
return;
end
_G[ "ServerRestart" ] = {
Enabled = true,
IncQue = #CONFIG.Increments,
Length = CONFIG.TimeToWait * 60,
Date = os.time() + CONFIG.TimeToWait * 60,
EDate = CurTime() + CONFIG.TimeToWait * 60,
};
GAMEMODE:NotifyAll( 1, 3, "Server restart in " .. CONFIG.TimeToWait .. " minutes!" );
Thiink();
end
end );
end
[/lua]
Try that... and the command is 'dorestart' not restart now
I don't want it for Jobs only who can do it, i want it so only head admins and owners can do the command :/
It's evolve groups btw :/
bump
Just change it to what ever you need to
[lua]ply:Team() == TEAM_OWNER [/lua]
[lua]evovle.GetRanks("admin")[/lua]
How would it look like on the rest of the script? Can you show me please so I can just add it to my server? Thanks :/
I will look, if you post the code.
[QUOTE=NinjaS;38563658]I will look, if you post the code.[/QUOTE]
[lua]
if( SERVER )then
local ADMIN, SUPERADMIN = 1, 2;
/* EDIT BELOW THIS AREA */
local CONFIG = {
Access = ADMIN, // Make it so only admins can run the command. Give people admin/superadmin with settings/users.txt
TimeToWait = 25, // Make it wait 25 minutes until it restarts
Increments = { .5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 23, 24, 24.5 }, // When should we display a notification that the server is restarting
};
/* EDIT ABOVE THIS AREA */
local function Thiink( ... )
if( !_G[ "ServerRestart" ] || !_G[ "ServerRestart" ].Enabled )then error( "Tried to restart the server by accident?" ); return; end
if( _G[ "ServerRestart" ].IncQue == 0 )then game.ConsoleCommand( "changelevel " .. game.GetMap() ); return; end
// If we didn't notify the player yet, send them a notification in TimeToWait - Increments[ #Increments ], else do LastIncrement - CurrentIncrement
local Delay = ( _G[ "ServerRestart" ].IncQue == #CONFIG.Increments )and( CONFIG.TimeToWait - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] ) or ( CONFIG.Increments[ _G[ "ServerRestart" ].IncQue + 1 ] - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] );
timer.Create( "ShowRestartNotifications", Delay * 60, 1, function( ... )
NotifyAll( 1, 3, "Server restart in " .. CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] .. " minutes!" );
_G[ "ServerRestart" ].IncQue = _G[ "ServerRestart" ].IncQue - 1;
Thiink();
end );
end
concommand.Add( "dorestart", function( ply, cmd, args )
if( !NotifyAll )then
print( "The person that requested this script wanted it for DarkRP. Sorry :[" );
return;
end
if( IsValid( ply ) && ((CONFIG.Access == ADMIN && ply:IsAdmin()) || (CONFIG.Access == SUPERADMIN && ply:IsSuperAdmin())) )then
if( _G[ "ServerRestart" ] && _G[ "ServerRestart" ].Enabled )then
ply:ChatPrint( "A server restart is already in progress!" );
return;
end
_G[ "ServerRestart" ] = {
Enabled = true,
IncQue = #CONFIG.Increments,
Length = CONFIG.TimeToWait * 60,
Date = os.time() + CONFIG.TimeToWait * 60,
EDate = CurTime() + CONFIG.TimeToWait * 60,
};
NotifyAll( 1, 3, "Server restart in " .. CONFIG.TimeToWait .. " minutes!" );
Thiink();
end
end );
end
[/lua]
[QUOTE=NinjaS;38562043]Just change it to what ever you need to
[lua]ply:Team() == TEAM_OWNER [/lua]
[lua]evovle.GetRanks("admin")[/lua][/QUOTE]
You would use ply:EV_IsRank( rankString )-- evolve.GetRanks with one argument couldn't verify if a player's rank is set to admin.
But I must be looking at an old version because it uses _R so it may have changed
[editline]23rd November 2012[/editline]
Oh and nice to see you back, Cubar.
Zaack, could you make it for the ev ranks please? :/
I don't know the system names of your groups, so I guessed they were 'owner' and 'headadmin'.
Again, I don't know if EV_IsRank will work because (_R is deprecated AFAIK) and that's what evolve uses- but I guess its worth a shot.
[lua]
if( SERVER )then
/* EDIT BELOW THIS AREA */
local CONFIG = {
TimeToWait = 25, // Make it wait 25 minutes until it restarts
Increments = { .5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 23, 24, 24.5 }, // When should we display a notification that the server is restarting
};
/* EDIT ABOVE THIS AREA */
local function Thiink( ... )
if( !_G[ "ServerRestart" ] || !_G[ "ServerRestart" ].Enabled )then error( "Tried to restart the server by accident?" ); return; end
if( _G[ "ServerRestart" ].IncQue == 0 )then game.ConsoleCommand( "changelevel " .. game.GetMap() ); return; end
// If we didn't notify the player yet, send them a notification in TimeToWait - Increments[ #Increments ], else do LastIncrement - CurrentIncrement
local Delay = ( _G[ "ServerRestart" ].IncQue == #CONFIG.Increments )and( CONFIG.TimeToWait - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] ) or ( CONFIG.Increments[ _G[ "ServerRestart" ].IncQue + 1 ] - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] );
timer.Create( "ShowRestartNotifications", Delay * 60, 1, function( ... )
NotifyAll( 1, 3, "Server restart in " .. CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] .. " minutes!" );
_G[ "ServerRestart" ].IncQue = _G[ "ServerRestart" ].IncQue - 1;
Thiink();
end );
end
concommand.Add( "dorestart", function( ply, cmd, args )
if( !NotifyAll )then
print( "The person that requested this script wanted it for DarkRP. Sorry :[" );
return;
end
if( ply:EV_IsRank("owner") || ply:EV_IsRank("headadmin") )then
if( _G[ "ServerRestart" ] && _G[ "ServerRestart" ].Enabled )then
ply:ChatPrint( "A server restart is already in progress!" );
return;
end
_G[ "ServerRestart" ] = {
Enabled = true,
IncQue = #CONFIG.Increments,
Length = CONFIG.TimeToWait * 60,
Date = os.time() + CONFIG.TimeToWait * 60,
EDate = CurTime() + CONFIG.TimeToWait * 60,
};
NotifyAll( 1, 3, "Server restart in " .. CONFIG.TimeToWait .. " minutes!" );
Thiink();
end
end
[/lua]
I get this error.
[ERROR] lua/autorun/restart.lua:57: ')' expected (to close '(' at line 30) near '<eof>'
1. unknown - lua/autorun/restart.lua:0
My friend who made the ranks for me said this...
Also, what about getNWString( "EV_UserGroup" ), so it should look like getNWString( "EV_UserGroup" ) == "owner" and getNWString( "EV_UserGroup" ) == "headadmin"
Change line 57 to
[lua]
end ) end
[/lua]
Doesn't work still :/ [img]http://puu.sh/1tuR7[/img]
[QUOTE=Jongunner;38566865]Doesn't work still :/ [img]http://puu.sh/1tuR7[/img][/QUOTE]
Because when you copied the code, you gave out an old version.....
[lua]
if( SERVER )then
/* EDIT BELOW THIS AREA */
local CONFIG = {
TimeToWait = 25, // Make it wait 25 minutes until it restarts
Increments = { .5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 23, 24, 24.5 }, // When should we display a notification that the server is restarting
};
/* EDIT ABOVE THIS AREA */
local function Thiink( ... )
if( !_G[ "ServerRestart" ] || !_G[ "ServerRestart" ].Enabled )then error( "Tried to restart the server by accident?" ); return; end
if( _G[ "ServerRestart" ].IncQue == 0 )then game.ConsoleCommand( "changelevel " .. game.GetMap() ); return; end
// If we didn't notify the player yet, send them a notification in TimeToWait - Increments[ #Increments ], else do LastIncrement - CurrentIncrement
local Delay = ( _G[ "ServerRestart" ].IncQue == #CONFIG.Increments )and( CONFIG.TimeToWait - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] ) or ( CONFIG.Increments[ _G[ "ServerRestart" ].IncQue + 1 ] - CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] );
timer.Create( "ShowRestartNotifications", Delay * 60, 1, function( ... )
GAMEMODE:NotifyAll( 1, 3, "Server restart in " .. CONFIG.Increments[ _G[ "ServerRestart" ].IncQue ] .. " minutes!" );
_G[ "ServerRestart" ].IncQue = _G[ "ServerRestart" ].IncQue - 1;
Thiink();
end );
end
concommand.Add( "dorestart", function( ply, cmd, args )
if( !GAMEMODE.NotifyAll )then
print( "The person that requested this script wanted it for DarkRP. Sorry :[" );
return;
end
if( ply:EV_IsRank("owner") || ply:EV_IsRank("headadmin") )then
if( _G[ "ServerRestart" ] && _G[ "ServerRestart" ].Enabled )then
ply:ChatPrint( "A server restart is already in progress!" );
return;
end
_G[ "ServerRestart" ] = {
Enabled = true,
IncQue = #CONFIG.Increments,
Length = CONFIG.TimeToWait * 60,
Date = os.time() + CONFIG.TimeToWait * 60,
EDate = CurTime() + CONFIG.TimeToWait * 60,
};
GAMEMODE:NotifyAll( 1, 3, "Server restart in " .. CONFIG.TimeToWait .. " minutes!" );
Thiink();
end
end )
end
[/lua]
Now it says this in console...
[ERROR] lua/autorun/restart.lua:37: attempt to call method 'EV_IsRank' (a nil value)
1. unknown - lua/autorun/restart.lua:37
2. unknown - lua/includes/modules/concommand.lua:69
Also, I don't want it to restart after 20 mins etc, I want it so it can only be restarted by the command :S
I just had restart in 20 mins pop up
Sorry, you need to Log In to post a reply to this thread.