local function getNumTeamRoleAlive( teamid, role ) local num = 0 for k,v in pairs( team.GetPlayers( teamid ) ) do if v:Alive() and v:GetRole() == role then num = num + 1 end end return num end local function getNumTeamRole( teamid, role ) local num = 0 for k,v in pairs( team.GetPlayers( teamid ) ) do if v:GetRole() == role then num = num + 1 end end return num end hook.Add( "EntityKeyValue", "Door sounds", function( ent, key, value ) if string.find( ent:GetClass(), "door" ) then if key == "loopmovesound" then return "0" end end end ) hook.Add( "TTTOnLoaded", "LoadTTTStuff", function() local TTTInRound = false hook.Remove( "PlayerCanPickupWeapon", "BA:PlayerCanPickupWeapon" ) --[[hook.Remove( "KeyPress", "AFK-LastKeyPressed" ) hook.Remove( "KeyRelease", "AFK-LastKeyReleased" ) hook.Remove( "OnPreRoundStart", "ResetAFKSlayedFlag") hook.Remove( "Think", "AFK-Brains" )]] hook.Add( "Think", "Anti - Cloak Exploit", function() for _,ply in pairs( player.GetAll() ) do if ply.IsCloaked and ply:IsCloaked() and !ply:HasWeapon( "weapon_ttt_cloak" ) then ply:SetCloaked( false ) end end end ) --[[hook.Add("EntityTakeDamage","Player Shot Someone", function(vic, inf, attk, amt) if vic:IsPlayer() and attk:IsPlayer() and ( ( attk:GetRole() == ROLE_INNOCENT or attk:GetRole() == ROLE_DETECTIVE ) and ( vic:GetRole() == ROLE_INNOCENT or vic:GetRole() == ROLE_DETECTIVE ) ) and amt > 5 then if vic.InitialDamageFrom and not vic.InitialDamageFrom[ attk:SteamID() ] then vic.InitialDamageFrom[ attk:SteamID() ] = CurTime() BAdmin:Log( string.format( "[RDM] %s was shot first by %s", vic:Nick( true ), attk:Nick( true ) ) ) end elseif vic:GetClass() == "ttt_health_station" and ( attk:IsPlayer() and ( attk:GetRole() == ROLE_INNOCENT or attk:GetRole() == ROLE_DETECTIVE ) ) then vic.DidRDM = true end end)]] local RDMerKarama = {} function _R.Player:GetRDMKarma() return RDMerKarama[ self:SteamID() ] or 1 end function _R.Player:AddRDMKarma( num ) RDMerKarama[ self:SteamID() ] = self:GetRDMKarma() + num end function _R.Player:SubRDMKarma( num ) RDMerKarama[ self:SteamID() ] = self:GetRDMKarma() - num end function _R.Player:ShowRDMMenu( ply, rupees ) umsg.Start( "TTT_RDM", self ) umsg.Entity( ply ) umsg.Short( rupees ) umsg.End() self.InRDMMenu = true self.RDMPlayer = ply self.RDMRupeeDeduction = rupees end concommand.Add( "~___ttt_rdm", function( ply, cmd, args ) if ply.InRDMMenu then if IsValid( ply.RDMPlayer ) then local action = tonumber( args[ 1 ] ) or 0 if action == 1 then ply:ChatPrint( "[red]You have chosen to forgive " .. ply.RDMPlayer:Nick( true ) ) ply.RDMPlayer:ChatPrint( "[red]" .. ply:Nick( true ) .. " has forgiven you!" ) elseif action == 2 then ply.RDMPlayer:TakeRupees( ply.RDMRupeeDeduction ) ply:ChatPrint( "[red]You have destroyed " .. ply.RDMRupeeDeduction .. " rupees from " .. ply.RDMPlayer:Nick( true ) ) ply.RDMPlayer:ChatPrint( "[red]" .. ply:Nick( true ) .. " has chosen to destroy " .. ply.RDMRupeeDeduction .. " of your rupees!" ) elseif action == 3 and ply.RDMPlayer:Alive() then ply.RDMPlayer:SetVelocity( Vector( math.random( -500, 500 ), math.random( -500, 500 ), math.random( -500, 500 ) ) ) ply.RDMPlayer:SetHealth( ply.RDMPlayer:Health() * 0.5 ) ply.RDMPlayer:EmitSound( "player/damage" .. math.random( 1, 3 ) .. ".wav", 100, 100 ) ply:ChatPrint( "[red]You have slapped " .. ply.RDMPlayer:Nick( true ) ) ply.RDMPlayer:ChatPrint( "[red]" .. ply:Nick( true ) .. " has chosen to slap you for RDMing them!" ) elseif action == 4 and ply.RDMPlayer:Alive() then ply.RDMPlayer:Ignite(10,0) ply:ChatPrint( "[red]You have burned " .. ply.RDMPlayer:Nick( true ) ) ply.RDMPlayer:ChatPrint( "[red]" .. ply:Nick( true ) .. " has chosen to burn you for RDMing them!" ) end else ply:ChatPrint( "[red]Your RDMer disconnected!" ) end ply.InRDMMenu = false end end ) hook.Add( "PlayerUse", "TTT - Stop door spam", function( ply, ent ) if string.find( ent:GetClass(), "door" ) then if ( !ent.LastUsedDoor or ent.LastUsedDoor <= CurTime() ) then ent.LastUsedDoor = CurTime() + 1 else return false end end end ) hook.Add("PlayerDeath","Give Monies", function(vic, dmg, attk) if vic != attk and (vic:IsPlayer() and attk:IsPlayer() ) and TTTInRound then if ( attk:GetRole() == ROLE_INNOCENT or attk:GetRole() == ROLE_DETECTIVE ) and ( vic:GetRole() == ROLE_INNOCENT or vic:GetRole() == ROLE_DETECTIVE ) or ( attk:GetRole() == ROLE_TRAITOR and vic:GetRole() == ROLE_TRAITOR ) then local RDMer = nil local RDMVic = nil BAdmin:AdminNotify( string.format( "%s killed %s who were both the same role", attk:Nick( true ), vic:Nick( true ) ), SPEW_ERROR ) if vic.InitialDamageFrom and vic.InitialDamageFrom[ attk:SteamID() ] and attk.InitialDamageFrom and attk.InitialDamageFrom[ vic:SteamID() ] then // Someone shot first BAdmin:Log( "[RDM] Who shot first?" ) local timeVictimShotAttacker = vic.InitialDamageFrom[ attk:SteamID() ] local timeAttackerShotVictim = attk.InitialDamageFrom[ vic:SteamID() ] if timeVictimShotAttacker < timeAttackerShotVictim and timeAttackerShotVictim - timeVictimShotAttacker <= 10 then RDMer = attk RDMVic = vic if !RDMVic.DidRDM then // Killer shot first, victim fought back and lost RDMer:AddRDMKarma( 0.25 ) if RDMer:GetRole() == ROLE_DETECTIVE then RDMer:AddRDMKarma( 0.1 ) end BAdmin:Log( string.format( "[RDM] Killer <%s><%.2f> shot first, victim <%s><%.2f> fought back and lost", RDMer:Nick( true ), RDMer:GetRDMKarma(), RDMVic:Nick( true ), RDMVic:GetRDMKarma() ) ) --RDMVic:ChatPrint( string.format( "[pink]%s [red]RDM'd[/c] you even though you fought back and lost.", RDMer:Nick( true ) ) ) end elseif timeVictimShotAttacker - timeAttackerShotVictim <= 10 then // The killer shot first, victim fought back and won RDMer = vic RDMVic = attk if !RDMVic.DidRDM then RDMer:AddRDMKarma( 0.15 ) if RDMer:GetRole() == ROLE_DETECTIVE then RDMer:AddRDMKarma( 0.1 ) end BAdmin:Log( string.format( "[RDM] Victim <%s><%.2f> was shot first, killer <%s><%.2f> was killed by the victim", RDMVic:Nick( true ), RDMVic:GetRDMKarma(), RDMer:Nick( true ), RDMer:GetRDMKarma() ) ) --RDMer:ChatPrint( string.format( "You shot [pink]%s[/c] first and they shot back to protect themself", RDMVic:Nick( true ) ) ) end end else // The killer RDM'd without the victim fighting back RDMer = attk RDMVic = vic if !RDMVic.DidRDM then RDMer:AddRDMKarma( 0.25 ) if RDMer:GetRole() == ROLE_DETECTIVE then RDMer:AddRDMKarma( 0.1 ) end RDMVic:ChatPrint( string.format( "[pink]%s [red]RDM'd you", RDMer:Nick( true ) ) ) BAdmin:Log( string.format( "[RDM] The killer <%s><%.2f> RDM'd without the victim <%s><%.2f> fighting back", RDMer:Nick( true ), RDMer:GetRDMKarma(), vic:Nick( true ), RDMVic:GetRDMKarma() ) ) end end if IsValid( RDMer ) and IsValid( RDMVic ) then if RDMer:GetRDMKarma() >= 2 then RDMVic:ChatPrint( string.format( "[red]%s[/c] RDM'd you and got banned", RDMer:Nick( true ) ) ) sourcebans.BanPlayer( RDMer, 1440 * 60, "Excessive RDMing" ) elseif !RDMVic.DidRDM then RDMer.DidRDM = true --RDMVic:ShowRDMMenu( RDMer, math.Round( 50 ^ ( RDMer:GetRDMKarma() or 1 ) ) )]] end end elseif attk:GetRole() == ROLE_TRAITOR and vic:GetRole() == ROLE_INNOCENT then attk:GiveRupees( 25 ) if attk:GetRDMKarma() >= 1.05 then attk:SubRDMKarma( 0.05 ) end elseif attk:GetRole() == ROLE_TRAITOR and vic:GetRole() == ROLE_DETECTIVE then attk:GiveRupees( 100 ) if attk:GetRDMKarma() >= 1.05 then attk:SubRDMKarma( 0.05 ) end elseif attk:GetRole() == ROLE_INNOCENT and vic:GetRole() == ROLE_TRAITOR then attk:GiveRupees( 100 ) if attk:GetRDMKarma() >= 1.05 then attk:SubRDMKarma( 0.05 ) end elseif attk:GetRole() == ROLE_DETECTIVE and vic:GetRole() == ROLE_TRAITOR then attk:GiveRupees( 250 ) if attk:GetRDMKarma() >= 1.05 then attk:SubRDMKarma( 0.05 ) end end end end) hook.Add( "TTTDelayRoundStartForVote", "TTT - Remove Rupees", function() BAdmin:GiveBackDroppedRupees() end ) local randomDays = { "day1relay", "day2relay", "day3relay", "night1relay", "night2relay", "night3relay", } hook.Add( "TTTPrepareRound", "No moar ghost plz", function() if game.GetMap() == "ttt_rooftops_a2_f1" then for _,v in pairs( ents.FindByModel("models/props/cs_militia/axe.mdl") ) do v:Remove() end elseif game.GetMap() == "trade_clocktown_b1" then for _,v in pairs( ents.FindByModel( "models/props_gameplay/resupply_locker.mdl" ) ) do v:Remove() end local randomRelay = ents.FindByName( table.Random( randomDays ) )[1] if IsValid( randomRelay ) then randomRelay:Fire( "Trigger", "", 0 ) end --[[if math.random() >= 0.5 then for _,rain in pairs( ents.FindByName( "rain" ) ) do rain:Fire( "Start", "", 0 ) end end]] end for k,v in ipairs( player.GetAll() ) do v:SetGhosted( false ) v.DidRDM = false v.InRDMMenu = false v.HasPlayerUpgrades = false end end ) hook.Add( "TTTBeginRound", "Mark as playing", function() for k,v in pairs( team.GetPlayers( TEAM_TERROR ) ) do v.PlayedInRound = true v.InitialDamageFrom = {} end TTTInRound = true end) hook.Add("TTTEndRound","Round Finished",function( wintype ) TTTInRound = false local allplayers = table.Add( team.GetPlayers( TEAM_TERROR ), team.GetPlayers( TEAM_SPEC ) ) if wintype == WIN_TIMELIMIT or wintype == WIN_INNOCENT then local innocentMoney = getNumTeamRoleAlive( TEAM_TERROR, ROLE_INNOCENT ) * 10 local detectiveMoney = getNumTeamRoleAlive( TEAM_TERROR, ROLE_DETECTIVE ) * 25 local totalEarnings = innocentMoney + detectiveMoney for k,v in pairs( allplayers ) do if v.PlayedInRound and v:GetRole() != ROLE_TRAITOR then if v:Alive() then v:GiveRupees( math.Round( totalEarnings * v:GetDamageFactor() ) ) v:GiveWin() v:ChatPrint( "[/c]You recieved [green]" .. totalEarnings .. " rupees[/c] and a win for surviving the round!" ) else local halfEarnings = math.Round( ( totalEarnings / 6 ) * v:GetDamageFactor() ) v:GiveRupees( halfEarnings ) v:ChatPrint( "[/c]You recieved [green]" .. halfEarnings .. " rupees[/c] for being on the winning team!" ) end end v.PlayedInRound = nil v.InitialDamageFrom = nil end elseif wintype == WIN_TRAITOR then local innocentMoney = getNumTeamRole( TEAM_SPEC, ROLE_INNOCENT ) * 10 local detectiveMoney = getNumTeamRole( TEAM_SPEC, ROLE_DETECTIVE ) * 25 local totalEarnings = innocentMoney + detectiveMoney for k,v in pairs( allplayers ) do if v.PlayedInRound and v:GetRole() == ROLE_TRAITOR then if v:Alive() then v:GiveRupees( math.Round( totalEarnings * v:GetDamageFactor() ) ) v:GiveWin() v:ChatPrint( "[/c]You recieved [green]" .. totalEarnings .. " rupees[/c] and a win for surviving the round!" ) else local halfEarnings = math.Round( ( totalEarnings / 2 ) * v:GetDamageFactor() ) v:GiveRupees( halfEarnings ) v:ChatPrint( "[/c]You recieved [green]" .. halfEarnings .. " rupees[/c] for being on the winning team!" ) end end v.PlayedInRound = nil v.InitialDamageFrom = nil end end end) end ) hook.Add( "ElevatorInit", "doda", function() hook.Remove( "PlayerCanPickupWeapon", "BA:PlayerCanPickupWeapon" ) hook.Remove( "KeyPress", "AFK-LastKeyPressed" ) hook.Remove( "KeyRelease", "AFK-LastKeyReleased" ) hook.Remove( "OnPreRoundStart", "ResetAFKSlayedFlag") hook.Remove( "Think", "AFK-Brains" ) end ) hook.Add( "Initialize", "DisableStuffForTTT", function() if GAMEMODE.FolderName == "terrortown" then hook.Call( "TTTOnLoaded" ) elseif GAMEMODE.FolderName == "elevator" then hook.Call( "ElevatorInit" ) elseif GAMEMODE.FolderName == "assassination" then hook.Remove( "PlayerCanPickupWeapon", "BA:PlayerCanPickupWeapon" ) end hook.Remove( "Initialize", "DisableStuffForTTT" ) end ) resource.AddSingleFile( "blackops/lost_woods.wav" )