So.. hi, I have tried everything, changing values, and shit, but doesn't work. So, I thought, what is the best forum for coding and other stuff with gmod? Face Punch Forums
[code]
if SERVER then // This is where the init.lua stuff goes.
AddCSLuaFile ("shared.lua")
SWEP.Weight = 1
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
elseif CLIENT then
SWEP.PrintName = "Force Choke"
SWEP.Slot = 4
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
end
SWEP.Author = "PIXX"
SWEP.Contact = "rctgamestv@gmail.com"
SWEP.Purpose = "Force choke lets you choke people at least make them recive damage"
SWEP.Instructions = "Left click to choke."
SWEP.Category = "Force Choke"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.UseHands = false
SWEP.ViewModel = "models/weapons/v_hands.mdl"
SWEP.WorldModel = ""
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = false
SWEP.ViewModelBoneMods = {}
local ShootSound = Sound("forcechoke/force_choke.wav")
SWEP.Primary.Recoil = 5
SWEP.Primary.Damage = 0
SWEP.Pistol = false
SWEP.Rifle = false
SWEP.Shotgun = false
SWEP.Sniper = false
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
ForceChoke()
self:EmitSound(ShootSound)
self.BaseClass.ShootEffects(self)
end
function SWEP:SecondaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
ForceSecond()
end
function ForceSecond()
end
function ForceChoke(tr,dmginfo)
hook.Add("Think","pixxEye",function()
-- This is the area, I think that creats the error.
local eyetrace = Entity( 1 ):GetEyeTrace()
if eyetrace.Entity:IsPlayer() then
Entity():TakeDamage(1000,self:Player(),eyetrace.Entity)
eyetrace.Entity:Freeze(true)
else
eyetrace.Entity:Freeze(false)
end
--
end)
end
[/code]
If you could help me, it would be fanastic.
- PIXX
Update:
This is what happens when you use it
[code]
File exists in two addons - possible conflicts! lua/ulib/shared/hook.lua (ULib and Star Wars Force Choke)
[ERROR] lua/weapons/forcechoke/shared.lua:72: attempt to call field 'Entity' (a userdata value)
1. fn - lua/weapons/forcechoke/shared.lua:72
2. unknown - lua/ulib/shared/hook.lua:110
[/code]
Update 2:
I fixed the problem (with help ofc from the beautiful forum of facepunch) and also fixed a bug that appered later!
Summary: THANKS EVERYONE WHO HELPED ME! :D
which line is line 72?
Change
[lua]Entity():TakeDamage(1000,self:Player(),eyetrace.Entity)[/lua]
to
[lua]eyetrace.Entity:TakeDamage(1000,self:Player(),eyetrace.Entity)[/lua]
I guess that's what you want?
You probably want to check out this page on [url=http://wiki.garrysmod.com/page/Global/Entity]Entity[/url]
[QUOTE=F1R3Kael;50384029]Change
[lua]Entity():TakeDamage(1000,self:Player(),eyetrace.Entity)[/lua]
to
[lua]eyetrace.Entity:TakeDamage(1000,self:Player(),eyetrace.Entity)[/lua]
I guess that's what you want?
You probably want to check out this page on [url=http://wiki.garrysmod.com/page/Global/Entity]Entity[/url][/QUOTE]
Thanks, gonna try that :D
Update: Works on singleplayer.
[editline]24th May 2016[/editline]
[QUOTE=danker pepers;50383958]which line is line 72?[/QUOTE]
this line
[code] Entity():TakeDamage(1000,self:Player(),eyetrace.Entity)[/code]
You'll also want to take the think hook out of the function
[QUOTE=tyguy;50389505]You'll also want to take the think hook out of the function[/QUOTE]
Your name is the thing I am about to say;
Thank you (random) guy (on the internet)
Sorry, you need to Log In to post a reply to this thread.