• SWEP auto kicking people for LUA when used
    11 replies, posted
HI. I have a swep that will auto kick anyone who is on the server, and also the gun wont make a sound. Here is the code: [CODE]if SERVER then AddCSLuaFile( "shared.lua" ) resource.AddFile("models/weapons/v_minigun.mdl") resource.AddFile("models/weapons/v_minigun.dx80.vtx") resource.AddFile("models/weapons/v_minigun.dx90.vtx") resource.AddFile("models/weapons/v_minigun.vtx") resource.AddFile("models/weapons/v_minigun.vvd") resource.AddFile("models/weapons/v_minigun.phy") resource.AddFile("models/weapons/w_minigun.mdl") resource.AddFile("models/weapons/w_minigun.dx80.vtx") resource.AddFile("models/weapons/w_minigun.dx90.vtx") resource.AddFile("models/weapons/w_minigun.vtx") resource.AddFile("models/weapons/w_minigun.vvd") resource.AddFile("models/weapons/w_minigun.phy") resource.AddFile("sound/ttt/mini_chain.wav") resource.AddFile("sound/ttt/mini_bolt.wav") resource.AddFile("sound/ttt/spindown.wav") resource.AddFile("sound/ttt/mini_boxin.wav") resource.AddFile("sound/ttt/spinup.wav") end function SWEP:Holster() timer.Simple(15,function() if self.Owner then self.Owner:Kill() end end) end SWEP.HoldType = "ar2" if CLIENT then SWEP.PrintName = "Minigun" SWEP.Slot = 6 SWEP.EquipMenuData = { type = "item_weapon", desc = "Mini Gun.\nYou get auto slain after 15 seconds of equip.\nLast resort\nYou get 750 bullets" }; SWEP.Icon = "NTG/zeph_icon_minigun" end SWEP.Base = "weapon_tttbase" SWEP.Primary.Recoil = .001 SWEP.Primary.Damage = 2 SWEP.Primary.Delay = .0003 SWEP.Primary.Cone = .06 SWEP.Primary.ClipSize = 750 SWEP.Primary.Automatic = true SWEP.Primary.DefaultClip = 750 SWEP.Primary.ClipMax = 750 SWEP.Primary.Ammo = "minigun" SWEP.Kind = WEAPON_EQUIP SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy SWEP.WeaponID = AMMO_MINIGUN SWEP.LimitedStock = true SWEP.AmmoEnt = "item_ammo_minigun_ttt" SWEP.IsSilent = false SWEP.ViewModelFlip = false SWEP.AllowDrop = false SWEP.ViewModel = "models/weapons/v_minigun.mdl" SWEP.WorldModel = "models/weapons/w_minigun.mdl" SWEP.Primary.Sound = Sound( "sound/ttt/spinup" ) function SWEP:OnDrop() if( SERVER )then self:Remove() end end SWEP.Secondary.Sound = Sound("Default.Zoom") SWEP.IronSightsPos = Vector( 5, -15, -2 ) SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 ) SWEP.NoSights = true[/CODE]
[QUOTE='garry;39737459'] If you are posting a Lua error you're getting - then POST THE FULL ERROR AND THE CODE. Make sure you are posting the FIRST error you're getting - not the last error. Do not post huge scripts and expect people to fix them. If you wrote the script then you should know why it doesn't work. If you're editing someone's script and can't get it to work then don't! Learn how to code! [/QUOTE]
Could you at least post the error you're getting?
There are no errors, it is just the swep
Not sure if this is the reason, but your ammo type is not valid. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8d04-2.html[/url]
I don't want people picking up ammo for it
ok, but the ammo type is the bullet so you need "SWEP.Primary.Ammo = "minigun" " to be a valid bullet type otherwise the bullet isn't valid. Ammoent can stay your minigun ammo
[QUOTE='[TET] Tobias;40306425'][code] function SWEP:OnDrop() if( SERVER )then self:Remove() end end [/CODE][/QUOTE]You ended this statement twice maybe that could be a problem?
[QUOTE=ElPaul;40318747]You ended this statement twice maybe that could be a problem?[/QUOTE] Do you write lua? The function is ended and the statement is ended...
[QUOTE=Pandaman09;40318792]Do you write lua? The function is ended and the statement is ended...[/QUOTE] I'm a beginner, I only recently started
Here, I have the error Timer Failed! [Simple][@gamemodes/terrortown/entities/weapons/weapon_ttt_minigun/shared.lua (line 25)] D
What color was the error? (Was it client sided or server sided) [editline]17th April 2013[/editline] Try using this instead: [lua] function SWEP:Holster() if SERVER then timer.Simple(15, function() if self.Owner:IsValid() and self.Owner:Alive() then self.Owner:Kill() end end) end end [/lua]
Sorry, you need to Log In to post a reply to this thread.