I want to make a module/addon that turns props on a map into interactable entities,
for example: A prop which is essentially junk acts like ammunition, or food props that heal the player
I imagined "creating" entities for each prop but I dont think that's the way to go here
does anyone have an idea how to do this?
Use the PlayerUse Hook and search for the specific class and then remove the prop with giving the player health.
Try going through ents.GetAll and using Entity:CreatedByMap to check if the entity is map created.
If it is, I think there was some method to override their Entity:Use function.
GM:PlayerUse might even work if that works with map entities.
would I have to look for a prop_physics with the right modell?
You will have to look up the class and the model using the Class and GetModel function.
If it depends on the model you could use a table like this:
local healers = {
["models/blah.mdl"] = 100
}
hook.Add( "PlayerUse", "blah", function( ply, ent )
if IsValid( ent ) and ent:CreatedByMap() and then
local health = healers[ ent:GetModel() ]
if health then
ply:SetHealth( ply:Health() + health )
end
end
end )
I doesnt have to be created by map but just props in general, wouldnt I have to use prop_physics or whatever the correct ent type it is atleast once somewhere too?
If the class actually matters you could just do
if IsValid( ent ) and ent:GetClass() == "prop_physics" then
Instead of
if IsValid( ent ) and ent:CreatedByMap() then
thanks dud i hope this will work
Sorry, you need to Log In to post a reply to this thread.