Multi Gamemode Server Issues (GMOD)

HELLO! This will be my first post here!
I have been having issues with my server BGGames
I just recently decided to make it multi-gamemode.
I have TTT, PropHunt, and Murder

TTT and Prophunt work fine, but I need to know how to make certain plugins work only for certain gamemodes

let me explain:
I have pointshop, but I only want certain items to show up on Murder(Playermodels)
I have a bunch of weapons in my shop but I only want them to show up if we are playing TTT
I tried to make the guns only work if gamemode.Get was “terrortown” but that just made them not show up at all for any gamemode.

Or:
I have Spec DM and I set that gamemode.Get to be terrortown but now it dosent work at all. Same with RDM manager

Is there anything I can do? I dont want my bystanders running around with deagles/

I am not new to lua, but I am having issues doing this.
I can show whatever Lua files you need me too, I just need to know how to fix this, Any help would be appreciated.

if !gmod.GetGamemode()[“Name”] == “Trouble in Terrorist Town” then return end

Put this at the top of your addons (all files) (modify it as needed), it should stop the files from loading if the gamemode isn’t TTT

This is the simplest way I could think of doing this, sorry.
Another method would be to make a module system that only loads certain Lua files per gamemode. (or just integrate the scripts you need into the gamemode)

I hope this helps :slight_smile:

FOR F**KS SAKE! Again with this shit.
It’s



if a ~= b then


and NOT



if !a == b then


For those who actually care: first one parses as not(a) == b and not(X) for any X that’s not false or nil will give false, so you get false == b which is not what you want.

OK! So that didnt Work. I caught the issue with ! being not.
Anyway heres what ive got! I am trying to make the file only work if TTT is the gamemode.
No Idea whats going wrong, Not getting any script errors, it just isnt working


if gmod.GetGamemode()["Name"] == "Trouble in Terrorist Town" then return

//Grand Theft Auto V Death Screen\\
//Made by [IЯAF] ÐγαMετR\\
//Version 1.0\\

util.AddNetworkString("gtavds_reset")
util.AddNetworkString("gtavds_death")
util.AddNetworkString("gtavds_deathinfo")

resource.AddFile("sound/gta5/deathsound.wav")
resource.AddFile("materials/gta5ds/vignette01.vtf")
resource.AddFile("materials/gta5ds/vignette01.vtm")
resource.AddFile("materials/gta5ds/vignette02.vtf")
resource.AddFile("materials/gta5ds/vignette02.vtm")
resource.AddFile("resource/fonts/pricedown_bl_0.ttf")

function gtavds_Init()
	if !ConVarExists( "gtavds_slowmotion" ) then
		CreateConVar("gtavds_slowmotion", 1, FCVAR_NOTIFY, "Toggles slowmotion feature")
	end
end
hook.Add( "Initialize", "gtavds_Init", gtavds_Init )

function gtavdsc_OverrideDeathSound()
	return true
end
hook.Add("PlayerDeathSound", "gtavdsc_OverrideDeathSound", gtavdsc_OverrideDeathSound)

function gtavds_Reset(ply, com,args)
	net.Start("gtavds_reset")
	net.Send(ply)
end
concommand.Add("gtavds_resettext", gtavds_Reset)

function gtavds_DeathSound(victim, wep, killer)
--original timer: 2.283
	net.Start("gtavds_death")
	net.Send(victim)
	
	victim.gtavds_tick1 = CurTime() + (2.283*game.GetTimeScale())
	victim.gtavds_tick2 = CurTime() + 7
	
	if SERVER then
		if game.SinglePlayer() then
			if GetConVarNumber("gtavds_slowmotion") == 1 then
				if game.GetTimeScale() == 1 then
					game.SetTimeScale(0.55)
				end
				
				timer.Simple((2.2899*game.GetTimeScale()), function()
					if !victim:Alive() then
						game.SetTimeScale(0.3)
					end
				end)
			end
			
		elseif !game.SinglePlayer() then
			net.Start("gtavds_deathinfo")
			net.WriteEntity(killer)
			if killer:IsPlayer() and killer:GetActiveWeapon():IsValid() then
				net.WriteFloat(killer:GetActiveWeapon():GetPrimaryAmmoType())
			end
			net.Send(victim)
		end
	end
end
hook.Add("PlayerDeath", "gtavds_DeathSound", gtavds_DeathSound)

function gtavds_Respawn( ply )

	if game.SinglePlayer() then
		game.SetTimeScale(1)
	end

end
hook.Add("PlayerSpawn", "gtavds_Respawn", gtavds_Respawn)
end

[editline]31st March 2015[/editline]

Also when I remove “return” and or add () it still doesn’t work

Move the return at the end of the first line to before the end on the last line.

So like

if gmod.GetGamemode()[“Name”] == “Trouble in Terrorist Town” then
“CODE”
return
end

[editline]31st March 2015[/editline]

OK! So…

Ive been at this for a few hours now.
I still have no idea why this isnt working.
Ive tried many different ways

I tried


if gmod.GetGamemode()["Name"] ~= "Trouble in Terrorist Town" then

else
return

//Code

end


Then I tried


if gmod.GetGamemode()["Name"] ~= "Trouble in Terrorist Town" then

else

//Code

return
end


As well as


if gmod.GetGamemode()["Name"] == "Trouble in Terrorist Town" then

//Code

return
end


And


