Welcome, Guest. Please login or register.
Did you miss your activation email?
November 24, 2024, 10:21:21 AM
Home Help Login Register
News: Zombie Master 2 discussion

Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Adding SWeps to the TTT weapon Placer
Pages: [1]
Author Topic: Adding SWeps to the TTT weapon Placer  (Read 10829 times)
nrich588
Poster

Posts: 253

WzG Owner


« on: December 06, 2011, 10:23:34 PM »

I've seen people with custom weapons in the TTT weapon placer, anyone wanna help me out?
BipolarDiZ
Poster

Posts: 101


|:NxS:| Staff! :D


« Reply #1 on: December 06, 2011, 11:22:28 PM »

It is pretty simple really. All you have to do is modify the stools lua file to include your weapons so I guess I will just make an example. (I spent 5 secs on this before work so not sure if it's everything needed to be changed.

All I saw to add was the new weapons to the list. See if that works. If it doesn't I will spend more time after work.

TOOL.Category = "Trouble in Terrorist Town"
TOOL.Name = "TTT Weapon Placer"
TOOL.Command = nil
TOOL.ConfigName = ""

TOOL.ClientConVar["weapon"] = "weapon_zm_pistol"
TOOL.ClientConVar["frozen"] = "0"
TOOL.ClientConVar["replacespawns"] = "0"


cleanup.Register("ttt_weapons")


if CLIENT then
  language.Add( "Tool_tttweaponplacer_name", "TTT Weapon Placer" )
  language.Add( "Tool_tttweaponplacer_desc", "Spawn TTT weapon dummies and export their placement" )
  language.Add( "Tool_tttweaponplacer_0", "Left click to spawn entity. Right click for matching ammo." )
  language.Add("Cleanup_ttt_weapons", "TTT Dummy Weapons/ammo/spawns")
end

local weps = {
  weapon_zm_pistol = {name="Pistol", snd="item_ammo_pistol_ttt"},
  weapon_zm_shotgun = {name="Shotgun", snd="item_box_buckshot_ttt"},
  weapon_zm_mac10 = {name="MAC10", snd="item_ammo_smg1_ttt"},
  weapon_zm_revolver = {name="Deagle", snd="item_ammo_revolver_ttt"},
  weapon_zm_rifle = {name="Rifle", snd="item_ammo_357_ttt"},
  weapon_zm_sledge = {name="HUGE249", snd=nil},
  weapon_ttt_m16 = {name="M16", snd="item_ammo_pistol_ttt"},
  weapon_ttt_glock = {name="Glock", snd="item_ammo_pistol_ttt"},
 
  weapon_zm_molotov = {name="Fire nade", snd=nil},
  weapon_ttt_confgrenade = {name="Discombobulator", snd=nil},
  weapon_ttt_smokegrenade = {name="Smoke nade", snd=nil},
 
  weapon_ttt_customweapon = {name="Custom Weapon", snd=Ammo Type},


  ttt_random_weapon = {name="Random weapon", snd=nil},
  ttt_random_ammo = {name="Random ammo", snd=nil},

  ttt_playerspawn = {name="Player spawn", snd=nil}
 
}

local mdls = {
  weapon_zm_pistol = "models/weapons/w_pist_fiveseven.mdl",
  weapon_zm_shotgun = "models/weapons/w_shot_xm1014.mdl",
  weapon_zm_mac10 = "models/weapons/w_smg_mac10.mdl",
  weapon_zm_revolver = "models/weapons/w_pist_deagle.mdl",
  weapon_zm_rifle = "models/weapons/w_snip_scout.mdl",
  weapon_zm_sledge = "models/weapons/w_mach_m249para.mdl",
  weapon_zm_molotov = "models/weapons/w_eq_flashbang.mdl",
 
  weapon_ttt_confgrenade = "models/weapons/w_eq_fraggrenade.mdl",
  weapon_ttt_smokegrenade = "models/weapons/w_eq_smokegrenade.mdl",
  weapon_ttt_m16 = "models/weapons/w_rif_m4a1.mdl",
  weapon_ttt_glock = "models/weapons/w_pist_glock18.mdl",
 
  weapon_ttt_customweapon = "yourweaponsmodel",

  ttt_random_weapon = "models/weapons/w_shotgun.mdl",
  ttt_random_ammo = "models/Items/battery.mdl",

  item_ammo_pistol_ttt= "models/items/boxsrounds.mdl",
  item_ammo_smg1_ttt= "models/items/boxmrounds.mdl",
  item_ammo_revolver_ttt = "models/items/357ammo.mdl",
  item_ammo_357_ttt = "models/items/357ammo.mdl",
  item_box_buckshot_ttt = "models/items/boxbuckshot.mdl",

  ttt_playerspawn = "models/player.mdl"
};

« Last Edit: December 06, 2011, 11:23:51 PM by BipolarDiZ »

BipolarDiZ is bipolar.
|:NxS:| Custom TTT Server: source.nxs-gaming.com:27015
|:NxS:| Vanilla TTT Server: source.nxs-gaming.com:27016
|:NxS:| Fretta: currently offline
nrich588
Poster

Posts: 253

WzG Owner


« Reply #2 on: December 07, 2011, 01:03:44 AM »

Hmmmm... it gave me this

e 'sandbox' derived from 'base'
[addons\tttweapons\lua\weapons\gmod_tool\stools\tttweaponplacer.lua:31] '}' expected (to close '{' at line 21) near 'weapon_ttt_aug'


in console.



TOOL.Category = "Trouble in Terrorist Town"
TOOL.Name = "TTT Weapon Placer"
TOOL.Command = nil
TOOL.ConfigName = ""

TOOL.ClientConVar["weapon"] = "weapon_zm_pistol"
TOOL.ClientConVar["frozen"] = "0"
TOOL.ClientConVar["replacespawns"] = "0"


cleanup.Register("ttt_weapons")


if CLIENT then
  language.Add( "Tool_tttweaponplacer_name", "TTT Weapon Placer" )
  language.Add( "Tool_tttweaponplacer_desc", "Spawn TTT weapon dummies and export their placement" )
  language.Add( "Tool_tttweaponplacer_0", "Left click to spawn entity. Right click for matching ammo." )
  language.Add("Cleanup_ttt_weapons", "TTT Dummy Weapons/ammo/spawns")
end

local weps = {
  weapon_zm_pistol = {name="Pistol", snd="item_ammo_pistol_ttt"},
  weapon_zm_shotgun = {name="Shotgun", snd="item_box_buckshot_ttt"},
  weapon_zm_mac10 = {name="MAC10", snd="item_ammo_smg1_ttt"},
  weapon_zm_revolver = {name="Deagle", snd="item_ammo_revolver_ttt"},
  weapon_zm_rifle = {name="Rifle", snd="item_ammo_357_ttt"},
  weapon_zm_sledge = {name="HUGE249", snd=nil},
  weapon_ttt_m16 = {name="M16", snd="item_ammo_pistol_ttt"},
  weapon_ttt_glock = {name="Glock", snd="item_ammo_pistol_ttt"},
  weapon_ttt_ak47 = {name="AK47", snd="item_ammo_pistol_ttt"}
  weapon_ttt_aug = {name="AUG", snd="item_ammo_smg1_ttt"}
  weapon_ttt_galil = {name="Galil", snd="item_ammo_sm1_ttt"}
  weapon_ttt_famas = {name="Famas", snd="item_ammo_sm1_ttt"}
  weapon_ttt_m3 = {name="m3", snd="item_ammo_buckshot_ttt"}
  weapon_ttt_sg552 = {name="SG552", snd="item_ammo_sm1_ttt"}
  weapon_ttt_mp5 = {name="MP5", snd="item_ammo_pistol_ttt"}
  weapon_ttt_p90 = {name="P90", snd="item_ammo_sm1_ttt"}
     
 

  weapon_zm_molotov = {name="Fire nade", snd=nil},
  weapon_ttt_confgrenade = {name="Discombobulator", snd=nil},
  weapon_ttt_customweapon = {name="Custom Weapon", snd=Ammo Type},


  ttt_random_weapon = {name="Random weapon", snd=nil},
  ttt_random_ammo = {name="Random ammo", snd=nil},

  ttt_playerspawn = {name="Player spawn", snd=nil}
 
}

local mdls = {
  weapon_zm_pistol = "models/weapons/w_pist_fiveseven.mdl",
  weapon_zm_shotgun = "models/weapons/w_shot_xm1014.mdl",
  weapon_zm_mac10 = "models/weapons/w_smg_mac10.mdl",
  weapon_zm_revolver = "models/weapons/w_pist_deagle.mdl",
  weapon_zm_rifle = "models/weapons/w_snip_scout.mdl",
  weapon_zm_sledge = "models/weapons/w_mach_m249para.mdl",
  weapon_zm_molotov = "models/weapons/w_eq_flashbang.mdl",
 
 
  weapon_ttt_confgrenade = "models/weapons/w_eq_fraggrenade.mdl",
  weapon_ttt_smokegrenade = "models/weapons/w_eq_smokegrenade.mdl",
  weapon_ttt_m16 = "models/weapons/w_rif_m4a1.mdl",
  weapon_ttt_glock = "models/weapons/w_pist_glock18.mdl",
  weapon_ttt_ak47 = "models/weapons/w_rif_ak47.mdl"
 
  weapon_ttt_aug = "models/weapons/w_rif_aug.mdl"
  weapon_ttt_galil = "models/weapons/w_rif_galil.mdl"
  weapon_ttt_famas = "models/weapons/w_rif_famas.mdl"
  weapon_ttt_m3 = "models/weapons/w_shot_m3super90.mdl"
  weapon_ttt_sg552 = "models/weapons/w_rif_sg552.mdl"
  weapon_ttt_mp5 = "models/weapons/w_smg_mp5.mdl"
  weapon_ttt_p90 = "models/weapons/w_smg_p90.mdl"
 
  weapon_ttt_customweapon = "yourweaponsmodel",

  ttt_random_weapon = "models/weapons/w_shotgun.mdl",
  ttt_random_ammo = "models/Items/battery.mdl",

  item_ammo_pistol_ttt= "models/items/boxsrounds.mdl",
  item_ammo_smg1_ttt= "models/items/boxmrounds.mdl",
  item_ammo_revolver_ttt = "models/items/357ammo.mdl",
  item_ammo_357_ttt = "models/items/357ammo.mdl",
  item_box_buckshot_ttt = "models/items/boxbuckshot.mdl",

  ttt_playerspawn = "models/player.mdl"
};


BipolarDiZ
Poster

Posts: 101


|:NxS:| Staff! :D


« Reply #3 on: December 07, 2011, 10:41:57 AM »

Ahhhhhhhhhhh YOU MADE A BOO BOOO! :D

Look at like 30 and compare it to 29. Here is the code.

29  weapon_ttt_glock = {name="Glock", snd="item_ammo_pistol_ttt"},
30  weapon_ttt_ak47 = {name="AK47", snd="item_ammo_pistol_ttt"}
31  weapon_ttt_aug = {name="AUG", snd="item_ammo_smg1_ttt"}

If you get the answer you get a cookie! :D No but for real if you fix that it should fix your issue. At least the lua error you posted.

BipolarDiZ is bipolar.
|:NxS:| Custom TTT Server: source.nxs-gaming.com:27015
|:NxS:| Vanilla TTT Server: source.nxs-gaming.com:27016
|:NxS:| Fretta: currently offline
Anonymous
Poster

Posts: 126


« Reply #4 on: December 07, 2011, 04:33:29 PM »

Hahahaha,    *hint* *hint*

sniperduck
Poster

Posts: 178


|:NxS:| Staff! :D


« Reply #5 on: December 07, 2011, 08:19:05 PM »

I want a cookie, milk, and a bed time story, < more hints

Overtime these forums have made me an asshole. ;D (TTT subforum)
|:NxS:| Custom TTT Server: source.nxs-gaming.com:27016
|:NxS:| Vanilla TTT Server: source.nxs-gaming.com:27016
|:NxS:| Fretta: <COMING SOON>
nrich588
Poster

Posts: 253

WzG Owner


« Reply #6 on: December 07, 2011, 08:42:31 PM »

I fixed that issue, added commas and it all looks good except when I export it the map is all fucked up and nothing works. No lua errors in console. Just no guns spawn or ammo besides pistol ammo and five-sevens
BipolarDiZ
Poster

Posts: 101


|:NxS:| Staff! :D


« Reply #7 on: December 07, 2011, 10:34:22 PM »

Okay I will work on the swep placer for a bit and repost when I personnally get it working. BRB.

Edit> Havent tested it yet but I found this toward the bottom,

local enttypes = {
  weapon_zm_pistol = WEAPON_PISTOL,
  weapon_zm_revolver = WEAPON_PISTOL,
  weapon_ttt_glock = WEAPON_PISTOL,

  weapon_zm_mac10 = WEAPON_HEAVY,
  weapon_zm_shotgun = WEAPON_HEAVY,
  weapon_zm_rifle = WEAPON_HEAVY,
  weapon_zm_sledge = WEAPON_HEAVY,
  weapon_ttt_m16 = WEAPON_HEAVY,
  weapon_ttt_aug = WEAPON_HEAVY,

  weapon_zm_molotov = WEAPON_NADE,
  weapon_ttt_smokegrenade = WEAPON_NADE,
  weapon_ttt_confgrenade = WEAPON_NADE,

  ttt_random_weapon = WEAPON_RANDOM,

  ttt_playerspawn = PLAYERSPAWN
};


I added the aug obviously.

EDITv2> I got the script to work perfectly. Here it is with the aug added. Just so you know I did nothing dif than what I told you to do really except that edit ^^^


TOOL.Category = "Trouble in Terrorist Town"
TOOL.Name = "TTT Weapon Placer"
TOOL.Command = nil
TOOL.ConfigName = ""

TOOL.ClientConVar["weapon"] = "weapon_zm_pistol"
TOOL.ClientConVar["frozen"] = "0"
TOOL.ClientConVar["replacespawns"] = "0"


cleanup.Register("ttt_weapons")


if CLIENT then
  language.Add( "Tool_tttweaponplacer_name", "TTT Weapon Placer" )
  language.Add( "Tool_tttweaponplacer_desc", "Spawn TTT weapon dummies and export their placement" )
  language.Add( "Tool_tttweaponplacer_0", "Left click to spawn entity. Right click for matching ammo." )
  language.Add("Cleanup_ttt_weapons", "TTT Dummy Weapons/ammo/spawns")
end

local weps = {
  weapon_zm_pistol = {name="Pistol", snd="item_ammo_pistol_ttt"},
  weapon_zm_shotgun = {name="Shotgun", snd="item_box_buckshot_ttt"},
  weapon_zm_mac10 = {name="MAC10", snd="item_ammo_smg1_ttt"},
  weapon_zm_revolver = {name="Deagle", snd="item_ammo_revolver_ttt"},
  weapon_zm_rifle = {name="Rifle", snd="item_ammo_357_ttt"},
  weapon_zm_sledge = {name="HUGE249", snd=nil},
  weapon_ttt_m16 = {name="M16", snd="item_ammo_pistol_ttt"},
  weapon_ttt_glock = {name="Glock", snd="item_ammo_pistol_ttt"},
  weapon_ttt_aug = {name="AUG", snd="item_ammo_pistol_ttt"},
 
  weapon_zm_molotov = {name="Fire nade", snd=nil},
  weapon_ttt_confgrenade = {name="Discombobulator", snd=nil},
  weapon_ttt_smokegrenade = {name="Smoke nade", snd=nil},


  ttt_random_weapon = {name="Random weapon", snd=nil},
  ttt_random_ammo = {name="Random ammo", snd=nil},

  ttt_playerspawn = {name="Player spawn", snd=nil}
}

local mdls = {
  weapon_zm_pistol = "models/weapons/w_pist_fiveseven.mdl",
  weapon_zm_shotgun = "models/weapons/w_shot_xm1014.mdl",
  weapon_zm_mac10 = "models/weapons/w_smg_mac10.mdl",
  weapon_zm_revolver = "models/weapons/w_pist_deagle.mdl",
  weapon_zm_rifle = "models/weapons/w_snip_scout.mdl",
  weapon_zm_sledge = "models/weapons/w_mach_m249para.mdl",
  weapon_zm_molotov = "models/weapons/w_eq_flashbang.mdl",
  weapon_ttt_aug = "models/weapons/v_rif_aug.mdl",
 
  weapon_ttt_confgrenade = "models/weapons/w_eq_fraggrenade.mdl",
  weapon_ttt_smokegrenade = "models/weapons/w_eq_smokegrenade.mdl",
  weapon_ttt_m16 = "models/weapons/w_rif_m4a1.mdl",
  weapon_ttt_glock = "models/weapons/w_pist_glock18.mdl",

  ttt_random_weapon = "models/weapons/w_shotgun.mdl",
  ttt_random_ammo = "models/Items/battery.mdl",

  item_ammo_pistol_ttt= "models/items/boxsrounds.mdl",
  item_ammo_smg1_ttt= "models/items/boxmrounds.mdl",
  item_ammo_revolver_ttt = "models/items/357ammo.mdl",
  item_ammo_357_ttt = "models/items/357ammo.mdl",
  item_box_buckshot_ttt = "models/items/boxbuckshot.mdl",

  ttt_playerspawn = "models/player.mdl"
};

-- special colours for certain ents
local colors = {
  ttt_random_weapon = Color(255, 255, 0),
  ttt_random_ammo = Color(0, 255, 0),
  item_ammo_revolver_ttt = Color(255, 100, 100),
  ttt_playerspawn = Color(0, 255, 0)
};

local function DummyInit(s)
  if colors[s:GetClass()] then
      local c = colors[s:GetClass()]
      s:SetColor(c.r, c.g, c.b, 255)
  end

  s:SetCollisionGroup(COLLISION_GROUP_WEAPON)
  s:SetSolid(SOLID_VPHYSICS)
  s:SetMoveType(MOVETYPE_VPHYSICS)

  if s:GetClass() == "ttt_playerspawn" then
      s:PhysicsInitBox(Vector(-18, -18, 0), Vector(18, 18, 66))
  else
      s:PhysicsInit(SOLID_VPHYSICS)
  end
 
  s:SetModel(s.Model)
end

for cls, mdl in pairs(mdls) do
  local tbl = {
      Type = "anim",
      Model = Model(mdl),
      Initialize = DummyInit
  };

  scripted_ents.Register(tbl, cls, false)
end

function TOOL:SpawnEntity(cls, trace)
  local mdl = mdls[cls]

  if not cls or not mdl then return end

  local ent = ents.Create(cls)
  ent:SetModel(mdl)
  ent:SetPos(trace.HitPos)

  local tr = util.TraceEntity({start=trace.StartPos, endpos=trace.HitPos, filter=self:GetOwner()}, ent)
  if tr.Hit then
      ent:SetPos(tr.HitPos)
  end

  ent:Spawn()

  ent:PhysWake()

  undo.Create("TTTWeapon")
  undo.AddEntity(ent)
  undo.SetPlayer(self:GetOwner())
  undo.Finish()

  self:GetOwner():AddCleanup("ttt_weapons", ent)
end

function TOOL:LeftClick( trace )
  local cls = self:GetClientInfo("weapon")

  self:SpawnEntity(cls, trace)
end

function TOOL:RightClick( trace )
  local cls = self:GetClientInfo("weapon")
  local info = weps[cls]
  if not info then return end

  local ammo = info.snd
  if not ammo then
      self:GetOwner():ChatPrint("No matching ammo for this type!")
      return
  end

  self:SpawnEntity(info.snd, trace)
end

function TOOL.BuildCPanel(panel) -- note that this is not a method, REAL NICE
  panel:AddControl( "Header", { Text = "#Tool_tttweaponplacer_name", Description = "#Tool_tttweaponplacer_desc"})

  local opts = {}
  for w, info in pairs(weps) do
      opts[info.name] = {tttweaponplacer_weapon = w}
  end

  panel:AddControl("ListBox", { Label = "Weapons", Height = "200", Options = opts } )

  panel:AddControl("Button", {Label="Report counts", Command="tttweaponplacer_count", Text="Count"})

  panel:AddControl("Label", {Text="Export", Description="Export weapon placements"})

  panel:AddControl("CheckBox", {Label="Replace existing player spawnpoints", Command="tttweaponplacer_replacespawns", Text="Replace spawns"})

  panel:AddControl( "Button",  { Label = "Export to file", Command = "tttweaponplacer_queryexport", Text = "Export"})

  panel:AddControl("Label", {Text="Import", Description="Import weapon placements"})

  panel:AddControl( "Button",  { Label = "Import from file", Command = "tttweaponplacer_queryimport", Text = "Import"})

  panel:AddControl("Button", {Label="Convert HL2 entities", Command = "tttweaponplacer_replacehl2", Text="Convert"})

  panel:AddControl("Button", {Label="Remove all existing weapon/ammo", Command = "tttweaponplacer_removeall", Text="Remove all existing items"})
end

-- STOOLs not being loaded on client = headache bonanza
if CLIENT then
  function QueryFileExists()

      local map = string.lower(game.GetMap())
      if not map then return end

      local fname = "ttt/maps/" .. map .. "_ttt.txt"

      if file.Exists(fname) then
        Derma_StringRequest("File exists", "The file \"" .. fname .. "\" already exists. Save under a different filename? Leave unchanged to overwrite.",
                            fname,
                            function(txt)
                                RunConsoleCommand("tttweaponplacer_export", txt)
                            end)
      else
        RunConsoleCommand("tttweaponplacer_export")
      end
  end

  function QueryImportName()
      local map = string.lower(game.GetMap())
      if not map then return end

      local fname = "ttt/maps/" .. map .. "_ttt.txt"

      Derma_StringRequest("Import", "What file do you want to import? Note that files meant for other maps will result in crazy things happening.",
                          fname,
                          function(txt)
                            RunConsoleCommand("tttweaponplacer_import", txt)
                          end)
     
  end
else
  -- again, hilarious things happen when this shit is used in mp
  concommand.Add("tttweaponplacer_queryexport", function() BroadcastLua("QueryFileExists()") end)
  concommand.Add("tttweaponplacer_queryimport", function() BroadcastLua("QueryImportName()") end)
end

WEAPON_PISTOL = 1
WEAPON_HEAVY = 2
WEAPON_NADE = 3
WEAPON_RANDOM = 4

PLAYERSPAWN = 5

local enttypes = {
  weapon_zm_pistol = WEAPON_PISTOL,
  weapon_zm_revolver = WEAPON_PISTOL,
  weapon_ttt_glock = WEAPON_PISTOL,

  weapon_zm_mac10 = WEAPON_HEAVY,
  weapon_zm_shotgun = WEAPON_HEAVY,
  weapon_zm_rifle = WEAPON_HEAVY,
  weapon_zm_sledge = WEAPON_HEAVY,
  weapon_ttt_m16 = WEAPON_HEAVY,
  weapon_ttt_aug = WEAPON_HEAVY,

  weapon_zm_molotov = WEAPON_NADE,
  weapon_ttt_smokegrenade = WEAPON_NADE,
  weapon_ttt_confgrenade = WEAPON_NADE,

  ttt_random_weapon = WEAPON_RANDOM,

  ttt_playerspawn = PLAYERSPAWN
};

local function PrintCount(ply)
  local count = {
      [WEAPON_PISTOL] = 0,
      [WEAPON_HEAVY] = 0,
      [WEAPON_NADE] = 0,
      [WEAPON_RANDOM] = 0,
      [PLAYERSPAWN] = 0
  };

  for cls, t in pairs(enttypes) do
      for _, ent in pairs(ents.FindByClass(cls)) do
        count[t] = count[t] + 1
      end
  end

  ply:ChatPrint("Entity count (use report_entities in console for more detail):")
  ply:ChatPrint("Primary weapons: " .. count[WEAPON_HEAVY])
  ply:ChatPrint("Secondary weapons: " .. count[WEAPON_PISTOL])
  ply:ChatPrint("Grenades: " .. count[WEAPON_NADE])
  ply:ChatPrint("Random weapons: " .. count[WEAPON_RANDOM])
  ply:ChatPrint("Player spawns: " .. count[PLAYERSPAWN])
end
concommand.Add("tttweaponplacer_count", PrintCount)

-- This shit will break terribly in MP
if SERVER or CLIENT then
  -- Could just do a GLON dump, but it's nice if the "scripts" are sort of
  -- human-readable so it's easy to go in and delete all pistols or something.
  local function Export(ply, cmd, args)
      if not IsValid(ply) then return end

      local map = string.lower(game.GetMap())

      if not map then return end

      --local frozen_only = GetConVar("tttweaponplacer_frozen"):GetBool()
      local frozen_only = false

      -- Nice header, # is comment
      local buf =  "# Trouble in Terrorist Town weapon/ammo placement overrides\n"
      buf = buf .. "# For map: " .. map .. "\n"
      buf = buf .. "# Exported by: " .. ply:Nick() .. "\n"

      -- Write settings ("setting: <name> <value>")
      local rspwns = GetConVar("tttweaponplacer_replacespawns"):GetBool() and "1" or "0"
      buf = buf .. "setting:\treplacespawns " .. rspwns .. "\n"

      local num = 0
      for cls, mdl in pairs(mdls) do
        for _, ent in pairs(ents.FindByClass(cls)) do
            if IsValid(ent) then
              if not frozen_only or not ent:GetPhysicsObject():IsMoveable() then
                  num = num + 1
                  buf = buf .. Format("%s\t%s\t%s\n", cls, tostring(ent:GetPos()), tostring(ent:GetAngles()))
              end
            end
        end
      end

      local fname = "ttt/maps/" .. map .. "_ttt.txt"

      if args[1] then
        fname = args[1]
      end
     
      file.Write(fname, buf)

      if not file.Exists(fname) then
        ErrorNoHalt("Exported file not found. Bug?\n")
      end

      ply:ChatPrint(num .. " placements saved to /garrysmod/data/" .. fname)
  end
  concommand.Add("tttweaponplacer_export", Export)

  local function SpawnDummyEnt(cls, pos, ang)
      if not cls or not pos or not ang then return false end

      local mdl = mdls[cls]
      if not mdl then return end

      local ent = ents.Create(cls)
      ent:SetModel(mdl)
      ent:SetPos(pos)
      ent:SetAngles(ang)
      ent:SetCollisionGroup(COLLISION_GROUP_WEAPON)
      ent:SetSolid(SOLID_VPHYSICS)
      ent:SetMoveType(MOVETYPE_VPHYSICS)
      ent:PhysicsInit(SOLID_VPHYSICS)
     
      ent:Spawn()

      local phys = ent:GetPhysicsObject()
      if IsValid(phys) then
        phys:SetAngle(ang)
      end
  end


  local function Import(ply, cmd, args)
      if not IsValid(ply) then return end
      local map = string.lower(game.GetMap())
      if not map then return end

      local fname = "ttt/maps/" .. map .. "_ttt.txt"

      if args[1] then
        fname = args[1]
      end

      if not file.Exists(fname) then
        ply:ChatPrint(fname .. " not found!")
        return
      end

      local buf = file.Read(fname)
      local lines = string.Explode("\n", buf)
      local num = 0
      for k, line in ipairs(lines) do
        if not string.match(line, "^#") and line != "" then
            local data = string.Explode("\t", line)

            local fail = true -- pessimism

            if #data > 0 then
              if data[1] == "setting:" and tostring(data[2]) then
                  local raw = string.Explode(" ", data[2])
                  RunConsoleCommand("tttweaponplacer_" .. raw[1], tonumber(raw[2]))

                  fail = false
                  num = num - 1
              elseif #data == 3 then
                  local cls = data[1]
                  local ang = nil
                  local pos = nil
                 
                  local posraw = string.Explode(" ", data[2])
                  pos = Vector(tonumber(posraw[1]), tonumber(posraw[2]), tonumber(posraw[3]))

                  local angraw = string.Explode(" ", data[3])
                  ang = Angle(tonumber(angraw[1]), tonumber(angraw[2]), tonumber(angraw[3]))

                  fail = SpawnDummyEnt(cls, pos, ang)
              end
            end

            if fail then
              ErrorNoHalt("Invalid line " .. k .. " in " .. fname .. "\n")
            else
              num = num + 1
            end
        end
      end

      ply:ChatPrint("Spawned " .. num .. " dummy ents")
  end
  concommand.Add("tttweaponplacer_import", Import)

  local function RemoveAll(ply, cmd, args)
      if not IsValid(ply) then return end

      local num = 0
      local delete = function(ent)
                        if not IsValid(ent) then return end
                        print("\tRemoving", ent, ent:GetClass())
                        ent:Remove()
                        num = num + 1
                    end

      print("Removing ammo...")
      for k, ent in pairs(ents.FindByClass("item_*")) do
        delete(ent)
      end

      print("Removing weapons...")
      for k, ent in pairs(ents.FindByClass("weapon_*")) do
        delete(ent)
      end

      ply:ChatPrint("Removed " .. num .. " weapon/ammo ents")
  end
  concommand.Add("tttweaponplacer_removeall", RemoveAll)

  local hl2_replace = {
      ["item_ammo_pistol"] = "item_ammo_pistol_ttt",
      ["item_box_buckshot"] = "item_box_buckshot_ttt",
      ["item_ammo_smg1"] = "item_ammo_smg1_ttt",
      ["item_ammo_357"] = "item_ammo_357_ttt",
      ["item_ammo_357_large"] = "item_ammo_357_ttt",
      ["item_ammo_revolver"] = "item_ammo_revolver_ttt", -- zm
      ["item_ammo_ar2"] = "item_ammo_pistol_ttt",
      ["item_ammo_ar2_large"] = "item_ammo_smg1_ttt",
      ["item_ammo_smg1_grenade"] = "weapon_zm_pistol",
      ["item_battery"] = "item_ammo_357_ttt",
      ["item_healthkit"] = "weapon_zm_shotgun",
      ["item_suitcharger"] = "weapon_zm_mac10",
      ["item_ammo_ar2_altfire"] = "weapon_zm_mac10",
      ["item_rpg_round"] = "item_ammo_357_ttt",
      ["item_ammo_crossbow"] = "item_box_buckshot_ttt",
      ["item_healthvial"] = "weapon_zm_molotov",
      ["item_healthcharger"] = "item_ammo_revolver_ttt",
      ["item_ammo_crate"] = "weapon_ttt_confgrenade",
      ["item_item_crate"] = "ttt_random_ammo",
      ["weapon_smg1"] = "weapon_zm_mac10",
      ["weapon_shotgun"] = "weapon_zm_shotgun",
      ["weapon_ar2"] = "weapon_ttt_m16",
      ["weapon_357"] = "weapon_zm_rifle",
      ["weapon_crossbow"] = "weapon_zm_pistol",
      ["weapon_rpg"] = "weapon_zm_sledge",
      ["weapon_slam"] = "item_ammo_pistol_ttt",
      ["weapon_frag"] = "weapon_zm_revolver",
      ["weapon_crowbar"] = "weapon_zm_molotov"
  };

  local function ReplaceSingle(ent, newname)
      if ent:GetPos() == vector_origin then
        return false
      end

      if ent:IsWeapon() and IsValid(ent:GetOwner()) and ent:GetOwner():IsPlayer() then
        return false
      end

      ent:SetSolid(SOLID_NONE)

      local rent = ents.Create(newname)
      rent:SetModel(mdls[newname])
      rent:SetPos(ent:GetPos())
      rent:SetAngles(ent:GetAngles())
      rent:Spawn()

      rent:Activate()
      rent:PhysWake()

      ent:Remove()
      return true
  end

  local function ReplaceHL2Ents(ply, cmd, args)
      if not IsValid(ply) then return end

      local c = 0
      for _, ent in pairs(ents.GetAll()) do
        local rpl = hl2_replace[ent:GetClass()]
        if rpl then
            local success = ReplaceSingle(ent, rpl)
            if success then
              c = c + 1
            end
        end
      end

      ply:ChatPrint("Replaced " .. c .. " HL2 entities with TTT versions.")
  end
  concommand.Add("tttweaponplacer_replacehl2", ReplaceHL2Ents)
end


« Last Edit: December 07, 2011, 10:56:04 PM by BipolarDiZ »

BipolarDiZ is bipolar.
|:NxS:| Custom TTT Server: source.nxs-gaming.com:27015
|:NxS:| Vanilla TTT Server: source.nxs-gaming.com:27016
|:NxS:| Fretta: currently offline
BipolarDiZ
Poster

Posts: 101


|:NxS:| Staff! :D


« Reply #8 on: December 08, 2011, 04:26:10 AM »

Did that work for you?

BipolarDiZ is bipolar.
|:NxS:| Custom TTT Server: source.nxs-gaming.com:27015
|:NxS:| Vanilla TTT Server: source.nxs-gaming.com:27016
|:NxS:| Fretta: currently offline
nrich588
Poster

Posts: 253

WzG Owner


« Reply #9 on: December 08, 2011, 08:46:41 PM »

Yes, also another question about SWeps, this maybe more for Sniper but, I am having trouble with dual elites, Is there a proper hold type for dual pistols? And i was wondering how to get them to both fire instead of one. Heres the lua:

-- First some standard GMod stuff
if SERVER then
  AddCSLuaFile( "shared.lua" )
end

if CLIENT then
  SWEP.PrintName = "Dual Elites"
  SWEP.Slot      = 1 -- add 1 to get the slot number key

  SWEP.ViewModelFOV  = 72
  SWEP.ViewModelFlip = true
end

-- Always derive from weapon_tttbase.
SWEP.Base = "weapon_tttbase"

--- Standard GMod values

SWEP.HoldType = "pistol"

SWEP.Primary.Delay      = 0.1
SWEP.Primary.Recoil      = 1.5
SWEP.Primary.Automatic  = false
SWEP.Primary.Damage      = 20
SWEP.Primary.Cone        = 0.020
SWEP.Primary.Ammo        = "Pistol"
SWEP.Primary.ClipSize    = 30
SWEP.Primary.ClipMax    = 60
SWEP.Primary.DefaultClip = 30
SWEP.ViewModel = "models/weapons/v_pist_elite.mdl"
SWEP.WorldModel = "models/weapons/w_pist_elite.mdl"

SWEP.Primary.Sound = Sound("Weapon_Elite.Single")
SWEP.IronSightsPos = Vector (-4.955, -3.441, 2.9131)
SWEP.IronSightsAng = Vector (-0.0325, -0.1378, 0.0087)

--- TTT config values

-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0      1      2    3      4      6      7        8
SWEP.Kind = WEAPON_PISTOL

-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = true

-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
SWEP.AmmoEnt = "item_ammo_pistol_ttt"

-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.


-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil

-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = false

-- If AllowDrop is false, players can't manually drop the gun with Q
SWEP.AllowDrop = true

-- If IsSilent is true, victims will not scream upon death.
SWEP.IsSilent = false

-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = false

-- Equipment menu information is only needed on the client
if CLIENT then
  -- Path to the icon material
  SWEP.Icon = "VGUI/ttt/icon_pistol"

  -- Text shown in the equip menu
 
end

-- Tell the server that it should download our icon to clients.
if SERVER then
  -- It's important to give your icon a unique name. GMod does NOT check for
  -- file differences, it only looks at the name. This means that if you have
  -- an icon_ak47, and another server also has one, then players might see the
  -- other server's dumb icon. Avoid this by using a unique name.
  resource.AddFile("materials/VGUI/ttt/icon_myserver_ak47.vmt")
end






Here's functions from a dual elite from a css weapon pack, I idiotically tried adding that, hoping in vain it might work.


/*---------------------------------------------------------
Think
---------------------------------------------------------*/
function SWEP:Think()

if self.Owner:KeyPressed(IN_ATTACK) and self.Weapon:Clip1() > 0 and self:CanClip1Attack()  then
-- When the left click is pressed, then
self.ViewModelFlip = true
end

if self.Owner:KeyPressed(IN_ATTACK2) and self.Weapon:Clip1() > 0 and self:CanClip2Attack() then
-- When the right click is pressed, then
self.ViewModelFlip = false
end
end

/*---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()

if not self:CanClip1Attack() or not self:CanPrimaryAttack() or self.Owner:WaterLevel() > 2 then return end
-- If your gun have a problem or if you are under water, you'll not be able to fire

self.Reloadaftershoot = CurTime() + self.Primary.Delay
-- Set the reload after shoot to be not able to reload when firering

self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
-- Set next secondary fire after your fire delay

self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay - 0.1)
-- Set next secondary fire after your fire delay

self.Weapon:EmitSound(self.Primary.Sound)
-- Emit the gun sound when you fire

self:RecoilPower()

clip1 = clip1 - 1
-- Take 1 ammo in your clip

if clip1 >= 0 then
self:TakePrimaryAmmo(1)
-- Take 1 ammo in you clip
end

if ((SinglePlayer() and SERVER) or CLIENT) then
self.Weapon:SetNetworkedFloat("LastShootTime", CurTime())
end
end

/*---------------------------------------------------------
SecondaryAttack
---------------------------------------------------------*/
function SWEP:SecondaryAttack()

if not self:CanClip2Attack() or not self:CanPrimaryAttack() or self.Owner:WaterLevel() > 2 then return end
-- If your gun have a problem or if you are under water, you'll not be able to fire

self.Reloadaftershoot = CurTime() + self.Primary.Delay
-- Set the reload after shoot to be not able to reload when firering

self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay - 0.1)
-- Set next secondary fire after your fire delay

