Gmod 10

Zexon
Garrys Mod Fourms
Gmod Links
Gmod Polls
Zexon's Gallery
Downloads & code
Zexon,s Lua Downloads
Zexon

welcome to Zexon A Garry's mod 10 website
=> Not registered yet?

Garrys Mod Fourms - Advanced Lua code

You are here:
Garrys Mod Fourms => Lua Codes => Advanced Lua code

<-Back

 1 

Continue->


Zexon
(13 posts so far)
09/18/2007 9:08pm (UTC)[quote]
this is a highly advanced Lua code
and is good for pro sweps / weapons.


Copy to the Notepad program
paste
save-as / shared.lua

Version//: 0.13 BETA

Credits for the code...

Aric Blunk (mblunk)
____________________________________
ADVANCED LUA CODE
____________________________________

-- Effect settings
SWEP.PrintName = "SWEP Template" -- The name of the weapon
SWEP.Slot = 1 -- The weapon slot this SWEP belongs in (0-5)
SWEP.SlotPos = 2 -- The position in the slot this weapon belongs in (0-infinity, DO NOT COVER UP EXISTING WEAPONS)
SWEP.DrawAmmo = true -- Display how much ammo this weapon has left?
SWEP.DrawCrosshair = true -- Display the crosshair?
SWEP.ViewModel = "models/weapons/v_pistol.mdl" -- First person model
SWEP.WorldModel = "models/weapons/w_pistol.mdl" -- Third person model
SWEP.ReloadSound = "weapons/pistol/pistol_reload1.wav" -- What sound should this weapon make when reloaded?

-- Other settings
SWEP.Weight = 5 -- How powerful is this weapon?
SWEP.AutoSwitchTo = false -- Automatically switch to this weapon if it's more powerful than what we're already holding
SWEP.AutoSwitchFrom = false -- Automatically switch from this weapon if what we pick up is more powerful than this weapon
SWEP.Spawnable = true -- Can clients spawn this weapon?
SWEP.AdminSpawnable = true -- Can admins spawn this weapon?
--SWEP.AutoReload = true -- Automatically reload if the clip is empty? (DOES NOT WORK YET)

-- Weapon info
SWEP.Author = "Aric Blunk (mblunk)" -- Who made this
SWEP.Contact = "aricblunk@gmail.com" -- How you can contact who made this
SWEP.Purpose = "To provide the GMod community with an easier way to create SWEPs." -- Why was this made?
SWEP.Instructions = "Look at the code, change some settings, and make your own SWEP." -- How do you use this?

-- Primary fire settings
SWEP.Primary.Sound = "weapons/pistol/pistol_fire2.wav" -- What sound should this weapon make when fired?
SWEP.Primary.Damage = 10 -- How much damage each bullet inflicts
SWEP.Primary.NumShots = 1 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like)
SWEP.Primary.Recoil = 0.5 -- How much we should punch the view
SWEP.Primary.Cone = 2 -- How many degrees the bullets can spread (90 max)
SWEP.Primary.Delay = 0.01 -- How many seconds between each shot
SWEP.Primary.ClipSize = 18 -- How big the clip is
SWEP.Primary.DefaultClip = 256 -- How much ammo the gun comes with
SWEP.Primary.Tracer = 1 -- Fire a tracer round every so many bullets
SWEP.Primary.Force = 1000 -- How much force the bullets have when they hit physics objects
SWEP.Primary.TakeAmmoPerBullet = false -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false
SWEP.Primary.Automatic = false -- Is this weapon automatic?
SWEP.Primary.Ammo = "pistol" -- Primary ammo type

-- Secondary fire settings
SWEP.Secondary.Sound = "" -- What sound should this weapon make when fired?
SWEP.Secondary.Damage = 0 -- How much damage each bullet inflicts
SWEP.Secondary.NumShots = 0 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like)
SWEP.Secondary.Recoil = 0 -- How much we should punch the view
SWEP.Secondary.Cone = 0 -- How many degrees the bullets can spread (90 max)
SWEP.Secondary.Delay = 0 -- How many seconds between each shot
SWEP.Secondary.ClipSize = 0 -- How big the clip is
SWEP.Secondary.DefaultClip = 0 -- How much ammo the gun comes with
SWEP.Secondary.Tracer = 0 -- Fire a tracer round every so many bullets
SWEP.Secondary.Force = 0 -- How much force the bullets have when they hit physics objects
SWEP.Secondary.TakeAmmoPerBullet = false -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false
SWEP.Secondary.Automatic = false -- Is this weapon automatic?
SWEP.Secondary.Ammo = "" -- Secondary ammo type

-- Functions that we can use to run certain code at certain times
-- I don't suggest you play around with this stuff unless you know what you're doing

