I've been coding a swep for the past few days, and need a little help I'll try to explain it the best I can:
The swep acts like a quick scope in CoD or other games where you can quick scope, so on Primary fire I need it to go into iron sights for a sec and shoot.
That's basically the swep, but I'm not quite sure how to code this.
Could someone post the code or give me a tutorial on how I would do this.
Any help is appreciated.
Here's this, if you need to activate the Iron Sights on Primary fire, just create a function for Primary fire.
[code]
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "smg" -- How we hold the weapon. Go for pistol for handguns, smg for smgs, shotgun for stuff like that, rpg for rocket launcher and ar2 for rifles
end
if ( CLIENT ) then
SWEP.Author = "DE" -- Add your name here
SWEP.Contact = "Enjoy" -- Keep this the same plz
SWEP.Purpose = "Taking Care Of Business..." -- Whats the point of your swep?
SWEP.Instructions = "Left Click to fire" -- How to use your weapon
SWEP.PrintName = "SwepBase" -- What your swep is called
SWEP.Slot = 2 -- Which slot your swep is under e.g 3 will be under smgs
SWEP.SlotPos = 0 -- Leave this as 0 so your swep won't overwrite any others
SWEP.DrawAmmo = true -- Do we show the user ammo amounts?
SWEP.DrawCrosshair = true -- Do we show a crosshair
SWEP.IconLetter = "y" -- The icon of your weapon in the menu e.g y is usp
SWEP.ViewModelFlip = true -- Change this to false if your model is on the wrong side
killicon.AddFont("cse_elites","CSKillIcons",SWEP.IconLetter,Color(255,80,0,255)) -- Killicon
end
SWEP.Base = "weapon_cs_base" -- Leave this unless you have a custom base
SWEP.Category = "SMGs"
SWEP.Spawnable = true -- Can anyone spawn this (change this to false if you want admin only)
SWEP.AdminSpawnable = true -- Can only admins spawn this (leave this as true)
SWEP.ViewModel = "models/weapons/v_smg_tmp.mdl" -- The player view model
SWEP.WorldModel = "models/weapons/w_smg_tmp.mdl" -- The model other players see
SWEP.Weight = 3 -- How heavy it is (5 is a good value for rifles etc.)
SWEP.AutoSwitchTo = true -- Do you auto switch to this weapon when we pick it up
SWEP.AutoSwitchFrom = false -- Do you change from this weapon if you pick up another?
SWEP.Primary.Sound = Sound("Weapon_P90.Single") -- The sound when you fire
SWEP.Primary.Recoil = 2 -- How much your view is punched after each shot
SWEP.Primary.Damage = 999 -- How much damage it deals e.g about 50 for an ak47
SWEP.Primary.NumShots = 1 -- Number of bullets fired with each shot e.g 8 for a shotgun
SWEP.Primary.Cone = 0.01 -- Number of degrees of spread
SWEP.Primary.ClipSize = 20 -- How many bullets to a single clip
SWEP.Primary.Delay = 0.3 -- Delay in seconds between each shot
SWEP.Primary.DefaultClip = 200 -- Default number of bullets it comes with
SWEP.Primary.Force = 3000 -- Amount of force a bullet has on physics objects
SWEP.Primary.TakeAmmoPerBullet = true -- True = take 1 ammo for each bullet, False = take one bullet for each shot
SWEP.Primary.Automatic = false -- Set to true for automatic fire
SWEP.Primary.Ammo = "smg1" -- What ammo it takes e.g buckshot for shotgun ammo
SWEP.IronSightsPos = Vector(-5.15,-3,2.37) -- Delete unless you can set ironsights. Position of the ironsight
SWEP.IronSightsAng = Vector(-.4,0,0) -- Delete unless you can set ironsights Angle of the ironsight [/code]
[QUOTE=DoubleElite;28508759]Here's this, if you need to activate the Iron Sights on Primary fire, just create a function for Primary fire.[/QUOTE]Thats just assigning simple variables, thats not really coding.. For the actual code look at the other bases, theres allot of them out there that support ironsights, css base that garry made contains pretty easy to understand examples of the usage.
[QUOTE=freemmaann;28510995]Thats just assigning simple variables, thats not really coding.. For the actual code look at the other bases, theres allot of them out there that support ironsights, css base that garry made contains pretty easy to understand examples of the usage.[/QUOTE]
I know how to do ironsights and all of that, I just need it to scope in and out on primary fire.
Sorry, you need to Log In to post a reply to this thread.