So I am coding my own weapon for a server and I need help with it. I already have the basics of it, its suppost to shoot balls/bricks with a trail and it does 0 damage to anyone. If anyone could please help me with the Trail Part? The code is!
[CODE]if SERVER then
AddCSLuaFile ("shared.lua")
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
elseif CLIENT then
SWEP.PrintName = "Chair throwing gun"
SWEP.Slot = 4
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity")
end
SWEP.Author = "goodguy68"
SWEP.Contact = ""
SWEP.Purpose = "Shoots a brick with a trail."
SWEP.Instructions = "Shoot it!"
SWEP.Category = "Trail Gun"
SWEP.Spawnable = true -- Whether regular players can see it
SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it
SWEP.ViewModel = "models/weapons/v_toolgun.mdl" -- This is the model used for clients to see in first person.
SWEP.WorldModel = "models/weapons/w_toolgun.mdl" -- This is the model shown to all other clients and in third-person.
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
local ShootSound = Sound("Metal.SawbladeStick")
function SWEP:throw_attack (model_file)
local tr = self.Owner:GetEyeTrace()
self:EmitSound(ShootSound)
self.BaseClass.ShootEffects(self)
if (!SERVER) then return end
local ent = ents.Create("prop_physics")
ent:SetModel(model_file)
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
ent:SetAngles(self.Owner:EyeAngles())
ent:Spawn()
local phys = ent:GetPhysicsObject()
if !(phys && IsValid(phys)) then ent:Remove() return end
phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3))
cleanup.Add(self.Owner, "props", ent)
undo.Create ("Thrown_SWEP_Entity")
undo.AddEntity (ent)
undo.SetPlayer (self.Owner)
undo.Finish()
end
function SWEP:PrimaryAttack()
self:throw_attack("models/props/brick.mdl")
end
function SWEP:SecondaryAttack()l
self:throw_attack("models/props/brick.mdl")
end
[/CODE]
I also need help to find out what the brick is? I think its models/props/brick.
Thank you to who ever helps!
[QUOTE=FlameCow;41701953][url]http://wiki.garrysmod.com/page/util/SpriteTrail[/url]
I believe that's what you're looking for. You could probably just set it when you create the entity that you're throwing.[/QUOTE]
Thank you, I've seen this before, but I'm wondering where to put it in the coding. And before you say that its basic coding where it goes. I'm still a noob at coding. D: I just know some basics.
[code]if SERVER then
AddCSLuaFile ("shared.lua")
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
elseif CLIENT then
SWEP.PrintName = "Chair throwing gun"
SWEP.Slot = 4
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity")
end
SWEP.Author = "goodguy68"
SWEP.Contact = ""
SWEP.Purpose = "Shoots a brick with a trail."
SWEP.Instructions = "Shoot it!"
SWEP.Category = "Trail Gun"
SWEP.Spawnable = true -- Whether regular players can see it
SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it
SWEP.ViewModel = "models/weapons/v_toolgun.mdl" -- This is the model used for clients to see in first person.
SWEP.WorldModel = "models/weapons/w_toolgun.mdl" -- This is the model shown to all other clients and in third-person.
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
local ShootSound = Sound("Metal.SawbladeStick")
function SWEP:throw_attack (model_file)
local tr = self.Owner:GetEyeTrace()
self:EmitSound(ShootSound)
self.BaseClass.ShootEffects(self)
if (!SERVER) then return end
local ent = ents.Create("prop_physics")
ent:SetModel(model_file)
local trail = util.SpriteTrail(ent, 0, Color(255,0,0), false, 15, 1, 4, 1/(15+1)*0.5, "trails/plasma.vmt")
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
ent:SetAngles(self.Owner:EyeAngles())
ent:Spawn()
local phys = ent:GetPhysicsObject()
if !(phys && IsValid(phys)) then ent:Remove() return end
phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3))
return trail
cleanup.Add(self.Owner, "props", ent)
undo.Create ("Thrown_SWEP_Entity")
undo.AddEntity (ent)
undo.SetPlayer (self.Owner)
undo.Finish()
end
function SWEP:PrimaryAttack()
self:throw_attack("models/props/brick.mdl")
end
function SWEP:SecondaryAttack()l
self:throw_attack("models/props/brick.mdl")
end[/code]
Im not sure, but this should work.
[CODE]
if SERVER then
AddCSLuaFile ("shared.lua")
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
elseif CLIENT then
SWEP.PrintName = "Trail Gun"
SWEP.Slot = 4
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity")
end
SWEP.Author = "goodguy68"
SWEP.Contact = ""
SWEP.Purpose = "Shoots Bricks With Trails"
SWEP.Instructions = "You shoot!"
SWEP.Category = "Chair Launcher"
SWEP.Spawnable = true -- Whether regular players can see it
SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it
SWEP.ViewModel = "models/weapons/v_toolgun.mdl" -- This is the model used for clients to see in first person.
SWEP.WorldModel = "models/weapons/w_toolgun.mdl" -- This is the model shown to all other clients and in third-person.
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
local ShootSound = Sound("Metal.SawbladeStick")
function SWEP:throw_attack (model_file)
local tr = self.Owner:GetEyeTrace()
self:EmitSound(ShootSound)
self.BaseClass.ShootEffects(self)
if (!SERVER) then return end
local ent = ents.Create("prop_physics")
ent:SetModel(model_file)
local trail = util.SpriteTrail(ent, 0, Color(0,0,255), false, 15, 1, 4, 1/(15+1)*0.5, "trails/plasma.vmt")
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
ent:SetAngles(self.Owner:EyeAngles())
ent:Spawn()
local phys = ent:GetPhysicsObject()
if !(phys && IsValid(phys)) then ent:Remove() return end
phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3))
cleanup.Add(self.Owner, "props", ent)
undo.Create ("Thrown_SWEP_Entity")
undo.AddEntity (ent)
undo.SetPlayer (self.Owner)
undo.Finish()
end
function SWEP:PrimaryAttack()
self:throw_attack("models/props/brick.mdl")
end
function SWEP:SecondaryAttack()
self:throw_attack("models/props/brick.mdl")
end
[/CODE]
Ok, so this works. I tested changing the models to a chair and a jetpack. Now all I need to know is what is the dir for the brick? Cause this doesn't shoot cause the dir isn't model/props/brick.mdl Someone please help me with that? D:
Thanks again person above with the trails!
Wait, you removed "return trail" from my code?
I found out that the brick is called CinderBrick01a. I've tried models/props/construction/CinderBrick01a.mdl, models/Construction_Props/CinderBrick01a.mdl, models/construction/CinderBrick01a.mdl, models/CinderBrick01a.mdl.
[editline]3rd August 2013[/editline]
[QUOTE=bilbasio;41702496]Wait, you removed "return trail" from my code?[/QUOTE]
Yea, should I add it back?
Well if it's working without it I guess you let it out
[editline]4th August 2013[/editline]
I haven't tested it so I thought you needed to specify the return trail (I have never worked with trails before)
Wait bilbasio, I have a question. How would you be able to make the gun Time limited. So they cant shoot Super Fast?
Edit:
Nevermind I was just being dumb!
[QUOTE=goodguy68;41702574]Wait bilbasio, I have a question. How would you be able to make the gun Time limited. So they cant shoot Super Fast?
Edit:
Nevermind I was just being dumb![/QUOTE]
If you haven't figured it out then its SWEP.Delay = "(number)"
Hmm. Ok. So it seems that the delay doesn't work. Also it does damage. Anyone have a way to prevent this?
Edit: Testing what the person has put above. Still need damage though, unless it is SWEP.Damage =
[editline]3rd August 2013[/editline]
Hmm, I tried putting SWEP.Delay = 5 Didn't work though. I've tried it with SWEP.Primary.Delay = 5 and Secondary, still didn't work. any suggestions?
[editline]4th August 2013[/editline]
Another question would be, how would you set it so the Object it shoots disappears within 5 secs?
[editline]4th August 2013[/editline]
Heres what I have at my current Point!
[CODE]if SERVER then
AddCSLuaFile ("shared.lua")
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
elseif CLIENT then
SWEP.PrintName = "Orange Shooter"
SWEP.Slot = 4
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity")
end
SWEP.Author = "goodguy68"
SWEP.Contact = ""
SWEP.Purpose = "Shoots Oranges With Trails"
SWEP.Instructions = "You shoot!"
SWEP.Category = "Orange Launcher"
SWEP.Spawnable = true -- Whether regular players can see it
SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it
SWEP.ViewModel = "models/weapons/v_toolgun.mdl" -- This is the model used for clients to see in first person.
SWEP.WorldModel = "models/weapons/w_toolgun.mdl" -- This is the model shown to all other clients and in third-person.
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Delay = 5
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = 0
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
local ShootSound = Sound("weapons/357_fire2.wav")
function SWEP:throw_attack (model_file)
local tr = self.Owner:GetEyeTrace()
self:EmitSound(ShootSound)
self.BaseClass.ShootEffects(self)
if (!SERVER) then return end
local ent = ents.Create("prop_physics")
ent:SetModel(model_file)
local trail = util.SpriteTrail(ent, 0, Color(255,93,0), false, 15, 1, 4, 1/(15+1)*0.5, "trails/physbeam.vmt")
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
ent:SetAngles(self.Owner:EyeAngles())
ent:Spawn()
local phys = ent:GetPhysicsObject()
if !(phys && IsValid(phys)) then ent:Remove() return end
phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3))
cleanup.Add(self.Owner, "props", ent)
undo.Create ("Thrown_SWEP_Entity")
undo.AddEntity (ent)
undo.SetPlayer (self.Owner)
undo.Finish()
end
function SWEP:PrimaryAttack()
self:throw_attack("models/props/cs_italy/orange.mdl")
end
function SWEP:SecondaryAttack()
end [/CODE]
I decided to use Oranges instead of the cinder block. Any one care to help with the delay, damage, and Disappearance of the oranges?
Yea, damage is SWEP.damage = (SWEP.Primary.Damage)
For some reason, I've tried that. And thats not it. I think its because of its a Prop Getting launched, so the Collision would have to be diffrent. I just don't know how to change that!
[editline]4th August 2013[/editline]
Also I don't know how to do the timer.
[editline]4th August 2013[/editline]
Bump. Please anyone?
[CODE]Entity:SetCollisionGroup( number group )[/CODE]
And the numbers relates to the [URL=http://wiki.garrysmod.com/page/Enums/COLLISION]Collision ENUMS[/URL]
Try actually doing it yourself from here instead of asking to be spoonfed
[QUOTE=rejax;41704037][CODE]Entity:SetCollisionGroup( number group )[/CODE]
And the numbers relates to the [URL=http://wiki.garrysmod.com/page/Enums/COLLISION]Collision ENUMS[/URL]
Try actually doing it yourself from here instead of asking to be spoonfed[/QUOTE]
Thank you for the Collisions. I know I've been being kind of... Yeah. lolz Thanks for everyones help. If I get done. I'll probably post the code on Steam or something. I'll be sure to give you guys some credit.
Sorry, you need to Log In to post a reply to this thread.