if gmod.GetGamemode()["Name"] == "Trouble in Terrorist Town" then
return

//code

end


Can someone please tell me what im doing wrong. I can post files, or whatever. I just really want to figure this out.
Thank you !

[editline]31st March 2015[/editline]

OK! I am doing tests on a Deagle Swep

Heres the Code


if gmod.GetGamemode() ~= "terrortown" then 

else
return
-- Variables that are used on both client and server
SWEP.Gun = ("m9k_deagle") -- must be the name of your swep but NO CAPITALS!
SWEP.Category				= "M9K Pistols"
SWEP.Author				= "iron angles and models hexed and converted to gmod my Mr Fokkusu"
SWEP.Contact				= ""
SWEP.Purpose				= ""
SWEP.Instructions				= ""
SWEP.Icon = "vgui/ttt/m9k/icon_m9k_deagle.vmt"
SWEP.MuzzleAttachment			= "1" 	-- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellEjectAttachment			= "2" 	-- Should be "2" for CSS models or "1" for hl2 models
SWEP.PrintName				= "Desert Eagle .40"		-- Weapon name (Shown on HUD)	
SWEP.Slot				= 1				-- Slot in the weapon selection menu
SWEP.SlotPos				= 5			-- Position in the slot
SWEP.DrawAmmo				= true		-- Should draw the default HL2 ammo counter
SWEP.DrawWeaponInfoBox			= false		-- Should draw the weapon info box
SWEP.BounceWeaponIcon   		= 	false	-- Should the weapon icon bounce?
SWEP.DrawCrosshair			= false		-- set false if you want no crosshair
SWEP.Weight				= 3			-- rank relative ot other weapons. bigger is better
SWEP.AutoSwitchTo			= true		-- Auto switch to if we pick it up
SWEP.AutoSwitchFrom			= true		-- Auto switch from if you pick up a better weapon
SWEP.HoldType 				= "pistol"		-- how others view you carrying the weapon
-- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive 
-- you're mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper rifles

		
		SWEP.ViewModel				= "models/weapons/v_tcom_deagle.mdl"	-- Weapon view model
		SWEP.WorldModel				= "models/weapons/w_tcom_deagle.mdl"	-- Weapon world model
		SWEP.Base				= "weapon_tttbase"
		SWEP.Primary.Sound			= Sound("Weapon_TDegle.Single")		-- Script that calls the primary fire sound
		SWEP.Primary.RPM			= 600			-- This is in Rounds Per Minut	e
		SWEP.Primary.ClipSize			= 8		-- Size of a clip
		SWEP.Primary.DefaultClip		= 8		-- Bullets you start with
		SWEP.Primary.ClipMax            = 37    -- Evens shit out
		SWEP.Primary.KickUp				= 1		-- Maximum up recoil (rise)
		SWEP.Primary.KickDown			= 0.5		-- Maximum down recoil (skeet)
		SWEP.Primary.KickHorizontal		= 0.5		-- Maximum up recoil (stock)
		SWEP.Primary.Automatic			= false		-- Automatic = true; Semi Auto = false
		SWEP.Primary.Ammo			= "AlyxGun"
		SWEP.AmmoEnt = "item_ammo_revolver_ttt"	
		

		SWEP.Primary.NumShots	= 1		-- How many bullets to shoot per trigger pull
		SWEP.Primary.Damage		= 30	-- Base damage per bullet
		SWEP.Primary.Spread		= .025	-- Define from-the-hip accuracy 1 is terrible, .0001 is exact)
		SWEP.Primary.IronAccuracy = .015
	
		SWEP.Base = "weapon_base"
		SWEP.ViewModel				= ""	-- Weapon view model
		SWEP.WorldModel				= ""
		
SWEP.AdminSpawnable = true
SWEP.AutoSpawnable      = true
SWEP.ViewModelFOV			= 70
SWEP.ViewModelFlip			= false

SWEP.Spawnable				= true
SWEP.AdminSpawnable			= true
SWEP.FiresUnderwater = false

SWEP.Kind = WEAPON_PISTOL
SWEP.WeaponID = AMMO_DEAGLE

		-- pistol, 357, smg1, ar2, buckshot, slam, SniperPenetratedRound, AirboatGun
-- Pistol, buckshot, and slam always ricochet. Use AirboatGun for a light metal peircing shotgun pellets

SWEP.Secondary.IronFOV			= 55		-- How much you 'zoom' in. Less is more! 	

SWEP.data 				= {}				--The starting firemode
 -- Ironsight accuracy, should be the same for shotguns

-- Enter iron sight info and bone mod info below
SWEP.IronSightsPos = Vector (-1.7102, 0, 0.2585)
SWEP.IronSightsAng = Vector (0, 0, 0)
SWEP.SightsPos = Vector (-1.7102, 0, 0.2585)
SWEP.SightsAng = Vector (0, 0, 0)
SWEP.RunSightsPos = Vector(3.444, -7.823, -6.27)
SWEP.RunSightsAng = Vector(60.695, 0, 0)
-- SWEP.RunSightsPos = Vector (-0.3967, 0, 2.2339)
-- SWEP.RunSightsAng = Vector (-17.3454, -2.6248, 0)


end


I keep getting this script error


[ERROR] addons/m9k lua/lua/weapons/m9k_deagle/shared.lua:6: 'end' expected (to close 'if' at line 1) near '='
  1. unknown - addons/m9k lua/lua/weapons/m9k_deagle/shared.lua:0


