Hey guys don't make fun I'm not a coder, working on my first real project other then editing other peoples code :) Im trying to give health to a player standing on an entity. Im not even sure if the give health is working because it throws an error before it gets to that. I THINK I am having a problem identifying the player standing on the entity. Please let me know whats going wrong here learning how to set an identifier seems useful :)
thanks guys i fucking love you!!!
[lua]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self.Entity:SetModel("models/hunter/blocks/cube1x1x025.mdl")
self.Entity:SetSkin(0)
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetSolid(SOLID_VPHYSICS)
local phys = self.Entity:GetPhysicsObject()
if phys and phys:IsValid() then phys:Wake() end
end
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( self.Classname )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
function ENT:GiveHealth( ply )
local ply = LocalPlayer()
if ( ply:IsValid() and ply:IsPlayer() ) then
local healed = 2
local hp = ply:GetMaxHealth(), ply:Health() + healed
ply:SetHealth(hp)
end
end
function ENT:StartTouch( ent )
if ( ent:IsValid() and ent:IsPlayer() ) then
self:GiveHealth( ply )
end
end
function ENT:Think()
end
[/lua]
[lua]
function ENT:StartTouch( ent )
if ent:IsValid() and ent:IsPlayer() then
self:GiveHealth( ent )
end
end
[/lua]
You never defined ply, use ent instead.
derp thanks bro :)
Sorry, you need to Log In to post a reply to this thread.