Welcome, Guest. Please login or register.
Did you miss your activation email?
November 25, 2024, 08:00:33 PM
Home Help Login Register
News: Trouble in Terrorist Town? Site here, forum here.

Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Golden Gun Error
Pages: [1]
Author Topic: Golden Gun Error  (Read 7089 times)
Apozen
Poster

Posts: 18


« on: February 08, 2012, 02:24:09 AM »

I get this error for the golden gun shared.lua
"[weapons\weapon_ttt_goldengun\shared.lua:113] attempt to call method 'Kill' (a nil value)"
Here's that part of the code:

if tr.Entity:IsRole(ROLE_INNOCENT) or tr.Entity:IsRole(ROLE_DETECTIVE) then
self.Owner:Kill()
self.Weapon:EmitSound(Sound( "Weapon_Deagle.Single"  ))
self:TakePrimaryAmmo(1)
end
end

self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self:TakePrimaryAmmo(1)
self.Owner:EmitSound(Sound( "Weapon_Deagle.Single"  ))

end

Help would be much appreciated, thanks in advance guys :)
Charles445
Build Tester
*
Posts: 2338


I LOVE THIS AVATAR


« Reply #1 on: February 08, 2012, 03:30:24 AM »

What exactly is that supposed to be... doing... killing the owner of the gun?

del>Ok, so Bad King, you are just going to wait for Garry to fix?
What an idiotic thing to ask. Dammit weed.

Bookcases, Bookcases Everywhere
Apozen
Poster

Posts: 18


« Reply #2 on: February 08, 2012, 11:33:19 AM »

Indeed, if he shoots an innocent or detective, the owner "person who shot the gun" dies.
Here's the large portion if you need it.

function SWEP:Deploy()
  //self.Weapon:SetMaterial("models/deagle_skin1.vtf")
  self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  return true
end


function SWEP:PrimaryAttack()
if not self:CanPrimaryAttack() then return end

self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )




local trace = util.GetPlayerTrace(self.Owner)
local tr = util.TraceLine(trace)

if tr.Entity:IsPlayer() then
if tr.Entity:IsRole(ROLE_TRAITOR) then

bullet = {}
bullet.Num    = 1
bullet.Src    = self.Owner:GetShootPos()
bullet.Dir    = self.Owner:GetAimVector()
bullet.Spread = Vector(0, 0, 0)
bullet.Tracer = 0
bullet.Force  = 3000
bullet.Damage = 4000
self.Owner:FireBullets(bullet)
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self:TakePrimaryAmmo(1)
self.Weapon:EmitSound(Sound( "Weapon_Deagle.Single"  ))


end



if tr.Entity:IsRole(ROLE_INNOCENT) or tr.Entity:IsRole(ROLE_DETECTIVE) then
self.Owner:Kill()
self.Weapon:EmitSound(Sound( "Weapon_Deagle.Single"  ))
self:TakePrimaryAmmo(1)
end
end

self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self:TakePrimaryAmmo(1)
self.Owner:EmitSound(Sound( "Weapon_Deagle.Single"  ))

end
Tommynator
Poster

Posts: 173

Tommynator is a traitor!


« Reply #3 on: February 08, 2012, 01:17:55 PM »

Player:Kill() is Serverside. Try this:

if SERVER then
  self.Owner:Kill()
end
Apozen
Poster

Posts: 18


« Reply #4 on: February 08, 2012, 08:56:37 PM »

That worked!
Thanks man :) amazing.
Pages: [1]
Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Golden Gun Error « previous next »
Jump to:  


Login with username, password and session length

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.012 seconds with 17 queries.