Any help at all will be appreciated. I am a noob to Lua
1. How to make certain groups get a certain weapon, to be more exact I want my 'donator' group to spawn with a lightsaber. Also please if you know, tell me where that code should go/be called. And is there anything in my lightsaber code that interferes with the other code please tell.
2. SWEP.HoldType = ? What goes there?
3. SWEP.Kind = ? What goes here
If you answer 1 or all it will be very appreciated.
How can we tell you if your lightsaber code interferes with the gamemode? You didn't [b]post your lightsaber code[/b].
As for the SWEP shit,
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index0e63.html[/url]
Ok, I am on my phone, I will get it in a sec
Look at the other TTT weapons
here is the lightsaber code: its long, my friend did something in the middle, which i think is a force jump, he wasnt quite clear on it.
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
end
SWEP.HoldType = "melee2"
if ( CLIENT ) then
SWEP.PrintName = "Jedi LightSaber"
SWEP.Slot = 0
SWEP.DrawCrosshair = false
killicon.AddFont( "weapon_knife", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
end
function SWEP:JumpReset()
self.JumpRefire = true
end
function SWEP:Think()
if self.Owner:KeyDown(IN_JUMP) then
if self.Owner:IsOnGround() then
self.Owner:SetVelocity(Vector(0,0,500))
end
end
//Jump think
if self.InAirDmg == 1 then
local trace = {}
trace.start = self.Owner:GetPos()
trace.endpos = self.Owner:GetPos() + (self.Owner:GetUp() * -10)
trace.filter = self.Owner
local tr2 = util.TraceLine(trace)
self.Owner:SetHealth(self.PrevHP)
if tr2.Hit then
self.InAirDmg = 0
self.JumpRefire = false
self.Weapon:SetNextSecondaryFire(CurTime() + 0.8)
self.Weapon:SetNextPrimaryFire(CurTime() + 0.3)
if SERVER then self.Owner:EmitSound(Sound("player/pl_pain5.wav")) end
else
local ang = self.Owner:GetAimVector()
local spos = self.Owner:GetShootPos()
local trace = {}
trace.start = spos
trace.endpos = spos + (ang * 150)
trace.filter = self.Owner
local tr = util.TraceLine(trace)
if tr.HitNonWorld and self.JumpRefire == true then
self.JumpRefire = false
local bullet = {}
bullet.Num=5
bullet.Src = self.Owner:GetShootPos()
bullet.Dir= self.Owner:GetAimVector()
bullet.Spread = Vector(0.1,0.1,0.1)
bullet.Tracer = 0
bullet.Force = 500
bullet.Damage = 200
self.Owner:FireBullets(bullet)
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
timer.Simple(0.5,self.JumpReset,self)
if SERVER then self.Owner:EmitSound(Sound("npc/vort/claw_swing"..tostring(math.random(1,2))..".wav")) end
if SERVER then self.Owner:EmitSound(Sound("ls/lightsaber_swing"..tostring(math.random(1,3))..".wav")) end
end
end
end
end
function SWEP:Initialize()
util.PrecacheSound("physics/flesh/flesh_impact_bullet" .. math.random( 3, 5 ) .. ".wav")
util.PrecacheSound("weapons/iceaxe/iceaxe_swing1.wav")
self:SetWeaponHoldType("melee")
end
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + .50)
local trace = self.Owner:GetEyeTrace()
if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
bullet = {}
bullet.Num = 1
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(0, 0, 0)
bullet.Tracer = 0
bullet.Force = 0
bullet.Damage = 1000
self.Owner:FireBullets(bullet)
self.Owner:SetAnimation( PLAYER_ATTACK1 );
self.Weapon:EmitSound("ls/lightsaber_swing" .. math.random( 3, 5 ) .. ".wav")
else
self.Weapon:EmitSound("ls/ls_throw")
self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER)
self.Owner:SetAnimation( PLAYER_ATTACK1 )
end
end
SWEP.InAirDmg = 0
function SWEP:SecondaryAttack()
if SERVER then self.Owner:EmitSound(Sound("ls/lightsaber_swing"..tostring(math.random(2,3))..".wav")) end
if SERVER then self.Owner:EmitSound(Sound("player/suit_sprint.wav")) end
self.Weapon:SetNextSecondaryFire(CurTime() + 100)
self.Weapon:SetNextPrimaryFire(CurTime() + 100)
self.PrevHP = self.Owner:Health()
if SERVER then self.Owner:SetVelocity(self.Owner:GetForward() * 400 + Vector(0,0,400)) end
timer.Simple(0.2,self.SecondaryAttackDelay,self)
end
function SWEP:SecondaryAttackDelay()
self.InAirDmg = 1
self.JumpRefire = true
end
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
SWEP.Base = "weapon_tttbase"
SWEP.ViewModel = "models/weapons/v_crewbar.mdl"
SWEP.WorldModel = "models/weapons/w_crewbar.mdl"
SWEP.Primary.Delay = 3
SWEP.Primary.Recoil = 0
SWEP.Primary.Damage = 32
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Secondary.Delay = 120
SWEP.Secondary.Recoil = 0
SWEP.Secondary.Damage = 0
SWEP.Secondary.NumShots = 1
SWEP.Secondary.Cone = 0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
SWEP.InLoadoutFor = {ROLE_DETECTIVE, ROLE_INNOCENT, ROLE_TRAITOR}
SWEP.Kind = WEAPON_MELEE
SWEP.WeaponID = AMMO_CROWBAR
SWEP.NoSights = true
SWEP.IsSilent = true
SWEP.AutoSpawnable = false
SWEP.AllowDelete = false
SWEP.AllowDrop = false
function SWEP:Deploy()
self.Weapon:EmitSound( "weapons/knife/knife_deploy1.wav" )
end
And yes. CrewBar is its model.
What the hell is going on in that code? Also use lua tags.
But why don't you just use the TTT crowbar code?
Ok, but i still havent figured out how to make it spawn for donors only :/
Well that code probably won't work at all, it's horribly written and copied from some other knife swep with a bunch of bullshit copy pasted in. As I said, look at the TTT crowbar's code
*sigh* ok, i will do that but that still doesnt answer my question.
If your wondering how to make donors and certain ranks spawn with weapons this is a simple code for it
I personally use pointshop and make donors choose which weapon they want
[LUA]
if SERVER then // This is where the init.lua stuff goes.
//This makes sure clients download the file
AddCSLuaFile("weaponspawn.lua")
end
--I added some default classes put you can do your own
local function giveWeapon(ply)
if ply:CheckGroup("donator") or ply:CheckGroup("moderator") or ply:CheckGroup("admin") then
ply:Give("Weapon you want")
end
end
hook.Add("PlayerLoadout", "giverankedWeapon", giveWeapon)
[/LUA]
Hope this helps
Where's the crowbar file? Sorry if this is stupid, but I'm trying the same thing, except I can't seem to find it. Is it weapon_ttt_unarmed?
[QUOTE=LilSumac;39518819]Where's the crowbar file? Sorry if this is stupid, but I'm trying the same thing, except I can't seem to find it. Is it weapon_ttt_unarmed?[/QUOTE]
Crowbar file is in garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_unarmed
If you want my advice just copy the lua file make a new one, paste it in then change the model from the crowbar to your lightsaber
[QUOTE=TryHardCoder;39519406]Crowbar file is in garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_unarmed
If you want my advice just copy the lua file make a new one, paste it in then change the model from the crowbar to your lightsaber[/QUOTE]
Says in the code that weapon_ttt_unarmed is slot number 5, which is the actual 'no weapon' slot.
[QUOTE=LilSumac;39519641]Says in the code that weapon_ttt_unarmed is slot number 5, which is the actual 'no weapon' slot.[/QUOTE]
Oh really i will double check because last time i saw it it was in there
[editline]8th February 2013[/editline]
Oh shit you were right thanks for telling me I hate giving false info its:
garrysmod/gamemodes/terrortown/entities/weapons/weapon_zm_improvised
There we go :dance:
[QUOTE=TryHardCoder;39519702]Oh really i will double check because last time i saw it it was in there
[editline]8th February 2013[/editline]
Oh shit you were right thanks for telling me I hate giving false info its:
garrysmod/gamemodes/terrortown/entities/weapons/weapon_zm_improvised
There we go :dance:[/QUOTE]
Thanks a lot! :v:
Sorry, you need to Log In to post a reply to this thread.