Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---- Example TTT custom weapon
- -- First some standard GMod stuff
- if SERVER then
- AddCSLuaFile( "shared.lua" )
- end
- if CLIENT then
- SWEP.PrintName = "Life stealer"
- 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 = "pistol"
- SWEP.Primary.Delay = 0.4
- SWEP.Primary.Recoil = 1
- SWEP.Primary.Automatic = false
- SWEP.Primary.Damage = 15
- SWEP.Primary.Cone = 0.01
- SWEP.Primary.Ammo = "pistol"
- SWEP.Primary.ClipSize = 5
- SWEP.Primary.ClipMax = 20
- SWEP.Primary.DefaultClip = 25
- SWEP.sound = "weapon_pistol.Single"
- --- 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 = "none"
- -- 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 = false
- -- If NoSights is true, the weapon won't have ironsights
- SWEP.NoSights = true
- -- Equipment menu information is only needed on the client
- if CLIENT then
- -- Text shown in the equip menu
- SWEP.EquipMenuData = {
- type = "Weapon",
- desc = "Shoot a bullet to inflict 15hp on target and regain 10hp to self"
- };
- end
- function SWEP:PrimaryAttack()
- if ( !self:CanPrimaryAttack() ) then return end
- local bullet = {}
- bullet.Num = 1
- bullet.Src = self.Owner:GetShootPos() // Source
- bullet.Dir = self.Owner:GetAimVector() // Dir of bullet
- bullet.Spread = Vector( self.Primary.Cone, self.Primary.Cone, 0 ) // Aim Cone
- bullet.Tracer = 0 // Show a tracer on every x bullets
- bullet.TracerName = tracer // what Tracer Effect should be used
- bullet.Force = 1 // Amount of force to give to phys objects
- bullet.Damage = self.Primary.Damage
- bullet.AmmoType = "Pistol"
- self.Owner:FireBullets( bullet )
- local trace = util.GetPlayerTrace( self.Owner )
- local traceRes = util.TraceLine( trace )
- self:EmitSound( self.sound )
- if ( traceRes.HitNonWorld ) then
- if traceRes.Entity:IsPlayer() then
- if self.Owner:Health()+10 < 100 then
- self.Owner:SetHealth( self.Owner:Health() + 10 )
- else
- self.Owner:SetHealth( 100 )
- end
- end
- end
- self:TakePrimaryAmmo(1)
- self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- self:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
- end
Advertisement
Add Comment
Please, Sign In to add comment