self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay)
-- Set next secondary fire after your fire delay

self.Weapon:EmitSound(self.Primary.Sound)
-- Emit the gun sound when you fire

self:RecoilPower()

clip2 = clip2 - 1
-- Take 1 ammo in your clip

if clip2 >= 0 then
self:TakePrimaryAmmo(1)
-- Take 1 ammo in you clip
end

if ((SinglePlayer() and SERVER) or CLIENT) then
self.Weapon:SetNetworkedFloat("LastShootTime", CurTime())
end
end

/*---------------------------------------------------------
Reload
---------------------------------------------------------*/
function SWEP:Reload()

if ( self.Reloadaftershoot > CurTime() ) then return end
-- If you're firering, you can't reload

self.Weapon:DefaultReload(ACT_VM_RELOAD)
-- Animation when you're reloading

if ( self.Weapon:Clip1() < self.Primary.ClipSize ) and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then

timer.Simple(2, function()
clip1 = 15
clip2 = 15
end)
end
end

/*---------------------------------------------------------
Deploy
---------------------------------------------------------*/
function SWEP:Deploy()

self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
-- Set the deploy animation when deploying

self.Weapon:SetNextPrimaryFire(CurTime() + 1)
-- Set the next primary fire to 1 second after deploying

self.Weapon:SetNextSecondaryFire(CurTime() + 1)
-- Set the next primary fire to 1 second after deploying

