Need help with making a timer to reload permaprops
2 replies, posted
I have this code that removes all the default map prop but it also removes all the permaprops I have placed myself and I can reload the permaprops and there back but I want to make this automatic.
This is the code I use for removing the props
[lua]
if SERVER then
timer.Create("cleanshit", 15, 1, function()
for k, v in pairs(ents.FindByClass("prop_physics")) do v:Remove() end
end)
end[/lua]
And this is the addon permaprops
[url]http://steamcommunity.com/sharedfile...archtext=perma[/url]
If there is a way to make a timer that reloads the permaprops 10 minutes after the server starts it would be great!
Thanks in advance
Jeromy Han
Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/CreatedByMap]Entity:CreatedByMap[/url] to only remove props created by the map. It should keep the add-on's props.
[lua]
if SERVER then
timer.Create("cleanshit", 15, 1, function()
for k, v in pairs(ents.FindByClass("prop_physics")) do
if IsValid(v) and v:CreatedByMap() then
v:Remove()
end
end
end)
end
[/lua]
[QUOTE=Lolle;49816835]Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/CreatedByMap]Entity:CreatedByMap[/url] to only remove props created by the map. It should keep the add-on's props.
[lua]
if SERVER then
timer.Create("cleanshit", 15, 1, function()
for k, v in pairs(ents.FindByClass("prop_physics")) do
if IsValid(v) and v:CreatedByMap() then
v:Remove()
end
end
end)
end
[/lua][/QUOTE]
Thank you so much dude this worked thanks for the quick reply your the best!
Sorry, you need to Log In to post a reply to this thread.