• EyeTrace
    3 replies, posted
Hello. I'm making a SWEP for a server and I need a hand with this specific area. I am struggling with EyeTraces. I haven't been able to find anything on the internet that teaches me how to use EyeTraces, and I couldn't really understand the wiki. Anyway, more to the point... I'm trying to make a SWEP for a vortigaunt job, so when you left click at any distance it heals the person you're aiming at back to their max health. I've just started it, so there is nothing in the primary fire function yet. [lua] if SERVER then SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false elseif CLIENT then //The name of the SWep, as appears in the weapons tab in the spawn menu(Q Menu) SWEP.PrintName = "Vortal Heal" SWEP.Slot = 1 SWEP.SlotPos = 0 SWEP.DrawAmmo = false SWEP.DrawCrosshair = true end SWEP.Author = "Shadow" SWEP.Contact = "www.apex-roleplay.com" SWEP.Purpose = "Heal others" SWEP.Instructions = "Left click" SWEP.Category = "Vortal Powers" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.ViewModel = "" SWEP.WorldModel = "" SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" local ShootSound = Sound("") function SWEP:Reload() end function SWEP:Think() end function SWEP:PrimaryAttack() OnRun = function(Player, Trace) local ply = Trace.Entity if ply:IsPlayer() then Entity:SetHealth(100) end end end function SWEP:SecondaryAttack() end [/lua] Please don't say anything too complex, I'm still yet to learn this. I'd appreciate if someone could tell me all about eye trace and maybe give me an example along these lines.
[URL="http://wiki.garrysmod.com/page/Player/GetEyeTrace"]self.Owner:GetEyeTrace()[/URL]. This page has more than enough information for what you're trying to do.
EyeTraces just uses TraceLine internally, so it's the same kind of return structure.
Thank you, I've got it.
Sorry, you need to Log In to post a reply to this thread.