• Multi Gamemode Server Issues (GMOD)
    13 replies, posted
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 :)
[QUOTE=fixgameagain;47425276] [code]if !gmod.GetGamemode()["Name"] == "Trouble in Terrorist Town" then return end[/code][/QUOTE] FOR F**KS SAKE! Again with this shit. It's [code] if a ~= b then [/code] and NOT [code] if !a == b then [/code] For those who actually care: first one parses as [i]not(a) == b[/i] and [i]not(X)[/i] for any X that's not [i]false[/i] or [i]nil[/i] will give [b]false[/b], so you get [i]false == b[/i] which is not what you want.
[QUOTE=mijyuoon;47426542]FOR F**KS SAKE! Again with this shit. It's [code] if a ~= b then [/code] and NOT [code] if !a == b then [/code] For those who actually care: first one parses as [i]not(a) == b[/i] and [i]not(X)[/i] for any X that's not [i]false[/i] or [i]nil[/i] will give [b]false[/b], so you get [i]false == b[/i] which is not what you want.[/QUOTE] 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 [CODE]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[/CODE] [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 [CODE]if gmod.GetGamemode()["Name"] ~= "Trouble in Terrorist Town" then else return //Code end [/CODE] Then I tried [CODE]if gmod.GetGamemode()["Name"] ~= "Trouble in Terrorist Town" then else //Code return end [/CODE] As well as [CODE]if gmod.GetGamemode()["Name"] == "Trouble in Terrorist Town" then //Code return end [/CODE] And [CODE]if gmod.GetGamemode()["Name"] == "Trouble in Terrorist Town" then return //code end [/CODE] 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 [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 [/CODE] I keep getting this script error [CODE][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 [/CODE]
Replace the first part with this: [code]if gmod.GetGamemode().Name ~= "Trouble in Terrorist Town" then return end AddCSLuaFile()[/code]
[QUOTE=code_gs;47431365]Replace the first part with this: [code]if gmod.GetGamemode().Name ~= "Trouble in Terrorist Town" then return end AddCSLuaFile()[/code][/QUOTE] Like this? Cuz thats not working [CODE]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[/CODE] [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. [CODE]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 fi
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 [code]if gmod.GetGamemode().Name == "Trouble in Terrorist Town" then return end[/code] 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
Sorry, you need to Log In to post a reply to this thread.