I was trying to make a swep and i have it all done. The only thing is i want it to be an arsony tool and i want it to light a prop on fire when u click on a prop. Can anyone help. Just add it to the code in the shared.lua, here it is:
[lua]// This SWEP was Made by Clod14's SWEP Maker.
SWEP.base = "weapon_Base"
//Basic Weapon Description
SWEP.Author = "TOMIS13LACK"
SWEP.Contact = "Tom.black0626@gmail.com"
SWEP.Purpose = "FIRE FIRE FIRE HAHAHAHA"
SWEP.Instructions = "click to use"
SWEP.PrintName = "Arsony SWEP"
SWEP.Slot = 4
SWEP.SlotPos = 2
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
SWEP.ViewModel = "models/weapons/v_crowbar.mdl" //HL2
SWEP.WorldModel = "models/weapons/w_crowbar.mdl" //HL2
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 64
SWEP.ReloadSound = "weapons/pistol/pistol_reload1.wav"
SWEP.HoldType = "melee"
// Other settings
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.Weight = 3
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = true
// Primary fire settings
SWEP.Primary.Recoil = 0
SWEP.Primary.Damage = 0
SWEP.Primary.NumShots = 0
SWEP.Primary.Cone = 0.01
SWEP.Primary.ClipSize = -1
SWEP.Primary.Delay = 0.08
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = True
SWEP.Primary.Ammo = "none"
SWEP.Primary.Tracer = 1
SWEP.Primary.Sound = "weapons/pistol/pistol_fire2.wav"
SWEP.Primary.Force = 1
SWEP.Primary.TakeAmmoPerBullet = true
SWEP.Secondary.Recoil = 0
SWEP.Secondary.Damage = 0
SWEP.Secondary.NumShots = 0
SWEP.Secondary.Cone = 0.01
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.Delay = 0.08
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = True
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Tracer = 1
SWEP.Secondary.Sound = "weapons/pistol/pistol_fire2.wav"
SWEP.Secondary.Force = 1
//Secondary fire settings
SWEP.Secondary.TakeAmmoPerBullet = true
function SWEP:Initialize()
if ( SERVER ) then
self:SetWeaponHoldType( self.HoldType )
end
end
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {}
bullet.Num = self.Primary.NumShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 )
bullet.Tracer = self.Primary.Tracer
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
bullet.AmmoType = self.Primary.Ammo
self.Owner:FireBullets( bullet )
self.Weapon:EmitSound(Sound(self.Primary.Sound))
self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 ))
if (self.Primary.TakeAmmoPerBullet) then
self:TakePrimaryAmmo(self.Primary.NumShots)
else
self:TakePrimaryAmmo(1)
end
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end
function SWEP:SecondaryAttack()
end
function SWEP:Think()
end
function SWEP:Reload()
self.Weapon:DefaultReload(ACT_VM_RELOAD)
return true
end
function SWEP:Deploy()
return true
end
function SWEP:Holster()
return true
end
function SWEP:OnRemove()
end
function SWEP:OnRestore()
end
function SWEP:Precache()
end
function SWEP:OwnerChanged()
end[/lua]
nobody knows how?
Would do it with something like making sure the target is a prop_physics and then if it is then fire("ignite")
yes but i am new with this stuff
[QUOTE=tomis13lack2;45799825]yes but i am new with this stuff[/QUOTE]
Too bad, learn it, we're not here to spoonfeed people code. Besides, no one ever gets value out of code they don't learn.
i do wanna learn and i cant learn unless i am taught
[QUOTE=tomis13lack2;45799862]i do wanna learn and i cant learn unless i am taught[/QUOTE]
Well then, you have a lot of reading to do then.
[URL="http://wiki.garrysmod.com"]GMod Wiki (Useful)[/URL] | [URL="http://google.com"]Google (Most Useful)[/URL]
[code]
local trace = self:GetOwner():GetEyeTrace()
if (IsValid(trace.Entity) and trace.Entity:GetClass() == "prop_physics") then
trace.Entity:Ignite(5)
end
[/code]
On you to figure out where that goes.
[LUA]local ent = FindMetaTable("Entity")
function SWEP:ReceiveTraceValue()
local v_tracelenght = 125 --how far should your traceline go , 125 reachdistance
local tr = util.TraceLine({
start = self.Owner:GetShootPos(),
endpos = self.Owner:GetShootPos() + ply:GetAimVector() * v_tracelenght,
filter = self.Owner
})
if !((tr.Entity:IsPropPhysics()) || (IsValid(tr.Entity))) then return end
trace.Entity:Ignite(5)
end
function ent:IsPropPhysics()
if self:GetClass() == "prop_physics" then
return true
else
return false
end
end[/LUA]
might be usefull
Sorry, you need to Log In to post a reply to this thread.