• TTT lua codeing help please
    7 replies, posted
Hello i need help with my lua codeing (im not good at codeing nor do i know what im doing) with lots of things D: Frist my Aug and T sniper dose not have scopes idk what to do :( and how do i add image's to the pointshop weapons and icons on t stuff AUG [T] if SERVER then AddCSLuaFile( "shared.lua" ) end SWEP.HoldType = "ar2" if CLIENT then SWEP.PrintName = "Aug" SWEP.Slot = 2 SWEP.Icon = "VGUI/ttt/" end SWEP.Base = "weapon_tttbase" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Kind = WEAPON_HEAVY SWEP.WeaponID = AMMO_M16 SWEP.Primary.Delay = 0.190000000000 SWEP.Primary.Recoil = 2.6 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "Pistol" SWEP.Primary.Damage = 23 SWEP.Primary.Cone = 0.018 SWEP.Primary.ClipSize = 20 SWEP.Primary.ClipMax = 60 SWEP.Primary.DefaultClip = 20 SWEP.AutoSpawnable = true SWEP.AmmoEnt = "item_ammo_pistol_ttt" SWEP.UseHands = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 64 SWEP.ViewModel = "models/weapons/cstrike/c_rif_aug.mdl" SWEP.WorldModel = "models/weapons/w_rif_aug.mdl" SWEP.Primary.Sound = Sound( "Weapon_aug.Single" ) SWEP.IronSightsPos = Vector(-7.58, -9.2, 0.55) SWEP.IronSightsAng = Vector(2.599, -1.3, -3.6) function SWEP:SetZoom(state) if CLIENT then return end if not (IsValid(self.Owner) and self.Owner:IsPlayer()) then return end if state then self.Owner:SetFOV(35, 0.5) else self.Owner:SetFOV(0, 0.2) 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 [/T] Sniper [T] ---- Example TTT custom weapon -- First some standard GMod stuff if SERVER then AddCSLuaFile( "shared.lua" ) end if CLIENT then SWEP.PrintName = "1 hit K.O" SWEP.Slot = 6 -- 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 = "ar2" SWEP.Primary.Delay = 1 SWEP.Primary.Recoil = 8 SWEP.Primary.Automatic = true SWEP.Primary.Damage = 1000000000 SWEP.Primary.Cone = 0.025 SWEP.Primary.Ammo = "" SWEP.Primary.ClipSize = 2 SWEP.Primary.ClipMax = 2 SWEP.Primary.DefaultClip = 2 SWEP.Primary.Sound = Sound( "Weapon_.Single" ) SWEP.IronSightsPos = Vector( 6.05, -5, 2.4 ) SWEP.IronSightsAng = Vector( 2.2, -0.1, 0 ) SWEP.ViewModel = "models/weapons/v_snip_sg550.mdl" SWEP.WorldModel = "models/weapons/w_snip_sg550.mdl" --- 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_EQUIP1 -- 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 = false -- The AmmoEnt is the ammo entity that can be picked up when carrying this gun. SWEP.AmmoEnt = "item_ammo_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. SWEP.CanBuy = { ROLE_TRAITOR } -- 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 = true -- 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 = true -- 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/Instant_kill_hitsplat.png" -- Text shown in the equip menu SWEP.EquipMenuData = { type = "Weapon", desc = "TTT's Lovey gun." }; 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/Instant_kill_hitsplat.png") end [\T] [editline]20th July 2013[/editline] Lol i forgot is was copying off a example :D
I'd suggest using [lua] tags to wrap code. Next, Alter the Secondary Attack function, change FOV will "zoom", for the "scope" you'll need to overlay an image using the HUD aspect of SWEP to draw the overlay when the user is zoomed with a scope. Make sure to reverse FOV when right click again and leave zoom.
[QUOTE=Acecool;41538069]I'd suggest using [lua] tags to wrap code. Next, Alter the Secondary Attack function, change FOV will "zoom", for the "scope" you'll need to overlay an image using the HUD aspect of SWEP to draw the overlay when the user is zoomed with a scope. Make sure to reverse FOV when right click again and leave zoom.[/QUOTE] How do I attach the image of the scope? Im not the best to understand anyway is it something like this [lua] if CLIENT then SWEP.PrintName = "1 hit K.O" SWEP.Slot = 6 SWEP.ViewModelFOV = zoom SWEP.ViewModelFlip = true SWEP.OverlayModel = end [lua]
clueless you need a [/lua] at the end. for the scope I suggest you look at how weapon_zm_rifle does it.
[QUOTE=Pandaman09;41546102]clueless you need a [/lua] at the end. for the scope I suggest you look at how weapon_zm_rifle does it.[/QUOTE] sorry new to forms :P
[QUOTE=Pandaman09;41546102]clueless you need a [/lua] at the end. for the scope I suggest you look at how weapon_zm_rifle does it.[/QUOTE] I used the weapon_zm_rifle for the lua but now the weapon cant be bought
[QUOTE=cluelesshobo;41547585]sorry new to forms :P[/QUOTE] Edit your post, click the edit button and put [/LUA] at the end, instead of [LUA] :)
[url]http://ttt.badking.net/custom-weapon-guide[/url] This is a guide on how to make a weapon. Look specifically at this section "Special equipment fields" I suggested looking at the weapon_zm_rifle because near the bottom is has a secondary click function that brings up a scope.
Sorry, you need to Log In to post a reply to this thread.