function SWEP:Initialize() -- Called when this script is run
end

function SWEPrimaryAttack() -- Called when we press primary fire
if ( !self:CanPrimaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot
local bullet = {} -- Set up the shot
bullet.Num = self.Primary.NumShots -- How many bullets we'll fire at once
bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from
bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed
bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 ) -- Bullet spread
bullet.Tracer = self.Primary.Tracer -- Set up tracer rounds
bullet.Force = self.Primary.Force -- Set the bullet's force
bullet.Damage = self.Primary.Damage -- Define how much damage each bullet does
bullet.AmmoType = self.Primary.Ammo -- Define what kind of ammo we're using
self.Owner:FireBullets( bullet ) -- Shoot!
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- View model animation
self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation( PLAYER_ATTACK1 ) -- 3rd Person Animation
self.Weapon:EmitSound(Sound(self.Primary.Sound)) -- Make shooty noises
self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 ))
if (self.Primary.TakeAmmoPerBullet) then -- Set up ammo loss
self:TakePrimaryAmmo(self.Primary.NumShots)
else
self:TakePrimaryAmmo(1)
end
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) -- Don't shoot again until the delay has expired
end

function SWEP:SecondaryAttack() -- Called when we press secondary fire
if ( !self:CanSecondaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot
local bullet = {} -- Set up the shot
bullet.Num = self.Secondary.NumShots -- How many bullets we'll fire at once
bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from
bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed
bullet.Spread = Vector( self.Secondary.Cone / 90, self.Secondary.Cone / 90, 0 ) -- Bullet spread
bullet.Tracer = self.Secondary.Tracer -- Set up tracer rounds
bullet.Force = self.Secondary.Force -- Set the bullet's force
bullet.Damage = self.Secondary.Damage -- Define how much damage each bullet does
bullet.AmmoType = self.Secondary.Ammo -- Define what kind of ammo we're using
self.Owner:FireBullets( bullet ) -- Shoot!
self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK ) -- View model animation
self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation( PLAYER_ATTACK2 ) -- 3rd Person Animation
self.Weapon:EmitSound(Sound(self.Secondary.Sound)) -- Make shooty noises
self.Owner:ViewPunch(Angle( -self.Secondary.Recoil, 0, 0 ))
if (self.Secondary.TakeAmmoPerBullet) then -- Set up ammo loss
self:TakeSecondaryAmmo(self.Secondary.NumShots)
else
self:TakeSecondaryAmmo(1)
end
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ) -- Don't shoot again until the delay has expired
end

function SWEP:Think() -- Called every frame while this weapon is active
--[[ autoreload code (doesn't work, help?)
if ( self.AutoReload ) and (( self.LastReload == nil ) or ( CurTime() > (self.LastReload + 1) )) then
SWEP.LastReload = CurTime()
if (self:Ammo1() > 0) and (self:Clip1() == 0) and (!self.WeaponefaultReload()) then
self.WeaponefaultReload( ACT_VM_RELOAD )
--self:Reload()
end
if (self:Ammo2() > 0) and (self:Clip2() == 0) and (!self.WeaponefaultReload()) then
self.WeaponefaultReload( ACT_VM_RELOAD )
--self:Reload()
end
end
]]
end

function SWEP:Reload() -- Called when we reload
if (self.WeaponefaultReload()) then return end -- If we're already reloading, don't try to reload
self.WeaponefaultReload( ACT_VM_RELOAD ) -- Reload
self.Weapon:EmitSound(Sound(self.ReloadSound)) -- Make reloady noises
end

function SWEPeploy() -- Called when we take this weapon out
self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
return true
end

function SWEP:Holster() -- Called when we put this weapon away
return true
end

function SWEP:OnRemove() -- Called right before this gun exists no more
end

function SWEP:OnRestore() -- Called when we load a save where you have this weapon, or if the admin changes the map
end

function SWEPrecache() -- Use this function to precache resources
end

function SWEP:OwnerChanged() -- Called when this weapons is dropped or someone else picks it up
end

function SWEP:ContextScreenClick( aimvec, mousecode, pressed, ply ) -- Use this function to define what happens when the user clicks with the context screen cursor
end
Zexon
(13 posts so far)
09/18/2007 9:13pm (UTC)[quote]
the smiles are only there becouse of a code / codes

if you copy and paste the lua code into a notepad the code will be normal and should work fine

____________________________________

i may make pages on their own with the code on it so it looks like a code for use instead of smiles showing up

Answer:

Nickname:

 Text color:

 Font size:
Close tags



Total topics: 935
Total posts: 972
Total users: 7
Online now (registered users): Nobody crying smiley
Today, there have been 8 visitors (17 hits) on this page!
Zexon

Zexon makes maps and lua

This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free