if ( self.Weapon:Clip1() == 30 ) then
clip1 = 15
clip2 = 15
end

return true
end

/*---------------------------------------------------------
ShootBullet
---------------------------------------------------------*/
function SWEP:CSShootBullet(dmg, recoil, numbul, cone)

numbul = numbul or 1
cone = cone or 0.01

local bullet = {}
bullet.Num  = numbul
bullet.Src = self.Owner:GetShootPos()        -- Source
bullet.Dir = self.Owner:GetAimVector()      -- Dir of bullet
bullet.Spread = Vector(cone, cone, 0)      -- Aim Cone
bullet.Tracer = 1        -- Show a tracer on every x bullets
bullet.Force = 0.5 * dmg      -- Amount of force to give to phys objects
bullet.Damage = dmg -- Amount of damage to give to the bullets
bullet.Callback = HitImpact
-- bullet.Callback = function ( a, b, c ) BulletPenetration( 0, a, b, c ) end

self.Owner:FireBullets(bullet) -- Fire the bullets
self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)      -- View model animation
self.Owner:MuzzleFlash()        -- Crappy muzzle light
self.Owner:SetAnimation(PLAYER_ATTACK1)        -- 3rd Person Animation

local fx = EffectData()
fx:SetEntity(self.Weapon)
fx:SetOrigin(self.Owner:GetShootPos())
fx:SetNormal(self.Owner:GetAimVector())
fx:SetAttachment(self.MuzzleAttachment)
util.Effect(self.MuzzleEffect,fx) -- Additional muzzle effects

