• Prop swep. Help!
    2 replies, posted
I want my swep to spawn a "models/props_junk/wood_crate001a.mdl" that can't move but is still breakable. For the swep secondary I want it to be able to remove the prop you are looking at when you right click, if it's your prop. This is for a gamemode i'm working on. I'd appreciate it if someone would help me. This is what I have so far. (Attempt to make it spawn a prop for primary.) When Ever I try to load it i get this error: " weapons/weapon_build/shared.lua:146: '<eof>' expected near 'end' ". So of course, I haven't been able to test what I have done so far. [lua] // Variables that are used on both client and server SWEP.Author = "Maxterchief" SWEP.Contact = "" SWEP.Purpose = "Build Stuff" SWEP.Instructions = "Build Stuff" SWEP.ViewModelFOV = 62 SWEP.ViewModelFlip = false SWEP.ViewModel = "models/weapons/v_pistol.mdl" SWEP.WorldModel = "models/weapons/w_pistol.mdl" SWEP.AnimPrefix = "python" SWEP.Spawnable = false SWEP.AdminSpawnable = false SWEP.Primary.ClipSize = 1 // Size of a clip SWEP.Primary.DefaultClip = 1 // Default number of bullets in a clip SWEP.Primary.Automatic = false // Automatic/Semi Auto SWEP.Primary.Ammo = "Pistol" SWEP.Secondary.ClipSize = 1 // Size of a clip SWEP.Secondary.DefaultClip = 1 // Default number of bullets in a clip SWEP.Secondary.Automatic = false // Automatic/Semi Auto SWEP.Secondary.Ammo = "Pistol" /*--------------------------------------------------------- Name: SWEP:Initialize( ) Desc: Called when the weapon is first loaded ---------------------------------------------------------*/ function SWEP:Initialize() end /*--------------------------------------------------------- Name: SWEP:Precache( ) Desc: Use this function to precache stuff ---------------------------------------------------------*/ function SWEP:Precache() end /*--------------------------------------------------------- Name: SWEP:PrimaryAttack( ) Desc: +attack1 has been pressed ---------------------------------------------------------*/ function SWEP:PrimaryAttack() // Make sure we can shoot first if ( !self:CanPrimaryAttack() ) then return end // Play shoot sound self.Weapon:EmitSound("Weapon_AR2.Single") propbox = ents.Create( "prop_physics" ) propbox:SetModel( "models/props_junk/wood_crate001a.mdl" ) propbox:SetPos( self.Owner:GetShootPos() ) propbox:SetAngles( self.Owner:GetAngles() ) propbox:EnableMotion( 0 ) propbox:SetOwner( self.Owner ) propbox:Spawn( ) end /*--------------------------------------------------------- Name: SWEP:SecondaryAttack( ) Desc: +attack2 has been pressed ---------------------------------------------------------*/ function SWEP:SecondaryAttack() // Make sure we can shoot first if ( !self:CanSecondaryAttack() ) then return end // Play shoot sound self.Weapon:EmitSound("sound\buttons\button19.wav") self.Owner:ViewPunch( Angle( -10, 0, 0 ) ) ------------- /*--------------------------------------------------------- Name: SWEP:CheckReload( ) Desc: CheckReload ---------------------------------------------------------*/ function SWEP:CheckReload() end /*--------------------------------------------------------- Name: SWEP:Reload( ) Desc: Reload is being pressed ---------------------------------------------------------*/ function SWEP:Reload() self.Weapon:DefaultReload( ACT_VM_RELOAD ); end /*--------------------------------------------------------- Name: SWEP:Think( ) Desc: Called every frame ---------------------------------------------------------*/ function SWEP:Think() end /*--------------------------------------------------------- Name: SWEP:Holster( weapon_to_swap_to ) Desc: Weapon wants to holster RetV: Return true to allow the weapon to holster ---------------------------------------------------------*/ function SWEP:Holster( wep ) return true end /*--------------------------------------------------------- Name: SWEP:Deploy( ) Desc: Whip it out ---------------------------------------------------------*/ function SWEP:Deploy() return true end /*--------------------------------------------------------- Name: SWEP:ShootBullet( ) Desc: A convenience function to shoot bullets ---------------------------------------------------------*/ function SWEP:ShootEffects() self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // View model animation self.Owner:MuzzleFlash() // Crappy muzzle light self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation end /*--------------------------------------------------------- Name: SWEP:ShootBullet( ) Desc: A convenience function to shoot bullets ---------------------------------------------------------*/ 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.Force = 1 // Amount of force to give to phys objects bullet.Damage = damage bullet.AmmoType = "Pistol" self.Owner:FireBullets( bullet ) self:ShootEffects() end /*--------------------------------------------------------- Name: SWEP:TakePrimaryAmmo( ) Desc: A convenience function to remove ammo ---------------------------------------------------------*/ function SWEP:TakePrimaryAmmo( num ) // Doesn't use clips if ( self.Weapon:Clip1() <= 0 ) then if ( self:Ammo1() <= 0 ) then return end self.Owner:RemoveAmmo( num, self.Weapon:GetPrimaryAmmoType() ) return end self.Weapon:SetClip1( self.Weapon:Clip1() - num ) end /*--------------------------------------------------------- Name: SWEP:TakeSecondaryAmmo( ) Desc: A convenience function to remove ammo ---------------------------------------------------------*/ function SWEP:TakeSecondaryAmmo( num ) // Doesn't use clips if ( self.Weapon:Clip2() <= 0 ) then if ( self:Ammo2() <= 0 ) then return end self.Owner:RemoveAmmo( num, self.Weapon:GetSecondaryAmmoType() ) return end self.Weapon:SetClip2( self.Weapon:Clip2() - num ) end /*--------------------------------------------------------- Name: SWEP:CanPrimaryAttack( ) Desc: Helper function for checking for no ammo ---------------------------------------------------------*/ function SWEP:CanPrimaryAttack() if ( self.Weapon:Clip1() <= 0 ) then self:EmitSound( "Weapon_Pistol.Empty" ) self:SetNextPrimaryFire( CurTime() + 0.2 ) self:Reload() return false end return true end /*--------------------------------------------------------- Name: SWEP:CanSecondaryAttack( ) Desc: Helper function for checking for no ammo ---------------------------------------------------------*/ function SWEP:CanSecondaryAttack() if ( self.Weapon:Clip2() <= 0 ) then self.Weapon:EmitSound( "Weapon_Pistol.Empty" ) self.Weapon:SetNextSecondaryFire( CurTime() + 0.2 ) return false end return true end /*--------------------------------------------------------- Name: ContextScreenClick( aimvec, mousecode, pressed, ply ) ---------------------------------------------------------*/ function SWEP:ContextScreenClick( aimvec, mousecode, pressed, ply ) end /*--------------------------------------------------------- Name: OnRemove Desc: Called just before entity is deleted ---------------------------------------------------------*/ function SWEP:OnRemove() end /*--------------------------------------------------------- Name: OwnerChanged Desc: When weapon is dropped or picked up by a new player ---------------------------------------------------------*/ function SWEP:OwnerChanged() end /*--------------------------------------------------------- Name: Ammo1 Desc: R
You forgot to close SWEP:SecondaryAttack() on line 73 [editline]12:59AM[/editline] What editor are you using? Most editors like notepad++ use a tree view of the functions you open/close. So you can see where a function starts and ends.
Try this, went through to find out end's were missing. Also some other things that [I]might[/I] cause a problem.. [lua]// Variables that are used on both client and server SWEP.Author = "Maxterchief" SWEP.Contact = "" SWEP.Purpose = "Build Stuff" SWEP.Instructions = "Build Stuff" SWEP.ViewModelFOV = 62 SWEP.ViewModelFlip = false SWEP.ViewModel = "models/weapons/v_pistol.mdl" SWEP.WorldModel = "models/weapons/w_pistol.mdl" SWEP.AnimPrefix = "python" SWEP.Spawnable = false SWEP.AdminSpawnable = false SWEP.Primary.ClipSize = 1 // Size of a clip SWEP.Primary.DefaultClip = 1 // Default number of bullets in a clip SWEP.Primary.Automatic = false // Automatic/Semi Auto SWEP.Primary.Ammo = "Pistol" SWEP.Secondary.ClipSize = 1 // Size of a clip SWEP.Secondary.DefaultClip = 1 // Default number of bullets in a clip SWEP.Secondary.Automatic = false // Automatic/Semi Auto SWEP.Secondary.Ammo = "Pistol" /*--------------------------------------------------------- Name: SWEP:Initialize( ) Desc: Called when the weapon is first loaded ---------------------------------------------------------*/ function SWEP:Initialize() end /*--------------------------------------------------------- Name: SWEP:Precache( ) Desc: Use this func to precache stuff ---------------------------------------------------------*/ function SWEP:Precache() end /*--------------------------------------------------------- Name: SWEP:PrimaryAttack( ) Desc: +attack1 has been pressed ---------------------------------------------------------*/ function SWEP:PrimaryAttack() // Make sure we can shoot first if ( !self:CanPrimaryAttack() ) then return end // Play shoot sound self.Weapon:EmitSound("Weapon_AR2.Single") propbox = ents.Create( "prop_physics" ) propbox:SetModel( "models/props_junk/wood_crate001a.mdl" ) propbox:SetPos( self.Owner:GetShootPos() ) propbox:SetAngles( self.Owner:GetAngles() ) propbox:EnableMotion( 0 ) propbox:SetOwner( self.Owner ) propbox:Spawn( ) end /*--------------------------------------------------------- Name: SWEP:SecondaryAttack( ) Desc: +attack2 has been pressed ---------------------------------------------------------*/ function SWEP:SecondaryAttack() // Make sure we can shoot first if ( !self:CanSecondaryAttack() ) then return end // Play shoot sound self.Weapon:EmitSound("sound\buttons\button19.wav") self.Owner:ViewPunch( Angle( -10, 0, 0 ) ) ------------- end /*--------------------------------------------------------- Name: SWEP:CheckReload( ) Desc: CheckReload ---------------------------------------------------------*/ function SWEP:CheckReload() end /*--------------------------------------------------------- Name: SWEP:Reload( ) Desc: Reload is being pressed ---------------------------------------------------------*/ function SWEP:Reload() self.Weapon:DefaultReload( ACT_VM_RELOAD ); end /*--------------------------------------------------------- Name: SWEP:Think( ) Desc: Called every frame ---------------------------------------------------------*/ function SWEP:Think() end /*--------------------------------------------------------- Name: SWEP:Holster( weapon_to_swap_to ) Desc: Weapon wants to holster RetV: Return true to allow the weapon to holster ---------------------------------------------------------*/ function SWEP:Holster( wep ) return true end /*--------------------------------------------------------- Name: SWEP:Deploy( ) Desc: Whip it out ---------------------------------------------------------*/ function SWEP:Deploy() return true end /*--------------------------------------------------------- Name: SWEP:ShootBullet( ) Desc: A convenience func to shoot bullets ---------------------------------------------------------*/ function SWEP:ShootEffects() self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // View model animation self.Owner:MuzzleFlash() // Crappy muzzle light self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation end /*--------------------------------------------------------- Name: SWEP:ShootBullet( ) Desc: A convenience func to shoot bullets ---------------------------------------------------------*/ 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.Force = 1 // Amount of force to give to phys objects bullet.Damage = damage bullet.AmmoType = "Pistol" self.Owner:FireBullets( bullet ) self:ShootEffects() end /*--------------------------------------------------------- Name: SWEP:TakePrimaryAmmo( ) Desc: A convenience func to remove ammo ---------------------------------------------------------*/ function SWEP:TakePrimaryAmmo( num ) // Doesn't use clips if ( self.Weapon:Clip1() <= 0 ) then if ( self:Ammo1() <= 0 ) then return end self.Owner:RemoveAmmo( num, self.Weapon:GetPrimaryAmmoType() ) return end self.Weapon:SetClip1( self.Weapon:Clip1() - num ) end /*--------------------------------------------------------- Name: SWEP:TakeSecondaryAmmo( ) Desc: A convenience func to remove ammo ---------------------------------------------------------*/ function SWEP:TakeSecondaryAmmo( num ) // Doesn't use clips if ( self.Weapon:Clip2() <= 0 ) then if ( self:Ammo2() <= 0 ) then return end self.Owner:RemoveAmmo( num, self.Weapon:GetSecondaryAmmoType() ) return end self.Weapon:SetClip2( self.Weapon:Clip2() - num ) end /*--------------------------------------------------------- Name: SWEP:CanPrimaryAttack( ) Desc: Helper func checking no ammo ---------------------------------------------------------*/ function SWEP:CanPrimaryAttack() if ( self.Weapon:Clip1() <= 0 ) then self:EmitSound( "Weapon_Pistol.Empty" ) self:SetNextPrimaryFire( CurTime() + 0.2 ) self:Reload() return false end return true end /*--------------------------------------------------------- Name: SWEP:CanSecondaryAttack( ) Desc: Helper func checking no ammo ---------------------------------------------------------*/ function SWEP:CanSecondaryAttack() if ( self.Weapon:Clip2() <= 0 ) then self.Weapon:EmitSound( "Weapon_Pistol.Empty" ) self.Weapon:SetNextSecondaryFire( CurTime() + 0.2 ) return false end return true end /*--------------------------------------------------------- Name: ContextScreenClick( aimvec, mousecode, pressed, ply ) ---------------------------------------------------------*/ function SWEP:ContextScreenClick( aimvec, mousecode, pressed, ply ) end /*--------------------------------------------------------- Name: OnRemove Desc: Called just before entity is deleted ---------------------------------------------------------*/ function SWEP:OnRemove() end /*--------------------------------------------------------- Name: OwnerChanged Desc: When weapon is dropped or picked up by a new player ---------------------------------------------------------*/ function SWEP:OwnerChanged() end /*--------------------------------------------------------- Name: Ammo1 Desc: Returns how much of ammo1 the player has ---------------------------------------------------------*/ function SWEP:Ammo1() return self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) end /*--------------------------------------------------------- Name: Ammo2 Desc: Returns how much of ammo2 the player has ---------------------------------------------------------*/ function SWEP:Ammo2() return self.Owner:GetAmmoCount( self.Weapon:GetSecondaryAmmoType() ) end /*--------------------------------------------------------- Name: SetDeploySpeed Desc: Sets the weapon deploy speed. This value needs to match on client and server. ---------------------------------------------------------*/ function SWEP:SetDeploySpeed( speed ) self.m_WeaponDeploySpe
Sorry, you need to Log In to post a reply to this thread.