Replace the first part with this:


if gmod.GetGamemode().Name ~= "Trouble in Terrorist Town" then return end

AddCSLuaFile()

Like this?
Cuz thats not working


if gmod.GetGamemode().Name ~= "Trouble in Terrorist Town" then 
return 
end

AddCSLuaFile()

else
return
-- Variables that are used on both client and server
SWEP.Gun = ("m9k_deagle") -- must be the name of your swep but NO CAPITALS!
SWEP.Category				= "M9K Pistols"
SWEP.Author				= "iron angles and models hexed and converted to gmod my Mr Fokkusu"
SWEP.Contact				= ""
SWEP.Purpose				= ""
SWEP.Instructions				= ""
SWEP.Icon = "vgui/ttt/m9k/icon_m9k_deagle.vmt"
SWEP.MuzzleAttachment			= "1" 	-- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellEjectAttachment			= "2" 	-- Should be "2" for CSS models or "1" for hl2 models
SWEP.PrintName				= "Desert Eagle .40"		-- Weapon name (Shown on HUD)	
SWEP.Slot				= 1				-- Slot in the weapon selection menu
SWEP.SlotPos				= 5			-- Position in the slot
SWEP.DrawAmmo				= true		-- Should draw the default HL2 ammo counter
SWEP.DrawWeaponInfoBox			= false		-- Should draw the weapon info box
SWEP.BounceWeaponIcon   		= 	false	-- Should the weapon icon bounce?
SWEP.DrawCrosshair			= false		-- set false if you want no crosshair
SWEP.Weight				= 3			-- rank relative ot other weapons. bigger is better
SWEP.AutoSwitchTo			= true		-- Auto switch to if we pick it up
SWEP.AutoSwitchFrom			= true		-- Auto switch from if you pick up a better weapon
SWEP.HoldType 				= "pistol"		-- how others view you carrying the weapon
-- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive 
-- you're mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper rifles

		
		SWEP.ViewModel				= "models/weapons/v_tcom_deagle.mdl"	-- Weapon view model
		SWEP.WorldModel				= "models/weapons/w_tcom_deagle.mdl"	-- Weapon world model
		SWEP.Base				= "weapon_tttbase"
		SWEP.Primary.Sound			= Sound("Weapon_TDegle.Single")		-- Script that calls the primary fire sound
		SWEP.Primary.RPM			= 600			-- This is in Rounds Per Minut	e
		SWEP.Primary.ClipSize			= 8		-- Size of a clip
		SWEP.Primary.DefaultClip		= 8		-- Bullets you start with
		SWEP.Primary.ClipMax            = 37    -- Evens shit out
		SWEP.Primary.KickUp				= 1		-- Maximum up recoil (rise)
		SWEP.Primary.KickDown			= 0.5		-- Maximum down recoil (skeet)
		SWEP.Primary.KickHorizontal		= 0.5		-- Maximum up recoil (stock)
		SWEP.Primary.Automatic			= false		-- Automatic = true; Semi Auto = false
		SWEP.Primary.Ammo			= "AlyxGun"
		SWEP.AmmoEnt = "item_ammo_revolver_ttt"	
		

		SWEP.Primary.NumShots	= 1		-- How many bullets to shoot per trigger pull
		SWEP.Primary.Damage		= 30	-- Base damage per bullet
		SWEP.Primary.Spread		= .025	-- Define from-the-hip accuracy 1 is terrible, .0001 is exact)
		SWEP.Primary.IronAccuracy = .015
	
		SWEP.Base = "weapon_base"
		SWEP.ViewModel				= ""	-- Weapon view model
		SWEP.WorldModel				= ""
		
SWEP.AdminSpawnable = true
SWEP.AutoSpawnable      = true
SWEP.ViewModelFOV			= 70
SWEP.ViewModelFlip			= false

SWEP.Spawnable				= true
SWEP.AdminSpawnable			= true
SWEP.FiresUnderwater = false

SWEP.Kind = WEAPON_PISTOL
SWEP.WeaponID = AMMO_DEAGLE

		-- pistol, 357, smg1, ar2, buckshot, slam, SniperPenetratedRound, AirboatGun
-- Pistol, buckshot, and slam always ricochet. Use AirboatGun for a light metal peircing shotgun pellets

SWEP.Secondary.IronFOV			= 55		-- How much you 'zoom' in. Less is more! 	

SWEP.data 				= {}				--The starting firemode
 -- Ironsight accuracy, should be the same for shotguns

-- Enter iron sight info and bone mod info below
SWEP.IronSightsPos = Vector (-1.7102, 0, 0.2585)
SWEP.IronSightsAng = Vector (0, 0, 0)
SWEP.SightsPos = Vector (-1.7102, 0, 0.2585)
SWEP.SightsAng = Vector (0, 0, 0)
SWEP.RunSightsPos = Vector(3.444, -7.823, -6.27)
SWEP.RunSightsAng = Vector(60.695, 0, 0)
-- SWEP.RunSightsPos = Vector (-0.3967, 0, 2.2339)
-- SWEP.RunSightsAng = Vector (-17.3454, -2.6248, 0)


end

[editline]1st April 2015[/editline]

Never Mind. That gun was broken.
Heres the real issue

Im doing it with RDM manager. I only want it to run if the gamemode is TTT. The Files still function, but cant tell its TTT or something. Im not sure whats up.


