• Custom Addon Not Showing Up In 'Q' Menu!
    21 replies, posted
Hello, I've recently began learning Gmod lua to make SWEPs, I don't know much. But I've hit a problem, my custom addon has stopped showing up in the 'Q' menu under the weapons tab. My folder structure: [IMG]http://i42.tinypic.com/2ileyjl.png[/IMG] CODE: [CODE] //General Settings\\ if ( SERVER ) then AddCSLuaFile( "shared.lua" ); SWEP.HoldType = "ar2" end if ( CLIENT ) then SWEP.PrintName = "LEARNING" SWEP.Author = "[FG] Syntax" SWEP.Slot = 4 SWEP.SlotPos = 1 end SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.ViewModel = "models/weapons/v_smg1.mdl" SWEP.WorldModel = "models/weapons/w_smg1.mdl" SWEP.ViewModelFlip = true SWEP.Weight = 5 SWEP.AutoSwitchTo = true SWEP.AutoSwitchFrom = false SWEP.HoldType = "ar2" SWEP.FiresUnderwater = true SWEP.DrawCrosshair = false SWEP.Category = " AURELS AWESOME STUFF " SWEP.DrawAmmo = true SWEP.ReloadSound = "(NOT CHOSEN YET)" ------------------------------------------------------------ //PrimaryFire Settings\\ SWEP.Primary.Sound = "Weapon_SMG1.Single" SWEP.Primary.Damage = 48 SWEP.Primary.TakeAmmo = 1 SWEP.Primary.ClipSize = 48 SWEP.Primary.DefaultClip = 48 SWEP.Primary.Ammo = "SMG1" SWEP.Primary.Spread = 0.55 SWEP.Primary.NumberofShots = 1 SWEP.Primary.Automatic = true SWEP.Primary.Recoil = 5 SWEP.Primary.Delay = 0.8 SWEP.Primary.Force = 250 [/CODE] (Sorry about the misplacement of the code) If you could help, that would be wonderful. Thank You
-snipimretarded-
I'm not too sure on modelling, but I'm pretty sure 'SWEP.ViewModel' and 'SWEP.WorldModel' should be filled in?
Wouldn't it still show up without those fields filled in? And if it would then ignore them.
[code] //General Settings\\ AddCSLuaFile() -- Includes the file it is ran from SWEP.HoldType = "ar2" -- HoldType MUST be set shared to work properly. -- No reason to keep those clientside only, has no benefit SWEP.PrintName = "LEARNING" SWEP.Author = "[FG] Syntax" SWEP.Slot = 4 SWEP.SlotPos = 1 SWEP.Spawnable = true --SWEP.AdminSpawnable = true -- Outdated, doesn't do anything, remove it --SWEP.AdminOnly = true -- Use this to make it admin only SWEP.ViewModel = "models/weapons/v_smg1.mdl" SWEP.WorldModel = "models/weapons/w_smg1.mdl" SWEP.ViewModelFlip = true SWEP.Weight = 5 SWEP.AutoSwitchTo = true SWEP.AutoSwitchFrom = false SWEP.HoldType = "ar2" -- Okay you have it here, good SWEP.FiresUnderwater = true SWEP.DrawCrosshair = false SWEP.Category = " AURELS AWESOME STUFF " SWEP.DrawAmmo = true SWEP.ReloadSound = "(NOT CHOSEN YET)" ------------------------------------------------------------ //PrimaryFire Settings\\ SWEP.Primary.Sound = "Weapon_SMG1.Single" SWEP.Primary.Damage = 48 SWEP.Primary.TakeAmmo = 1 SWEP.Primary.ClipSize = 48 SWEP.Primary.DefaultClip = 48 SWEP.Primary.Ammo = "SMG1" SWEP.Primary.Spread = 0.55 SWEP.Primary.NumberofShots = 1 SWEP.Primary.Automatic = true SWEP.Primary.Recoil = 5 SWEP.Primary.Delay = 0.8 SWEP.Primary.Force = 250[/code]
Thanks, but it still doesn't show up! Any other ideas?
-snip- nevermind
This is what I used when I was making my first swep [CODE] //General Settings \\ SWEP.PrintName = "Gold Pistol" SWEP.Author = "Crazyman" SWEP.Instructions = "My Swep" SWEP.Contact = "" SWEP.Purpose = "Have Fun" SWEP.AdminSpawnable = true // Is the SWEP spawnable for admins? SWEP.Spawnable = true // Can everybody spawn this SWEP? - If you want only admins to spawn it, keep this false and admin spawnable true. SWEP.ViewModel = "models/weapons/v_pist_geagle.mdl" // The viewModel = the model you see when you're holding the weapon. SWEP.WorldModel = "models/weapons/w_pist_geagle.mdl" // The world model = the model you when it's down on the ground. SWEP.AutoSwitchTo = false // When someone picks up the SWEP, should it automatically change to your SWEP? SWEP.AutoSwitchFrom = true // Should the weapon change to the a different SWEP if another SWEP is picked up? SWEP.Slot = 1 // Which weapon slot you want your SWEP to be in? (1 2 3 4 5 6) SWEP.SlotPos = 1 // Which part of that slot do you want the SWEP to be in? (1 2 3 4 5 6) SWEP.HoldType = "Pistol" // How is the SWEP held? (Pistol SMG Grenade Melee) SWEP.FiresUnderwater = true // Does your SWEP fire under water? SWEP.Weight = 5 // Set the weight of your SWEP. SWEP.DrawCrosshair = true // Do you want the SWEP to have a crosshair? SWEP.Category = "Biobastards" // Which weapon spawning category do you want your SWEP to be in? SWEP.DrawAmmo = true // Does the ammo show up when you are using it? True / False SWEP.ReloadSound = "sound/Weapon_SMG1.Reload" // Reload sound, you can use the default ones, or you can use your own; Example; "sound/myswepreload.wav" SWEP.base = "weapon_cs_base" //What your weapon is based on. //General settings\\ //PrimaryFire Settings\\ SWEP.Primary.Sound = Sound( "Weapon_Deagle.Single" ) SWEP.Primary.Damage = 50 // How much damage the SWEP will do. SWEP.Primary.TakeAmmo = 1 // How much ammo does the SWEP use each time you shoot? SWEP.Primary.ClipSize = 16 // The clip size. SWEP.Primary.Ammo = "Pistol" // The ammo used by the SWEP. (pistol/smg1) SWEP.Primary.DefaultClip = 8 // How much ammo do you get when you first pick up the SWEP? SWEP.Primary.Spread = 0.1 // Do the bullets spread all over when firing? If you want it to shoot exactly where you are aiming, leave it at 0.1 SWEP.Primary.NumberofShots = 1 // How many bullets the SWEP fires each time you shoot. SWEP.Primary.Automatic = false // Is the SWEP automatic? SWEP.Primary.Recoil = 5 // How much recoil does the weapon have? SWEP.Primary.Delay = 0.6 // How long must you wait before you can fire again? SWEP.Primary.Force = 1000 // The force of the shot. SWEP.Primary.Cone = 0.02 SWEP.Primary.ClipMax = 36 //PrimaryFire settings\\ SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" //SWEP:PrimaryFire\\ function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end local bullet = {} bullet.Num = self.Primary.NumberofShots //The number of shots fired bullet.Src = self.Owner:GetShootPos() //Gets where the bullet comes from bullet.Dir = self.Owner:GetAimVector() //Gets where you're aiming bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0) //The above, sets how far the bullets spread from each other. bullet.Tracer = 0 bullet.Force = self.Primary.Force bullet.Damage = self.Primary.Damage bullet.AmmoType = self.Primary.Ammo local rnda = self.Primary.Recoil * -1 local rndb = self.Primary.Recoil * math.random(-1, 1) self:ShootEffects() self.Owner:FireBullets( bullet ) self:EmitSound(Sound(self.Primary.Sound)) self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) self:TakePrimaryAmmo(self.Primary.TakeAmmo) self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end [/CODE] This should show up but there will be no picture for it
It is important where you put it, for example: lua/weapons/weapon_myweapon.lua For weapons with one file. Also, is there anything in the console?
I didn't see anything in the console about the custom addon, and this is not going to be a single file weapon, I already have models, materials etc ready, I'll put those in later when I got it showing up.
[QUOTE='[FG] Syntax;42881578']I didn't see anything in the console about the custom addon, and this is not going to be a single file weapon, I already have models, materials etc ready, I'll put those in later when I got it showing up.[/QUOTE] By single file I meant single lua file.
Ok, I've tried making it a single lua file and putting it in that directory, but it didn't work! So I think that it might be a problem with the code.
It printed it. And I've also discovered this: [IMG]http://i43.tinypic.com/260wmep.png[/IMG] and this: [IMG]http://i40.tinypic.com/invedj.png[/IMG]
Delete 5-10 lines before and after like 15 and retype them manually. "Couldn't find" error is caused by the first error. Also, don't name your weapon class "weapons" rename it to something like weapon_mygun to keep it unique. ( lua/weapons/weapon_mygun/shared.lua )
Don't want to sound dumb, but delete the lines from the code you corrected?
Trial and error my friend. Keep backups of versions before you change though.
[QUOTE='[FG] Syntax;42885147']Don't want to sound dumb, but delete the lines from the code you corrected?[/QUOTE] From the code you have that provides the error. I myself experience this error sometimes, when the stack trace shows error on line 0 (zero) then there's a corrupt symbol or whatever that fucks up the script. The only way to fix this is to find the erroring line by commenting out all lines around the erroring line ( in your case 15 ) until the error on line 0 disappears and retyping the last commented line manually again. OR CTRL+Z to the last working state.
YAY! Your method worked, now I have a problem that when I change the recoil for example which is now set to 0, in the game it doesn't work this also happens with delay. And the secondary fire settings also don't work.
You need to script them to work, it's not just "edit the number and it works". See weapon_bases SWEP:PrimaryAttack and SWEP:SecondaryAttack
-snip- wrong thread [editline]16th November 2013[/editline] To answer the thread though, what did you use as your starting point?
Thanks for all the help!!!
Sorry, you need to Log In to post a reply to this thread.