timer.Simple( self.EjectDelay, function()
if  not IsFirstTimePredicted() then
return
end

local fx = EffectData()
fx:SetEntity(self.Weapon)
fx:SetNormal(self.Owner:GetAimVector())
fx:SetAttachment(self.ShellEjectAttachment)

util.Effect(self.ShellEffect,fx) -- Shell ejection
end)

if ((SinglePlayer() and SERVER) or (not SinglePlayer() and CLIENT)) then
local eyeang = self.Owner:EyeAngles()
eyeang.pitch = eyeang.pitch - recoil
self.Owner:SetEyeAngles(eyeang)
end
end

/*---------------------------------------------------------
CanClip1Attack
---------------------------------------------------------*/
function SWEP:CanClip1Attack()
if clip1 <= 0 and self.Primary.ClipSize > -1 then
self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
self.Weapon:EmitSound("Weapons/ClipEmpty_Pistol.wav")
clip1 = 0
return false
end

return true
end

/*---------------------------------------------------------
CanClip2Attack
---------------------------------------------------------*/
function SWEP:CanClip2Attack()
if clip2 <= 0 and self.Primary.ClipSize > -1 then
self.Weapon:SetNextSecondaryFire(CurTime() + 0.5)
self.Weapon:EmitSound("Weapons/ClipEmpty_Pistol.wav")
clip2 = 0
return false
end

