Did a search through the Evolve code and found this...
[lua]ply:EV_GetRank()[/lua]
This should work:
[lua]if( SERVER )then
/* EDIT BELOW THIS AREA */
local CONFIG = {
Access = {"owner", "headadmin"}
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( table.HasValue(CONFIG.Access, ply:EV_GetRank()) )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 this error occurs. [img]http://puu.sh/1tHnb[/img]
Also, it says the command doesnt work :S [img]http://puu.sh/1tHp1[/img]
Change line 6 to this:
[lua]
Access = {"owner", "headadmin"},
[/lua]
Or simply add a comma at the end of the line.
Thank you, it now works! But it counts down from 25 minutes, I'd like it to say 'Restart in 5 minutes', then again saying 'Restart in 1 minute' (Obv after the 5 minutes) then when 30 seconds are left, it counts down 30, 29, 28 etc.. Any chance this could be changed?
Your question has nothing to do with lua knowledge and now you're just stupid. Read the comments and do as they say (at line 7 and 8)
[QUOTE=Donkie;38573785]Your question has nothing to do with lua knowledge and now you're just stupid. Read the comments and do as they say (at line 7 and 8)[/QUOTE]
My friend tried it and errors came up :/
However, I have asked for a lot, and nothing in return, I'm being selfish and I apologize.
"errors came up :/"
I'm sorry but how on earth can we help you with that?
The TimeToWait value is how long the script will wait until it restarts the server. Make sure you have a comma after changing the TimeToWait value ( line 7 ). Note that this value is measured in minutes.
So if you want it to wait 5 minutes, line 7 would be..
[code]
TimeToWait = 5,
[/code]
The Increments table is what tells the game when to display notifications to the player ( how often ). So if the table contains value .5, 1, and 2, then the game will notify they play the server is restarting 30 seconds before the restart ( .5 minutes = 30 seconds ), 1 minute before the restart, and 2 minutes before the restart. Each value is measured in minutes as I stated above. Make sure that each value has a comma to the right of it.
So if you wanted it to say that there are 5 mintues left, 1 minute left, and then 30 seconds left you would change line 8 to this
[code]
Increments = { .5, 1, 5 },
[/code]
The only problem is the fact it doesnt restart automatically :S
Sorry, you need to Log In to post a reply to this thread.