How do you make a no killing period for like 10 mins?

So I just made a server and have this idea where for 15 mins you build your bases and then it is war for like 10 mins. Any one know howto do that?

Wrote this up for you very quickly,

[lua]function nokill ( mins )
PrintMessage( HUD_PRINTTALK, “[NoKill] Killing has been disabled for " … mins … " minutes!” )

for _, ply in pairs ( player.GetAll ( ) ) do
	if ( not ply:HasGodMode ( ) ) then
		ply:GodEnable ( )

timer.Create("nokill", mins * 60, 1,
	function ( )
		PrintMessage( HUD_PRINTTALK, "[NoKill] Killing been enabled!")

		for _, ply in pairs ( player.GetAll ( ) ) do
			if ( ply:HasGodMode ( ) ) then
				ply:GodDisable ( )


Run nokill ( minutes ) server side to activate.

thank you so much

for k, v in pairs(player.GetAll()) do
timer.Simple( number 600, function()
for k, v in pairs(player.GetAll()) do

[editline]5th April 2015[/editline]

Shitty code I wrote in 2 secs, but got ninja’d anyway so :v:

Here’s a console command for easier use as well,

[lua]-- Change this to allow ranks to use.
local allowed = {
[“superadmin”] = true,
[“admin”] = true,

– Hell, if you want Steam ID’s only,
local allowedid = {
[“STEAM_0_0:0”] = true,

concommand.Add( “nokill”,
function ( ply, command, arguments, minutes )
if ( tonumber ( minutes ) and ( allowed [ ply:GetUserGroup ( ) ] or allowedid [ ply:SteamID ( ) ) ) then
nokill ( minutes )

does this go in a cycle from build to killing?

It prevents anyone from dying for x minutes after it has been called.

It gives everyone god mode for stated amount of minutes, and then revokes their god mode automatically after x minutes.

what does the 60 mean on line 10 ???

The function is called with an amount of minutes specified. Since timer.Create takes the time in seconds as a parameter, it takes the value in minutes specified and multiplies it by 60 to get the desired time.

do you have to close the parentheses in timer.Create(“nokill”, mins * 60, 1,

The parenthesis is closed later. This timer has a function, so it has to contain the rest of the code.
Why don’t you try out the code before assuming it’s broken?

i am not assuming it’s broken i just have no idea how to program so i am asking quastions but thx for the help :slight_smile:

GodEnable and GodDisable can easily be glitched so they won’t work until you call Disable then Enable again on the user.

Use mine, remove .html to view Lua:

Plenty of customization, but to enable timed god-mode sequences simply add:

// Start server with build-mode
BuildMode = BuildMode || true;

hook.Add( "HasGodMode", "EnableDisableGodTimer", function( _p )
	if ( BuildMode ) then
		return true;

timer.Create( "EnableDisableGodMode", 60 * 10, function( )
	BuildMode = !BuildMode;
end );

for simple 10 minute build / god, 10 minute non-build / non-god… Make sure all of the code is server-side; also modify the code above any way you want to enable / disable using a global controller ( You can use hooks to enable / disable, etc… ).

I must say, your name is the best name I’ve seen on this site so far.
As for what you asked, yeah just use Acecools method.

My steam name is OfficerBigTitty but on this forum it was too big a did not let me be A BIG TITTY insteed i am a normal titty. That makes me sad titty :frowning:

I feel like this could work nicely, too.

BuildMode = BuildMode or true
hook.Add("PlayerShouldTakeDamage", "buildtime", function(client, attacker)
    if BuildMode then return false end

timer.Create("BuildTimer", 600, 1, function() BuildMode = false end)

If you want it to toggle between on and off state, set BuildMode = !BuildMode;

But, yes… That is a shorter and cleaner implementation if you don’t need all of the other bloat, helper-functions or hooks…

You may want to also add the Fall Damage hook ( Can’t recall if PlayerShouldTakeDamage is called for that; it should work but I seem to recall needing it in addition to the Should take damage hook ).

PlayerShouldTakeDamage is called for every damage event relating to the player as far as I’m aware. And yes, I just tested it to be sure, it is called for fall damage.