if gmod.GetGamemode().Name == "Trouble in Terrorist Town" then return end
AddCSLuaFile()
 
surface.CreateFont("DL_RDM_Manager", {
	font = "DermaLarge",
	size = 20
})

surface.CreateFont("DL_Conclusion", {
	font = "DermaLarge",
	size = 18,
	weight = 600
})

surface.CreateFont("DL_ConclusionText", {
	font = "DermaLarge",
	size = 18
})

local function AdjustText(str, font, w)
	surface.SetFont(font)
	local size = surface.GetTextSize(str)
	if size <= w then
		return str
	else
		local last_space
		local i = 0
		for k,v in pairs(string.ToTable(str)) do
			local _w,h = surface.GetTextSize(v)
			i = i + _w
			if i > w then
				local sep = last_space or k
				return string.Left(str, sep), string.Right(str, #str - sep)
			end	
			if v == " " then
				last_space = k
			end
		end
	end
end

local show_finished = CreateClientConVar("rdm_manager_show_finished", "1", FCVAR_ARCHIVE)

cvars.AddChangeCallback("rdm_manager_show_finished", function(name, old, new)
	if Damagelog.CurrentReports and Damagelog.CurrentReports:IsValid() then
		Damagelog.CurrentReports:UpdateAllReports()
	end
	if Damagelog.PreviousReports and Damagelog.PreviousReports:IsValid() then
		Damagelog.PreviousReports:UpdateAllReports()
	end
end)

local status = {
	[RDM_MANAGER_WAITING] = "Waiting",
	[RDM_MANAGER_PROGRESS] = "In progress",
	[RDM_MANAGER_FINISHED] = "Finished",
	[RDM_MANAGER_CANCELED] = "Canceled by the victim"
}

local icons = {
	[RDM_MANAGER_WAITING] = "icon16/clock.png",
	[RDM_MANAGER_PROGRESS] = "icon16/arrow_refresh.png",
	[RDM_MANAGER_FINISHED] = "icon16/accept.png"
}

local colors = {
	[RDM_MANAGER_WAITING] = Color(100,100, 0),
	[RDM_MANAGER_PROGRESS] = Color(0,0,190),
	[RDM_MANAGER_FINISHED] = Color(0,190, 0),
	[RDM_MANAGER_CANCELED] = Color(100, 100, 100)
}

local function GetBySteamID(steamid)
	for k,v in pairs(player.GetAll()) do
		if v:SteamID() == steamid then
			return v
		end
	end
end

local function TakeAction()
	local report = Damagelog.SelectedReport
	if not report then return end
	local current = not report.previous
	local attacker = GetBySteamID(report.attacker)
	local victim = GetBySteamID(report.victim)
	local menuPanel = DermaMenu()
	menuPanel:AddOption("Set conclusion", function()
		if report.status != RDM_MANAGER_FINISHED then
			Damagelog:Notify(DAMAGELOG_NOTIFY_ALERT, "This report is not finished!", 3, "buttons/weapon_cant_buy.wav")
			return
		end
		Derma_StringRequest("Conclusion", "Please write the conclusion for this report", "", function(txt)
			if #txt > 0 and #txt < 200 then
				net.Start("DL_Conclusion")
				net.WriteUInt(0,1)
				net.WriteUInt(report.previous and 1 or 0, 1)
				net.WriteUInt(report.index, 16)
				net.WriteString(txt)
				net.SendToServer()
			end
		end)
	end):SetImage("icon16/comment.png")
	menuPanel:AddOption("Force the reported player to respond", function()
		if IsValid(attacker) then
			net.Start("DL_ForceRespond")
			net.WriteUInt(report.index, 16)
			net.WriteUInt(current and 0 or 1, 1)
			net.SendToServer()
		else
			Derma_Message("The reported player isn't valid! (disconnected?)", "Error", "OK")
		end
	end):SetImage("icon16/clock_red.png")
	menuPanel:AddOption("View Death Scene", function()
		local found = false
		for k,v in pairs(report.logs or {}) do
			if v.type == "KILL" then
				local infos = v.infos
				if infos[6] == report.victim and infos[7] == report.attacker then
					net.Start("DL_AskDeathScene")
					net.WriteUInt(infos[8], 32)
					net.WriteString(report.victim)
					net.WriteString(report.attacker)
					net.SendToServer()
					found = true
					break
				end
			end
		end
		if not found then
			Derma_Message("Could not find the Death Scene", "Error", "OK")
		end
	end):SetImage("icon16/television.png")
	if ulx then
		if Damagelog.Enable_Autoslay then
			local slaynr_pnl = vgui.Create("DMenuOption", menuPanel)
			local slaynr = DermaMenu(menuPanel)
			slaynr:SetVisible(false)
			slaynr_pnl:SetSubMenu(slaynr)
			slaynr_pnl:SetText("Slay next round")
			slaynr_pnl:SetImage("icon16/lightning_go.png")
			menuPanel:AddPanel(slaynr_pnl)
			local function SetConclusion(ply, num, reason)
				net.Start("DL_Conclusion")
				net.WriteUInt(1,1)
				net.WriteUInt(report.previous and 1 or 0, 1)
				net.WriteUInt(report.index, 16)
				net.WriteString("(Auto) "..ply.." slain "..num.." times for "..reason..".")
				net.SendToServer()
			end
			local function AddSlayPlayer(reported)
				local ply_pnl = vgui.Create("DMenuOption", slaynr)
				local ply = DermaMenu(ply_pnl)
				ply:SetVisible(false)
				ply_pnl:SetSubMenu(ply)
				ply_pnl:SetText(reported and "Reported player" or "Victim")
				ply_pnl:SetImage(reported and "icon16/user_delete.png" or "icon16/user.png")
				slaynr:AddPanel(ply_pnl)
				for k,v in ipairs( {"bullet_green.png", "bullet_yellow.png", "bullet_red.png"} )do
					local numbers_pnl = vgui.Create("DMenuOption", ply)
					local numbers = DermaMenu(numbers_pnl)
					numbers:SetVisible(false)
					numbers_pnl:SetSubMenu(numbers)
					numbers_pnl:SetText(k.." times")
					numbers_pnl:SetImage("icon16/"..v)
					ply:AddPanel(numbers_pnl)
					numbers:AddOption("Default reason", function()
						local ply = reported and attacker or victim
						if IsValid(ply) then
							RunConsoleCommand("ulx", "aslay", ply:Nick(), tostring(k))
							SetConclusion(ply:Nick(), k, "the default reason")
						else
							RunConsoleCommand("ulx", "aslayid", reported and report.attacker or report.victim, tostring(k))
							SetConclusion(reported and report.attacker_nick or report.victim_nick, k, "the default reason")
						end
					end):SetImage("icon16/mouse.png")
					numbers:AddOption("Set reason...", function()
						local nick = reported and report.attacker_nick or report.victim_nick
						Derma_StringRequest("Reason", "Please type the reason why you want to slay "..nick, "", function(txt)
							local ply = reported and attacker or victim
							if IsValid(ply) then
								RunConsoleCommand("ulx", "aslay", ply:Nick(), tostring(k), txt)
								SetConclusion(ply:Nick(), k, "\""..txt.."\"")
							else
								RunConsoleCommand("ulx", "aslayid", reported and report.attacker or report.victim, tostring(k), txt)
								SetConclusion(reported and report.attacker_nick or report.victim_nick, k, "\""..txt.."\"")
							end
						end)
					end):SetImage("icon16/page_edit.png")
				end
			end
			AddSlayPlayer(true)
			AddSlayPlayer(false)
		end
		menuPanel:AddOption("Slay the reported player now", function()
			if IsValid(attacker) then
				RunConsoleCommand("ulx", "slay", attacker:Nick())
			else
				Derma_Message("The reported player isn't valid! (disconnected?)", "Error", "OK")
			end
		end):SetImage("icon16/lightning.png")
	end
	menuPanel:Open()
end


local PANEL = {}

function PANEL:Init()
	self:SetMultiSelect(false)
	self:AddColumn("id"):SetFixedWidth(34)
	self:AddColumn("Victim"):SetFixedWidth(105)
	self:AddColumn("Reported player"):SetFixedWidth(105)
	self:AddColumn("Round"):SetFixedWidth(54)
	self:AddColumn("Autoslay status"):SetFixedWidth(135)
	self:AddColumn("Status"):SetFixedWidth(180)
	self.Reports = {}
end

function PANEL:SetOuputs(victim, killer)
	self.VictimOutput = victim
	self.KillerOuput = killer
end

function PANEL:SetReportsTable(tbl)
	self.ReportsTable = tbl
end

function PANEL:GetAttackerSlays(report)
	for k,v in pairs(player.GetAll()) do
		local steamid = v:IsBot() and "BOT" or v:SteamID()
		if steamid == report.attacker then
			local slays = v:GetNWInt("Autoslays_left", 0)
			if tonumber(slays) <= 0 then
				return v:Nick().." not slain"
			else
				return v:Nick().." slain "..slays.." times"
			end
		end
	end
	return "Player not found"
end

function PANEL:GetStatus(report)
	local str = status[report.status]
	if (report.status == RDM_MANAGER_FINISHED or report.status == RDM_MANAGER_PROGRESS) and report.admin then
		str = str.." by "..report.admin
	end
	return str
end

function PANEL:UpdateReport(index)
	local report = self.ReportsTable[index]
	local tbl = {
		report.index,
		report.victim_nick,
		report.attacker_nick,
		report.round or "?",
		self:GetAttackerSlays(report),
		self:GetStatus(report)
	}
	if not self.Reports[index] then
		if report.status != RDM_MANAGER_FINISHED or show_finished:GetBool() then
			self.Reports[index] = self:AddLine(unpack(tbl))
			self.Reports[index].status = report.status
			self.Reports[index].index = report.index
			local tbl = { self.Reports[index] }
			for k,v in ipairs(self.Sorted) do
				if k == #self.Sorted then continue end
				table.insert(tbl, v)
			end
			self.Sorted = tbl
			self:InvalidateLayout()
			self.Reports[index].PaintOver = function(self)
				if self:IsLineSelected() then 
					self.Columns[2]:SetFGColor(color_white)
					self.Columns[3]:SetFGColor(color_white)
					self.Columns[6]:SetFGColor(color_white)
				else
					self.Columns[2]:SetFGColor(Color(0, 190, 0))
					self.Columns[3]:SetFGColor(Color(190, 0, 0))
					self.Columns[6]:SetFGColor(colors[self.status] or color_white)
				end
			end
			self.Reports[index].OnRightClick = function(self)
				TakeAction()
			end
			self.Reports[index].Think = function(pnl)
				self.Reports[pnl.index]:SetValue(5, self:GetAttackerSlays(report))
			end
		else
			self.Reports[index] = false
		end
	else
		self.Reports[index].status = report.status
		self.Reports[index].index = report.index
		if report.status == RDM_MANAGER_FINISHED and not show_finished:GetBool() then
			return self:UpdateAllReports()
		else
			for k,v in ipairs(self.Reports[index].Columns) do
				self.Reports[index]:SetValue(k, tbl[k])
			end
		end
		if report.conclusion then
			local selected = Damagelog.SelectedReport
			if selected and selected.index == report.index and selected.previous == report.previous then
				self.Conclusion:SetText(report.conclusion)
			end
		end
	end
	return self.Reports[index]
end

function PANEL:AddReport(index)
	return self:UpdateReport(index)
end

function PANEL:UpdateAllReports()
	self:Clear()
	table.Empty(self.Reports)
	if not self.ReportsTable then return end
	for i=1, #self.ReportsTable do
		self:AddReport(i)
	end
	if Damagelog.SelectedReport then
		local selected_current = not Damagelog.SelectedReport.Previous
		local current = not self.Previous
		if Damagelog.SelectedReport.status == RDM_MANAGER_FINISHED and not show_finished:GetBool() then
			for k,v in pairs(self.Lines) do
				v:SetSelected(false)
			end
			Damagelog.SelectedReport = nil
			Damagelog:UpdateReportTexts()
		elseif selected_current == current then
			for k,v in pairs(self.Lines) do
				if Damagelog.SelectedReport.index == v.index then
					v:SetSelected(true)
					break
				end
			end
		end
		if Damagelog.SelectedReport then
			local conclusion = Damagelog.SelectedReport.conclusion
			if conclusion then
				self.Conclusion:SetText(conclusion)
			else
				self.Conclusion:SetText("No conclusion for the selected report.")
			end
		end
		Damagelog:UpdateReportTexts()
	end
end

function PANEL:OnRowSelected(index, line)
	Damagelog.SelectedReport = self.ReportsTable[line.index]
	Damagelog:UpdateReportTexts()
	local conclusion = Damagelog.SelectedReport.conclusion
	if conclusion then
		self.Conclusion:SetText(conclusion)
	else
		self.Conclusion:SetText("No conclusion for the selected report.")
	end
	if Damagelog.SelectedReport.previous then
		if Damagelog.CurrentReports:GetSelected()[1] then
			Damagelog.CurrentReports:GetSelected()[1]:SetSelected(false)
		end
	else
		if Damagelog.PreviousReports:GetSelected()[1] then
			Damagelog.PreviousReports:GetSelected()[1]:SetSelected(false)
		end		
	end
end

vgui.Register("RDM_Manager_ListView", PANEL, "DListView")

net.Receive("DL_NewReport", function()
	local tbl = net.ReadTable()
	local index = table.insert(Damagelog.Reports.Current, tbl)
	Damagelog.Reports.Current[index].index = index
	if Damagelog.CurrentReports and Damagelog.CurrentReports:IsValid() then
		Damagelog.CurrentReports:AddReport(index)
	end
end)

net.Receive("DL_UpdateReport", function()
	local previous = net.ReadUInt(1) == 1
	local index = net.ReadUInt(8)
	local updated = net.ReadTable()
	updated.index = index
	if previous then
		Damagelog.Reports.Previous[index] = updated
		if Damagelog.PreviousReports and Damagelog.PreviousReports:IsValid() then
			Damagelog.PreviousReports:UpdateReport(index)
		end
	else
		Damagelog.Reports.Current[index] = updated
		if Damagelog.CurrentReports and Damagelog.CurrentReports:IsValid() then
			Damagelog.CurrentReports:UpdateReport(index)
		end
	end
	if Damagelog.SelectedReport then
		if Damagelog.SelectedReport.index == index and ((not Damagelog.SelectedReport.previous and not previous) or Damagelog.SelectedReport.previous == previous) then
			Damagelog.SelectedReport = updated
		end
	end
end)

net.Receive("DL_UpdateReports", function()
	Damagelog.SelectedReport = nil
	local size = net.ReadUInt(32)
	local data = net.ReadData(size)
	if not data then return end
	local json = util.Decompress(data)
	if not json then return end
	Damagelog.Reports = util.JSONToTable(json)
	if Damagelog.CurrentReports and Damagelog.CurrentReports:IsValid() then
		Damagelog.CurrentReports:UpdateAllReports()
	end	
	if Damagelog.PreviousReports and Damagelog.PreviousReports:IsValid() then
		Damagelog.PreviousReports:UpdateAllReports()
	end		
end)

function Damagelog:DrawRDMManager(x,y)
	if LocalPlayer():CanUseRDMManager() and Damagelog.RDM_Manager_Enabled then
		
		local Manager = vgui.Create("DPanelList");
		Manager:SetSpacing(10)
		
		local Background = vgui.Create("ColoredBox")
		Background:SetHeight(170)
		Background:SetColor(Color(90, 90, 95))
		
		local ReportsSheet = vgui.Create("DPropertySheet", Background)
		ReportsSheet:SetPos(5, 5)
		ReportsSheet:SetSize(630, 160)
		
		self.CurrentReports = vgui.Create("RDM_Manager_ListView")
		self.CurrentReports:SetReportsTable(Damagelog.Reports.Current)
		self.CurrentReports.Previous = false
		ReportsSheet:AddSheet("Reports", self.CurrentReports, "icon16/zoom.png")
		
		self.PreviousReports = vgui.Create("RDM_Manager_ListView")
		self.PreviousReports:SetReportsTable(Damagelog.Reports.Previous)
		self.PreviousReports.Previous = true
		ReportsSheet:AddSheet("Previous map reports", self.PreviousReports, "icon16/world.png")
	
		local ShowFinished = vgui.Create("DCheckBoxLabel", Background)
		ShowFinished:SetText("Show finished reports")
		ShowFinished:SetConVar("rdm_manager_show_finished")
		ShowFinished:SizeToContents()
		ShowFinished:SetPos(235, 7)
	
		local TakeActionB = vgui.Create("DButton", Background)
		TakeActionB:SetText("Take Action")
		TakeActionB:SetPos(380, 4)
		TakeActionB:SetSize(125, 18)
		TakeActionB.Think = function(self)
			self:SetDisabled(not Damagelog.SelectedReport)
		end
		TakeActionB.DoClick = function(self)
			TakeAction()
		end
	
		local SetState = vgui.Create("DButton", Background)
		SetState:SetText("Set Status")
		SetState:SetPos(510, 4)
		SetState:SetSize(125, 18)
		SetState.Think = function(self)
			self:SetDisabled(not Damagelog.SelectedReport)
		end
		SetState.DoClick = function()
			local menu = DermaMenu()
			for k,v in ipairs(status) do
				if k == RDM_MANAGER_CANCELED then continue end
				menu:AddOption(v, function()
					net.Start("DL_UpdateStatus")
					net.WriteUInt(Damagelog.SelectedReport.previous and 1 or 0, 1)
					net.WriteUInt(Damagelog.SelectedReport.index, 16)
					net.WriteUInt(k, 4)
					net.SendToServer()
				end):SetImage(icons[k])
			end
			menu:Open()
		end
		
		Manager:AddItem(Background)
		
		local VictimInfos = vgui.Create("DPanel")
		VictimInfos:SetHeight(110)
		VictimInfos.Paint = function(panel, w, h)
			local bar_height = 27
			surface.SetDrawColor(30, 200, 30);
			surface.DrawRect(0, 0, (w/2), bar_height);
			draw.SimpleText("Victim's report", "DL_RDM_Manager", w/4, bar_height/2, Color(0,0,0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
			surface.SetDrawColor(220, 30, 30);
			surface.DrawRect((w/2)+1, 0, (w/2), bar_height);
			draw.SimpleText("Reported player's response", "DL_RDM_Manager", (w/2) + 1 + (w/4), bar_height/2, Color(0,0,0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
			surface.SetDrawColor(0, 0, 0);
			surface.DrawOutlinedRect(0, 0, w, h);
			surface.DrawLine(w/2, 0, w/2, h);
			surface.DrawLine(0, 27, w, bar_height);
		end
		
		local VictimMessage = vgui.Create("DTextEntry", VictimInfos);
		VictimMessage:SetMultiline(true);
		VictimMessage:SetKeyboardInputEnabled(false);
		VictimMessage:SetPos(1, 27)
		VictimMessage:SetSize(319, 82)
		
		local KillerMessage = vgui.Create("DTextEntry", VictimInfos);
		KillerMessage:SetMultiline(true);
		KillerMessage:SetKeyboardInputEnabled(false);
		KillerMessage:SetPos(319, 27)
		KillerMessage:SetSize(319, 82)
		
		self.CurrentReports:SetOuputs(VictimMessage, KillerMessage)
		self.PreviousReports:SetOuputs(VictimMessage, KillerMessage)

		Manager:AddItem(VictimInfos)
		
		local VictimLogs
		local VictimLogsForm
		
		local Conclusion = vgui.Create("DPanel")
		surface.SetFont("DL_Conclusion")
		local cx,cy = surface.GetTextSize("Conclusion :")
		local cm = 5
		Conclusion.PaintOver = function(panel, w, h)
			if not panel.t1 then return end
			surface.SetDrawColor(color_black)
			surface.DrawLine(0, 0, w-1, 0)
			surface.DrawLine(w-1, 0, w-1, h-1)
			surface.DrawLine(w-1, h-1, 0, h-1)
			surface.DrawLine(0, h-1, 0, 0)
			surface.SetFont("DL_Conclusion")
			surface.SetTextPos(cm, panel.t2 and (h/3 - cy/2) or (h/2 - cy/2))
			surface.SetTextColor(Color(0, 108, 155))
			surface.DrawText("Conclusion : ")
			surface.SetFont("DL_ConclusionText")
			surface.SetTextColor(color_black)
			local tx1, ty1 = surface.GetTextSize(panel.t1)
			surface.SetTextPos(cx + 2*cm, panel.t2 and (h/3 - ty1/2) or h/2 - ty1/2)
			surface.DrawText(panel.t1)
			if panel.t2 then
				local tx2, ty2 = surface.GetTextSize(panel.t2)
				surface.SetTextPos(cm, 2*h/3 - ty2/2)
				surface.DrawText(panel.t2)
			end
		end
		Conclusion.SetText = function(pnl, t)
			pnl.Text = t
			local t1, t2 = AdjustText(t, "DL_ConclusionText", pnl:GetWide() - cx - cm*3)
			pnl.t1 = t1
			pnl.t2 = nil
			if t2 then
				pnl.t2 = t2
				pnl:SetHeight(45)
				KillerMessage:SetHeight(97)
				VictimMessage:SetHeight(97)
				VictimInfos:SetHeight(125)
				if VictimLogs then
					VictimLogs:SetHeight(205)
				end
			else
				pnl:SetHeight(30)
				KillerMessage:SetHeight(82)
				VictimMessage:SetHeight(82)
				VictimInfos:SetHeight(110)
				if VictimLogs then
					VictimLogs:SetHeight(230)
				end
			end
			if VictimLogsForm then
				VictimLogsForm:PerformLayout()
			end
			Manager:PerformLayout()
		end
		Conclusion.SetDefaultText = function(pnl)
			pnl:SetText("No selected report.")
		end
		Conclusion.ApplySchemeSettings = function(pnl)
			if pnl.Text then
				pnl:SetText(pnl.Text)
			end
		end		
		Conclusion:SetHeight(45)
		
		self.CurrentReports.Conclusion = Conclusion
		self.PreviousReports.Conclusion = Conclusion
		
		Manager:AddItem(Conclusion)
		
		VictimLogsForm = vgui.Create("DForm")
		VictimLogsForm.SetExpanded = function() end
		VictimLogsForm:SetName("Logs before victim's death")
	
		VictimLogs = vgui.Create("DListView")
		VictimLogs:AddColumn("Time"):SetFixedWidth(40)
		VictimLogs:AddColumn("Type"):SetFixedWidth(40)
		VictimLogs:AddColumn("Event"):SetFixedWidth(539)
		VictimLogs:SetHeight(230)
		
		Damagelog.UpdateReportTexts = function()
			local selected = Damagelog.SelectedReport
			if not selected then
				VictimMessage:SetText("")
				KillerMessage:SetText("")
			else
				VictimMessage:SetText(selected.message)
				KillerMessage:SetText(selected.response or "No response yet")
			end
			VictimLogs:Clear()
			if selected and selected.logs then
				Damagelog:SetListViewTable(VictimLogs, selected.logs, false)
			end
		end
		
		VictimLogsForm:AddItem(VictimLogs)
	
		Manager:AddItem(VictimLogsForm)
		
		self.Tabs:AddSheet("RDM Manager", Manager, "icon16/magnifier.png", false, false)	
		
		Conclusion:SetDefaultText()
		self.CurrentReports:UpdateAllReports()
		self.PreviousReports:UpdateAllReports()
	end
end




[editline]1st April 2015[/editline]

Heres the Script Errors

[ERROR] addons/tttdamagelogs-master/lua/damagelogs/cl_damagelog.lua:121: attempt to call method ‘DrawRDMManager’ (a nil value)

  1. OpenMenu - addons/tttdamagelogs-master/lua/damagelogs/cl_damagelog.lua:121
  2. Think - addons/tttdamagelogs-master/lua/damagelogs/cl_damagelog.lua:142
    3. fn - addons/tttdamagelogs-master/lua/damagelogs/cl_damagelog.lua:157
    4. unknown - addons/ulib/lua/ulib/shared/hook.lua:105

That error is not from the same file

Yea! I know, but they are happening because the gmod.GetGamemode isnt working. when I put what you said into the file, It does do something, but that something is not get the gamemode and if the gamemode is “Trouble in Terrorist Town” then run the file.

Ive been doing this to a few lua files, including sweps and other addons. This isnt working, All I need is a line of code that will get the gamemode and if the gamemode is TTT terrortown or Trouble in Terrorist Town then run the addon, If not then dont run the addon.

My current test is with the GTA 5 Death Screen. When you die it pastes a Wasted on the screen and plays a sound file. When I don’t have that line of code the file works fine, but when I add the code, the file doesn’t work at all, no lua errors from that specific file, nothing. As if the file isn’t recognizing that the game mode is TTT. Any suggestions?

"if gmod.GetGamemode().Name ~= “Trouble in Terrorist Town” then return end

AddCSLuaFile()"

PS: I am not adding anything to these files other than the line of code you provided me with. I can send whatever you need if you dont have enough information about what im dealing with. I am using a server provider, not hosting it myself. Also I am using FileZilla for FTP. The only plugins I am doing this too are GTA Death Screen, and a few sweps, as well as TTT RDM manager

Remove the AddCSLuaFile() in that file. Put


if gmod.GetGamemode().Name == "Trouble in Terrorist Town" then return end

At the top of all of the RDM manager files.

What files am I supposed to put this on? I put it on all of them and It didnt work, I put it on just the autorun and that didnt work. What do I put it on? Any specific files? Its not working for Sweps or my GTA Death.

I seriously appologise for this, I am having some serious issues making this work, apparently this is supposed to be an easy fix, but im having problems for some reason.

Also I keep getting this

[ERROR] addons/tttdamagelogs-master/lua/autorun/damagelog_autorun.lua:1: attempt to index a nil value

  1. unknown - addons/tttdamagelogs-master/lua/autorun/damagelog_autorun.lua:1

So Idk what that means nil Values

That’s probably because the name is trying to be accessed before it’s valid. Honestly, it would just be easier to do this in a single include file; I don’t know the structure of the addon, but doing it file-by-file just causes more errors