return true
end


sniperduck
Poster

Posts: 178


|:NxS:| Staff! :D


« Reply #10 on: December 08, 2011, 09:31:56 PM »

Nope. Most of the time duals are just a view model that shoots two bullets, and in other cases its a mirror of one pistol that shoots two bullets.
Sorry bro.

Overtime these forums have made me an asshole. ;D (TTT subforum)
|:NxS:| Custom TTT Server: source.nxs-gaming.com:27016
|:NxS:| Vanilla TTT Server: source.nxs-gaming.com:27016
|:NxS:| Fretta: <COMING SOON>
nrich588
Poster

Posts: 253

WzG Owner


« Reply #11 on: December 08, 2011, 09:46:21 PM »

Oh well, it will still make a fun traitor weapon :D
BipolarDiZ
Poster

Posts: 101


|:NxS:| Staff! :D


« Reply #12 on: December 09, 2011, 02:36:11 AM »

I found an amazing toybox swep for dualies. If this one doesn't work out for you.

BipolarDiZ is bipolar.
|:NxS:| Custom TTT Server: source.nxs-gaming.com:27015
|:NxS:| Vanilla TTT Server: source.nxs-gaming.com:27016
|:NxS:| Fretta: currently offline
nrich588
Poster

Posts: 253

WzG Owner


« Reply #13 on: December 09, 2011, 03:34:29 AM »

Yeah it works but fires from left gun only and you hold it wierd, question about some lua for start sounds:

resource.AddFile("sound/start.wav")


local function PlaySound()
  if TTTPrepareRound then
      BroadcastLua('surface.PlaySound("start.wav")')
    end
end
hook.Add("TTTPrepareRound", "MyMusic", PlaySound)
BipolarDiZ
Poster

Posts: 101


|:NxS:| Staff! :D


« Reply #14 on: December 09, 2011, 06:36:46 AM »

The one I saw fired from both guns.... I will try and find it for you later.

BipolarDiZ is bipolar.
|:NxS:| Custom TTT Server: source.nxs-gaming.com:27015
|:NxS:| Vanilla TTT Server: source.nxs-gaming.com:27016
|:NxS:| Fretta: currently offline
Pages: [1]
Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Adding SWeps to the TTT weapon Placer « previous next »
Jump to:  


Login with username, password and session length

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.01 seconds with 18 queries.