• Need help for swep
    27 replies, posted
I just finished a swep, and i tried to test it, didnt show up. This happened to me before, and now i am fustrated, heres the lua: [lua] if (SERVER) then AddCSLuaFile("shared.lua") SWEP.HoldType = "ar2" end if ( CLIENT ) then SWEP.PrintName = "Admin Para" SWEP.Author = "Wombo" SWEP.Slot = 2 SWEP.SlotPos = 1 SWEP.IconLetter = "b" SWEP.Instructions = "Use left for a brutal machine gun" SWEP.Contact = "Wombo194@comcast.net" SWEP.Purpose = "To handle most mingbag situations" killicon.AddFont( "weapon_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end SWEP.Base = "swep_base" SWEP.AdminSpawnable = true SWEP.Spawnable = false SWEP.ViewModel = "models/weapons/v_mach_m249para.mdl" SWEP.WorldModel = "models/weapons/w_mach_m249para.mdl" SWEP.ViewModelFlip = true SWEP.DrawCrosshair = true SWEP.Weight = 4 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false SWEP.FiresUnderwater = true SWEP.Category = "Admin" SWEP.DrawAmmo = true swep.ViewModelFOV = 64 SWEP.Primary.Sound = Sound("Weapon_M249.Single") SWEP.Primary.Reload = Sound( "Weapon_M249.Reload" ) SWEP.Primary.Empty = Sound( "Weapon_M249.Empty" ) SWEP.Primary.Damage = 100000 SWEP.Primary.TakeAmmo = 1 SWEP.Primary.ClipSize = 100000 SWEP.Primary.Ammo = "smg1" SWEP.Primary.DefaultClip = 10000 SWEP.Primary.Spread = .1 SWEP.Primary.NumbShots = 4 SWEP.Primary.Automatic = true SWEP.Primary.Recoil = .2 SWEP.Primary.RecoilXRand = .3 SWEP.Primary.RecoilYRand = 0.1 SWEP.Primary.Delay = .1 SWEP.Primary.Force = 100000 SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.IronSightsPos = Vector (-4.4153, 0, 2.1305) SWEP.IronSightsAng = Vector (0, 0, 0) SWEP.RunArmOffset = Vector (2.2344, -2.2257, 1.7539) SWEP.RunArmAngle = Vector (-19.3086, 29.9962, 0) self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) if ( !self:CanPrimaryAttack() ) then return end self.Weapon:EmitSound( self.Primary.Sound ) self:TakePrimaryAmmo( 1 ) self.Owner:ViewPunch( Angle( math.Rand(-self.Primary.RecoilXRand,-self.Primary.RecoilXRand) * self.Primary.Recoil, math.Rand(self.Primary.RecoilYRand,-self.Primary.RecoilYRand) *self.Primary.Recoil, 0 ) ) end function SWEP:Think() local trace = self.Owner:GetEyeTrace() if self.Owner:Health() < 100 then self.Owner:SetHealth(self.Owner:Health()+1) end function SWEP:CanPrimaryAttack() if ( self.Weapon:Clip1() <= 0 ) then self:EmitSound( "Weapon_Pistol.Empty" ) self:SetNextPrimaryFire( CurTime() + 0.2 ) self:Reload() return false return true end function SWEP:Reload() //if ( CLIENT ) then return end self:SetIronsights( false ) if ( self.Weapon:GetNetworkedBool( "reloading", true ) ) then return end if ( self.Weapon:Clip1() < self.Primary.ClipSize && self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 ) then self.Weapon:SetNetworkedBool( "reloading", true ) self.Weapon:SetVar( "reloadtimer", CurTime() + 0.3 ) self.Weapon:SendWeaponAnim( ACT_VM_RELOAD ) end function SWEP:ShootBullet( damage, num_bullets, aimcone ) local bullet = {} bullet.Num = num_bullets bullet.Src = self.Owner:GetShootPos() // Source bullet.Dir = self.Owner:GetAimVector() // Dir of bullet bullet.Spread = Vector( aimcone, aimcone, 0 ) // Aim Cone bullet.Tracer = 5 // Show a tracer on every x bullets bullet.TracerName = "Tracer" // what Tracer Effect should be used bullet.Force = 300 // Amount of force to give to phys objects bullet.Damage = damage bullet.AmmoType = "smg" self.Owner:FireBullets( bullet ) self:ShootEffects() end function SWEP:TakePrimaryAmmo( num ) if ( self.Weapon:Clip1() <= 0 ) then if ( self:Ammo1() <= 0 ) then return end self.Owner:RemoveAmmo( num, self.Weapon:GetPrimaryAmmoType() ) self.Weapon:SetClip1( self.Weapon:Clip1() - num ) return end function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha ) draw.SimpleText( <IconLetter>, <FontName>, x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER ) function SWEP:DrawWorldModel() self.Weapon:DrawModel() function SWEP:Deploy() self.Weapon:SendWeaponAnim(ACT_VM_DRAW) return true function SWEP:ShootEffects() self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // View model animation self.Owner:MuzzleFlash() // Crappy muzzle light self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation function SWEP:PrimaryAttack() self.Weapon:EmitSound("Weapon_M249.Single") self:ShootBullet( 150, 1, 0.75 ) self.Owner:ViewPunch( Angle( -1, 0, 0 ) ) end function SWEP:Deploy() self.Owner:SetRunSpeed(3000) self.Owner:SetJumpPower(1200) self.Owner:ChatPrint("") return true end function SWEP:Holster() self.Owner:SetRunSpeed(800) self.Owner:SetJumpPower(300) self.Owner:ChatPrint("") self.Owner:SetHealth(90000) return true end [/lua] Edit:updated, will still not working, help. Edit AGAIN: i cleaned the code up and added some stuff, but im still getting the same console error, which is the cause of it not showing up, what do i need to do?
Did you make a info.txt? "AddonInfo" { "name" "Name" "version" "Version" "up_date" "" "author_name" "Your name" "author_email" "Your Email" "author_url" "" "info" "" } Save that in a txt file and put it in your sweps folder.
Ya i have a info txt, here it is if i did it wrong "AddonInfo" { "name" "Admin Para" "version" "3" "up_date" "When it's done" "author_name" "Wombo" "author_email" "Wombo194@comcast.net" "author_url" "www.wombosstuff.webs.com" "info" "A very powereful machine gun, admin only" }
[QUOTE=I Fail At Lua;19887247]Did you make a info.txt? Save that in a txt file and put it in your sweps folder.[/QUOTE] Go away. Your problem is you're missing a lot of things. I assume the code block beneath the variable declarations is supposed to go in SWEP:PrimaryAttack(), and you're missing an "end" in the SWEP:Think(). Plus, I don't think CSShootBullet is a valid function.
will that solve the problem of it even showing up?
Theres no SWEP:PrimaryAttack() function...anywhere.
[QUOTE=Wombo194;19888074]will that solve the problem of it even showing up?[/QUOTE] If there is an error in your weapon, it will not show up anywhere.
ok, sorry if im being noobish, im new to lua.
[QUOTE=Wombo194;19888074]will that solve the problem of it even showing up?[/QUOTE] Use notepad ++ then use gmod 10 lua, it makes things easier.
-Snip- look at top
Bump, still need help
bump again, please help!
Try setting SWEP.Spawnable to true and if it shows then it's probably a problem with the server script.
that will make it spawnable by everyone, and its a admin gun
how hard is it to get help? Seriously, HELP
Try putting give myweapon in the console, replacing myweapon with the classname of your weapon. See if it gives you the weapon.
Most people won't help someone who goes "HELP HELP HELP." Please, if you want us to help you, then search your console for the error that your weapon is causing.
k, got a console error, here it is weapons/weapon_admin_para/shared.lua:83: '<eof>' expected near 'end' sorry for being noobish
So it's a syntax error, seems like you've got too many ends. The thing is, you really should fix the indentation on your code, helps us read it and would make it easier to uncover this sort of error.
Sorry for bringing up this topic again but it still wont even show up :( What do i need to do?
Jesus dude... After you realize the weapon isn't working, look through the ENTIRE console for any errors. Post the error HERE, and he will do our best to help you unless you act like those people who say, "ITS SO SIMPLE HELP" If it's so simple, YOU go do it.
You are missing so many ends, about 7 lines of code are not in a function, and why are you returning in nearly every function?
[QUOTE=Chad Mobile;20017657]Jesus dude... After you realize the weapon isn't working, look through the ENTIRE console for any errors. Post the error HERE, and he will do our best to help you unless you act like those people who say, "ITS SO SIMPLE HELP" If it's so simple, YOU go do it.[/QUOTE] I already did, read most of the topic, anyways ill try do that, and clean up my code a bit. Also, its not that it isnt working, its not showing up.
Read the console for all the errors.
There won't be any other errors until he fixes that one. He just needs to add in a bunch of ends, and I doubt that anyone wants to do that for him.
how helpful for a person thats new to lua, trying to figure things out. I guess i don't blame you, nobody is going to help somebody do their work, even if they are new.
Not with that attitude, for sure. They already told you what the error may be caused by. The lack of "end" in your code. Check your code. After each "function" and "if", forexample: [lua]function Admin(ply) if ply:IsAdmin then ply:Give("admin_para") end -- end of "if" end -- end of "function"[/lua]
problem solved! Like i said, im a bit new to lua, but i understand my mistakes now.
Sorry, you need to Log In to post a reply to this thread.