Terrorist Script/Darkrp

Ok what I am trying to do is make it so that when the terrorist dies the class will be disabled for 20 minutes and the person will be demoted. After the 20 minutes is up it will useable again and so on.

This is what I have so far.

local function terrorist( ply )
if ply:Team() == TEAM_TERRORIST then
			ply:ChangeTeam(TEAM_CITIZEN, true)
            Notify(ply, 1, 4, "You have been demoted because you have died.")
			for a, b in pairs(player.GetAll()) do
				Notify(b, 1, 4, "There has been a bombing but the terrorist died in the process!")
hook.Add("PlayerDeath", "terrorist", terrorist)

local function StopTerrorist( ply )
if ply:Team() == TEAM_TERRORIST then 
RunConsoleCommand("rp_allowterrorist 0")
timer.Create( "StopTerrorist", 1200, 1, function()
RunConsoleCommand("rp_allowterrorist 1")
      end )

hook.Add("PlayerDeath", "StopTerrorist", StopTerrorist)

RunConsoleCommand would make the player run the command and then they could just do it when they didn’t want to wait so it won’t work, you’ll have to make the game do it for the player I believe.

Yeah, I figured that. I need something to disable it then enable it but I just don’t know what to do.

i think RunConsoleCommand()'ll work because its called serverside, so this should work if rp_allowterrorist exist, to create it, use something like : [lua] if !ConVarExists( “rp_allowterrorist” ) then CreateConVar( “rp_allowterrorist”, “1”, { FCVAR_REPLICATED, FCVAR_ARCHIVE } ) end
Now you need to check if the player can join the team when the player change his team, you now can use

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=G.GetConVarNumber)** to check this.

Thanks for the help slay3r36 but I used another command. I used game.ConsoleCommand("rp_allowterrorist 1

It works perfectly but I don’t know if it is exploitable or if it will fuck something up. I am probably paranoid lol.


Ok another question is there a way so if there is there is nobody on the server it will change to a 1

RunConsoleCommand is clientside …

Its shared, i run admin-only command serverside with it.