I need to know what 'end' expected (to close 'if' at line 45) near '<eof>' means to fix my weapon.
Can someone tell me what it means?
We can only tell you what it means if you post your code.
Means you've got one too few "end"s in your code. You'll have to post it for anyone to be able to tell you where the missing one's supposed to be, though.
[QUOTE=mahalis;19397494]Means you've got one too few "end"s in your code. You'll have to post it for anyone to be able to tell you where the missing one's supposed to be, though.[/QUOTE]
I made this rather quick so there might be more bugs in it.
[lua]
// Variables that are used on both client and server
SWEP.Author = "Battlepope"
SWEP.Contact = "n/a"
SWEP.Purpose = "Shooting Rockets"
SWEP.Instructions = "Primary= Shoot Rockets"
SWEP.ViewModelFOV = 54
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_mll.mdl"
SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl"
SWEP.AnimPrefix = "rpg"
SWEP.Category = "Other"
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.Primary.ClipSize = 1 // Size of a clip
SWEP.Primary.DefaultClip = 6 // Default number of bullets in a clip
SWEP.Primary.Automatic = false // Automatic/Semi Auto
SWEP.Primary.Ammo = "CombineCannon"
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 = ""
function SWEP:Initialize()
end
function SWEP:Precache()
util.PrecacheSound("NPC_Helicopter.FireRocket")
util.PrecacheSound("Buttons.snd14")
end
function SWEP:Deploy()
self.Weapon:SendWeaponAnim( ACT_VM_DEPLOY )
end
function SWEP:PrimaryAttack()
if tr.Entity:GetClass() != "npc_manhack" then Fire = 1
if tr.Entity:GetClass() != "npc_strider" then Fire = 1
if tr.Entity:GetClass() != "npc_combinegunship" then Fire = 1
if tr.Entity:GetClass() != "npc_combinedropship" then Fire = 1
if tr.Entity:GetClass() != "npc_helicopter" then Fire = 1
else
Fire = 0
end
if (Fire == 1 || self:Clip1() < 2 ) then
self.Weapon:SetNextPrimaryFire( CurTime() + 1.5 )
self.Weapon:EmitSound( NPC_Helicopter.FireRocket )
self:SetClip1( self:Clip1() -1 )
self:FireRocket()
self.Weapon:TakePrimaryAmmo( 1 )
self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
else
end
end
function SWEP:FireRocket()
local aim = self.Owner:GetAimVector()
local side = aim:Cross(Vector(0,0,1))
local up = side:Cross(aim)
local pos = self.Owner:GetShootPos() + aim * 24 + side * 8 + up * -1 --offsets the rocket so it spawns from the muzzle (hopefully)
local rocket = ents.Create("bazooka_round")
if !rocket:IsValid() then return false end
rocket:SetAngles(aim:Angle())
rocket:SetPos(pos)
rocket:SetOwner(self.Owner)
rocket:Spawn()
rocket:Activate()
rocket:SetVelocity(rocket:GetForward()*3000)
end
function SWEP:SecondaryAttack()
end
function SWEP:Reload()
if self:DefaultReload( ACT_VM_RELOAD ) then
self:EmitSound(Sound("weapons/rpg/rpg_reload.wav"))
end
end
end
[/lua]
And the full length lua error is:
weapons\weapon_launcher\shared.lua:93: 'end' expected (to close 'if' at line 45) near '<eof>'
[lua]function SWEP:PrimaryAttack()
if tr.Entity:GetClass() != "npc_manhack" then Fire = 1
if tr.Entity:GetClass() != "npc_strider" then Fire = 1
if tr.Entity:GetClass() != "npc_combinegunship" then Fire = 1
if tr.Entity:GetClass() != "npc_combinedropship" then Fire = 1
if tr.Entity:GetClass() != "npc_helicopter" then Fire = 1
else
Fire = 0
end[/lua] is very very wrong.
[QUOTE=Lexic;19398850][lua]function SWEP:PrimaryAttack()
if tr.Entity:GetClass() != "npc_manhack" then Fire = 1
if tr.Entity:GetClass() != "npc_strider" then Fire = 1
if tr.Entity:GetClass() != "npc_combinegunship" then Fire = 1
if tr.Entity:GetClass() != "npc_combinedropship" then Fire = 1
if tr.Entity:GetClass() != "npc_helicopter" then Fire = 1
else
Fire = 0
end[/lua] is very very wrong.[/QUOTE]
probably, but its hard to improve with no tips.
[QUOTE=Battlepope98;19398857]probably[/QUOTE]
Not probably, [i]is[/i].
This is a lot better, though I don't know why you made it so it can't fire if it's got a clip of more than one.
[lua]function SWEP:PrimaryAttack()
local class = self:GetOwner():GetEyeTraceNoCursor().Entity:GetClass();
if (class == "npc_manhack" or class == "npc_strider" or class == "npc_combinegunship" or
class == "npc_combinedropship" or class == "npc_helicopter") then
return false
elseif (self:Clip1() < 2 ) then
self.Weapon:SetNextPrimaryFire( CurTime() + 1.5 )
self.Weapon:EmitSound( NPC_Helicopter.FireRocket )
self:SetClip1( self:Clip1() -1 )
self:FireRocket()
self.Weapon:TakePrimaryAmmo( 1 )
self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
end
end[/lua]
[QUOTE=Lexic;19398919]
This is a lot better, though I don't know why you made it so it can't fire if it's got a clip of more than one.
*lua*
[/QUOTE]
Ok, now one problem down, back to the original lua error.
P.S. Thank you Lexic for correcting that.
[QUOTE=Battlepope98;19399093]Ok, now one problem down, back to the original lua error.
P.S. Thank you Lexic for correcting that.[/QUOTE]
What? That was supposed to fix the error you originally stated.
[QUOTE=Lexic;19399124]What? That was supposed to fix the error you originally stated.[/QUOTE]
It did, But I just tested the new script and it does not fire at all, even when pointed at the selected npcs.
Sorry, you need to Log In to post a reply to this thread.