Hi,
I am making an addon where an entity gets spawned in and you have to take it to an NPC to receive an award. Everything works fine until you have to drag the entity onto an NPC. I know how make it remove the entity etc etc but i can't seem to find a way to reward the person that dragged the Entity onto the NPC. I tried to use entity:SetOwner and then
function ENT:StartTouch(Ent) print(Ent:GetOwner())end
But it doesn't seem to work. As it prints "[NULL Entity]"
net.Receive("SpawnEnt", function(len,ply)
local theent= ents.Create( "testing_ent" )
if ( !IsValid( theent ) ) then return end
theent:SetModel( "models/props_c17/BriefCase001a.mdl" )
theent:SetPos( ply:EyePos() + Vector(0,5,2) )
theent:Spawn()
theent:SetOwner(ply)
end)
If anybody has any advice on how to fix this issue let me know.
Is that StartTouch method in the NPC? If so, try printing out the entity to verify it is indeed the one you spawned in the net callback.
okay i just realised as i added print(ent:GetClass()) that it doesn't even seem to recognize the enitity. It prints "player" when i touch it but when the entity touches it, it doesn't print anything.
Sorry, you need to Log In to post a reply to this thread.