• ERROR: GAMEMODE:'Tick' Failed
    2 replies, posted
I was working on a Proximity Bomb for my trouble in terrorist town server but when ever the weapon is on screen this error appears in console until the weapon is switched. ERROR: GAMEMODE:'Tick' Failed: [gamemodes\terrortown\gamemode\player.lua:1109] attempt to call method 'GetIronsights' (a nil value) i checked where the error is pointing to and all that on that line is [CODE]ply.scanner_weapon:Think()[/CODE] Any Help is much appreciated if it helps here is the code for the Weapon [CODE]if( SERVER ) then AddCSLuaFile( "shared.lua" ); end if CLIENT then SWEP.PrintName = "Proximity Bomb" SWEP.Slot = 6 SWEP.EquipMenuData = { type = "item_weapon", name = "Proximity Bomb", desc = "Left Click To Set. Right Click to set Proximity Distance. Reload to reset distance." }; end SWEP.Kind = WEAPON_EQUIP SWEP.CanBuy = {ROLE_TRAITOR} SWEP.WeaponID = AMMO_C4 SWEP.NoSights = true ------------------------------------------------------------------------------------------------------ SWEP.NextPlant = 0; SWEP.DetectRadius = 0; SWEP.IncrementNumber = 50; ------------------------------------------------------------------------------------------------------ SWEP.ViewModelFOV = 62 SWEP.ViewModelFlip = true ------------------------------------------------------------------------------------------------------ SWEP.Spawnable = false SWEP.AdminSpawnable = true ------------------------------------------------------------------------------------------------------ SWEP.ViewModel = "models/weapons/v_c4.mdl" SWEP.WorldModel = "models/weapons/w_c4.mdl" ------------------------------------------------------------------------------------------------------ SWEP.Primary.Delay = 0.9 SWEP.Primary.Recoil = 0 SWEP.Primary.Damage = 7 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0 SWEP.Primary.ClipSize = 1 SWEP.Primary.DefaultClip = 3 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" ------------------------------------------------------------------------------------------------------ SWEP.Secondary.Delay = 0.9 SWEP.Secondary.Recoil = 0 SWEP.Secondary.Damage = 6 SWEP.Secondary.NumShots = 1 SWEP.Secondary.Cone = 0 SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" ------------------------------------------------------------------------------------------------------ //Preload util.PrecacheSound("weapons/c4/c4_beep1.wav") util.PrecacheSound("weapons/c4/c4_plant.wav") util.PrecacheSound("radio/bombpl.wav") function SWEP:Initialize() end function SWEP:Precache() end function SWEP:Deploy() self.Weapon:EmitSound( "weapons/c4/c4_beep1.wav" ); return true; end function SWEP:PrimaryAttack() if( CurTime() < self.NextPlant ) then return; end self.NextPlant = ( CurTime() + .8 ); // local trace = {} trace.start = self.Owner:GetShootPos() trace.endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 64 trace.mask = MASK_NPCWORLDSTATIC trace.filter = self.Owner local tr = util.TraceLine( trace ) // local ent = ents.Create ("planted_proxbomb"); if ( ent && ent != NULL ) then if ( tr.Hit ) then ent:SetPos (trace.endpos); ent:SetVar("Radius", self.DetectRadius) ent:SetVar("Owner", self.Owner) ent:Spawn(); ent:Activate() self.Owner:EmitSound( "weapons/c4/c4_plant.wav" ); self.Owner:EmitSound( "radio/bombpl.wav" ); self.Owner:SetAnimation(PLAYER_ATTACK1) self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER) ent:GetTable():WallPlant( tr.HitPos + tr.HitNormal, tr.HitNormal ) //Cleanup for sandbox cleanup.Add (self.Owner, "props", ent); undo.Create ("Proximity Bomb"); undo.AddEntity (ent); undo.SetPlayer (self.Owner); undo.Finish(); end end end function SWEP:Reload() //Timer to stop chat overflow. if( CurTime() < self.NextPlant ) then return; end self.NextPlant = ( CurTime() + .2 ); self.DetectRadius = 0 self.Owner:ChatPrint("Proximity Radius has been reset to 0."); end function SWEP:SecondaryAttack() if( CurTime() < self.NextPlant ) then return; end self.NextPlant = ( CurTime() + .1 ); // Set Proximity Distance self.DetectRadius = 70 self.Weapon:EmitSound( "weapons/c4/c4_beep1.wav" ); self.Owner:ChatPrint("Proximity Radius has been set to "..self.DetectRadius.."."); end [/CODE] Side note: this was something i found on garrymod.org that i am modifying to work with the ttt gamemode
I checked the copy of player.lua in my Garry's Mod .gcf file, and the contents of that line for me are: if ValidEntity(wep) and wep:GetIronsights() then The gamemode assumes that the player's weapon has implemented a :GetIronSights() method somehow. Your code doesn't implement such a method for your weapon, so, naturally, when it indexes your weapon with "GetIronSights", it returns the value 'nil', and when it tries to call that value, you're getting that error. Judging from the Terrortown code, I'm guessing that method indicates if the player is using the iron sights on the weapon or not. So the simplest solution would be to add this line to your code: function SWEP:GetIronSights() return false end
[QUOTE=Infectious;37391549]I checked the copy of player.lua in my Garry's Mod .gcf file, and the contents of that line for me are: if ValidEntity(wep) and wep:GetIronsights() then The gamemode assumes that the player's weapon has implemented a :GetIronSights() method somehow. Your code doesn't implement such a method for your weapon, so, naturally, when it indexes your weapon with "GetIronSights", it returns the value 'nil', and when it tries to call that value, you're getting that error. Judging from the Terrortown code, I'm guessing that method indicates if the player is using the iron sights on the weapon or not. So the simplest solution would be to add this line to your code: function SWEP:GetIronSights() return false end[/QUOTE] Alright thanks ill try that
Sorry, you need to Log In to post a reply to this thread.