• TTT - Item doesn't show up in T shop
    9 replies, posted
I recently decided to add a silent AWP that looks like a sniper rifle to the server. Shouldn't be too hard, right? Should be something that even a complete noob should be able to do. I just took an existing T shop item, took the weapon_zm_rifle lua file, and combined them. It SHOULD work, but it didn't. It simply doesn't show up in the T shop. No lua error or anything... The code: [CODE]---- Example TTT custom weapon -- First some standard GMod stuff if SERVER then AddCSLuaFile( "shared.lua" ) end if CLIENT then SWEP.PrintName = "Silenced AWP" SWEP.Slot = 2 -- add 1 to get the slot number key end SWEP.UseHands = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 54 SWEP.ViewModel = Model("models/weapons/cstrike/c_snip_scout.mdl") SWEP.WorldModel = Model("models/weapons/w_snip_scout.mdl") -- Always derive from weapon_tttbase. SWEP.Base = "weapon_tttbase" SWEP.Spawnable = false --- Standard GMod values SWEP.HoldType = "ar2" SWEP.Primary.Delay = 0.05 SWEP.Primary.Recoil = 0.005 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "xBowBolt" SWEP.Primary.Damage = 10000 SWEP.Primary.Cone = 0.005 SWEP.Primary.ClipSize = 1 SWEP.Primary.ClipMax = 1 -- keep mirrored to ammo SWEP.Primary.DefaultClip = 1 SWEP.Primary.Sound = Sound( "weapons/usp/usp1.wav" ) SWEP.Primary.SoundLevel = 50 SWEP.HeadshotMultiplier = 4 SWEP.IronSightsPos = Vector( 5, -15, -2 ) SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 ) function SWEP:WasBought(buyer) if IsValid(buyer) then -- probably already self.Owner buyer:GiveAmmo( 1, "item_ammo_357_ttt" ) end end -- TTT config values SWEP.Kind = WEAPON_HEAVY SWEP.AutoSpawnable = false SWEP.AmmoEnt = "item_ammo_357_ttt" SWEP.CanBuy = {ROLE_TRAITOR} SWEP.InLoadoutFor = nil SWEP.LimitedStock = true SWEP.AllowDrop = true SWEP.IsSilent = true 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_scout" -- Text shown in the equip menu SWEP.EquipMenuData = { type = "item_weapon", name = "Silenced AWP" desc = "Silenced AWP Sniper Rifle./n/n One shot. One Kill." }; end function SWEP:SetZoom(state) if CLIENT then return elseif IsValid(self.Owner) and self.Owner:IsPlayer() then if state then self.Owner:SetFOV(20, 0.3) else self.Owner:SetFOV(0, 0.2) end end end[/CODE] I know it's long and all, and also this: "Do not post huge scripts and expect people to fix them. If you wrote the script then you should know why it doesn't work. If you're editing someone's script and can't get it to work then don't! Learn how to code!" But I have no idea what to do here Btw: I removed the sniper zoom part from the code, to make it much shorter, so maybe now it's not too long
What exactly did you "combine"? Because it seems as if you have two clientside sections, so you could've gone wrong elsewhere
Shouldn't it be [CODE]type = "Weapon",[/CODE]
[QUOTE=King Traitor;45520744]Shouldn't it be [CODE]type = "Weapon",[/CODE][/QUOTE] Nope. e.g.: [CODE]SWEP.EquipMenuData = { type = "item_weapon", name = "C4", desc = "c4_desc" };[/CODE]
[QUOTE=Ekuland;45520791]Nope. [/QUOTE] Well I use a silent AWP and it only works when I use type = "Weapon",
Welp, you said there weren't any lua errors, but the server console should've complained about your SWEP.EquipMenuData not being closed by a "}". Change the afore mentioned bit of code to this: [CODE] -- Text shown in the equip menu SWEP.EquipMenuData = { type = "item_weapon", name = "Silenced AWP", desc = "Silenced AWP Sniper Rifle./n/n One shot. One Kill." }; [/CODE]
[QUOTE=Ekuland;45520855]Welp, you said there weren't any lua errors, but the server console should've complained about your SWEP.EquipMenuData not being closed by a "}". Change the afore mentioned bit of code to this: [CODE] -- Text shown in the equip menu SWEP.EquipMenuData = { type = "item_weapon", name = "Silenced AWP", desc = "Silenced AWP Sniper Rifle./n/n One shot. One Kill." }; [/CODE][/QUOTE] That's exactly what I have? [editline]28th July 2014[/editline] Changed the code a bit, might wanna check it out again
Same error is still present. There isn't a comma after this part in your script. Watch syntax carefully.[CODE]name = "Silenced AWP"[/CODE]
[QUOTE=Ekuland;45523810]Same error is still present. There isn't a comma after this part in your script. Watch syntax carefully.[CODE]name = "Silenced AWP"[/CODE][/QUOTE] Fixed. Still broken
Fixed. Apparently I was using a corrupt file or wrong directory or smh. Anyways this code works for me: [CODE]if SERVER then AddCSLuaFile( "shared.lua" ) end SWEP.HoldType = "ar2" if CLIENT then SWEP.PrintName = "Silenced Sniper" SWEP.Author = "JasonMan" SWEP.Slot = 2 SWEP.SlotPos = 1 SWEP.IconLetter = "w" SWEP.Icon = "vgui/ttt/icon_scout" end SWEP.Base = "weapon_tttbase" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Kind = WEAPON_HEAVY SWEP.Primary.Delay = 0.9 SWEP.Primary.Recoil = 4 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "357" SWEP.Primary.Damage = 48 SWEP.Primary.Cone = 0.006 SWEP.Primary.ClipSize = 10 SWEP.Primary.ClipMax = 20 -- keep mirrored to ammo SWEP.Primary.DefaultClip = 20 SWEP.AutoSpawnable = true SWEP.AmmoEnt = "item_ammo_357_ttt" SWEP.UseHands = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 54 SWEP.ViewModel = Model("models/weapons/cstrike/c_snip_scout.mdl") SWEP.WorldModel = Model("models/weapons/w_snip_scout.mdl") SWEP.Primary.Sound = Sound ("Weapon_M4A1.Silenced") --SWEP.Primary.Sound = Sound( "Weapon_M4A1.Single" ) --SWEP.IronSightsPos = Vector( 5, 0, 1 ) SWEP.IronSightsPos = Vector(0, 0, -15) SWEP.CanBuy = { ROLE_TRAITOR } SWEP.LimitedStock = true SWEP.EquipMenuData = { type = "Weapon", desc = "A silenced sniper rifle." }; SWEP.AllowDrop = true SWEP.IsSilent = true SWEP.PrimaryAnim = ACT_VM_PRIMARYATTACK_SILENCED SWEP.ReloadAnim = ACT_VM_RELOAD_SILENCED function SWEP:Deploy() self.Weapon:SendWeaponAnim(ACT_VM_DRAW_SILENCED) return true end -- We were bought as special equipment, and we have an extra to give function SWEP:WasBought(buyer) if IsValid(buyer) then -- probably already self.Owner buyer:GiveAmmo( 10, "357" ) end end function SWEP:SetZoom(state) if CLIENT then return else if state then self.Owner:SetFOV(20, 0.3) else self.Owner:SetFOV(0, 0.2) end end end -- Add some zoom to ironsights for this gun function SWEP:SecondaryAttack() if not self.IronSightsPos then return end if self.Weapon:GetNextSecondaryFire() > CurTime() then return end bIronsights = not self:GetIronsights() self:SetIronsights( bIronsights ) if SERVER then self:SetZoom(bIronsights) end self.Weapon:SetNextSecondaryFire( CurTime() + 0.3) end function SWEP:PreDrop() self:SetZoom(false) self:SetIronsights(false) return self.BaseClass.PreDrop(self) end function SWEP:Reload() self.Weapon:DefaultReload( ACT_VM_RELOAD ); self:SetIronsights( false ) self:SetZoom(false) end function SWEP:Holster() self:SetIronsights(false) self:SetZoom(false) return true end if CLIENT then local scope = surface.GetTextureID("sprites/scope") function SWEP:DrawHUD() if self:GetIronsights() then surface.SetDrawColor( 0, 0, 0, 255 ) local x = ScrW() / 2.0 local y = ScrH() / 2.0 local scope_size = ScrH() -- crosshair local gap = 80 local length = scope_size surface.DrawLine( x - length, y, x - gap, y ) surface.DrawLine( x + length, y, x + gap, y ) surface.DrawLine( x, y - length, x, y - gap ) surface.DrawLine( x, y + length, x, y + gap ) gap = 0 length = 50 surface.DrawLine( x - length, y, x - gap, y ) surface.DrawLine( x + length, y, x + gap, y ) surface.DrawLine( x, y - length, x, y - gap ) surface.DrawLine( x, y + length, x, y + gap ) -- cover edges local sh = scope_size / 2 local w = (x - sh) + 2 surface.DrawRect(0, 0, w, scope_size) surface.DrawRect(x + sh - 2, 0, w, scope_size) surface.SetDrawColor(255, 0, 0, 255) surface.DrawLine(x, y, x + 1, y + 1) -- scope surface.SetTexture(scope) surface.SetDrawColor(255, 255, 255, 255) surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0) else return self.BaseClass.DrawHUD(self) end end function SWEP:AdjustMouseSensitivity() return (self:GetIronsights() and 0.2) or nil end end[/CODE]
Sorry, you need to Log In to post a reply to this thread.