• Remove A Certain Prop/Entity Every <time> Seconds?
    6 replies, posted
What lua code would I need to [b]constantly check for and delete[/b] a certain prop or entity(not a certain type like prop_physics or prop_dynamic, I mean a specific prop or entity down it's model path) [b]every however many of seconds[/b] OR have a specific prop or entity deleted after however many seconds after it is created?
Use timers and ents.FindByModel and you should be good to go.
alternatively you could hook into [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnEntityCreated]GM/OnEntityCreated[/url]
[lua]local search_delay, search_model = 10, "entity_model_here" timer.Create("CleanupEntities", search_delay, 0, function() if search_model then for k,v in pairs(ents.FindByModel(search_model)) do if IsValid(v) then v:Remove() end end end end)[/lua]
[QUOTE=Author.;46790219][lua]local search_delay, search_model = 10, "entity_model_here" timer.Create("CleanupEntities", search_delay, 0, function() if search_model then for k,v in pairs(ents.FindByModel(search_model)) do if IsValid(v) then v:Remove() end end end end)[/lua][/QUOTE] Thank you so much.
Zerf's soluton is actually better, unless you want the prop to appear for a little bit prior to being deleted.
[QUOTE=sasherz;46794046]unless you want the prop to appear for a little bit prior to being deleted.[/QUOTE] Yeah that's what I was going for, Gib/Goremod V14's Serverside Ragdoll Auto-Delete function doesn't seem to work on multiplayer so I'd be trying to have it so corpses would automatically be removed after X seconds. And you can't sit back and watch the nice gore and dismemberment if it gets deleted immediately.
Sorry, you need to Log In to post a reply to this thread.