• remove props by lua
    21 replies, posted
hello , is there a way to remove props via lua in maps? cause i want to remove some props from a map //Thx :froggonk: [highlight](User was banned for this post ("Wrong section" - mahalis))[/highlight]
[lua] for k,v in pairs(ents.GetAll()) do if ( v:GetClass() == "prop_physics_override" ) then v:Remove() // Bai end end [/lua] would delete all prop_physics_override entities.
[QUOTE=Hoffa;20458982][lua] for k,v in pairs(ents.GetAll()) do if ( v:GetClass() == "prop_physics_override" ) then v:Remove() // Bai end end [/lua] would delete all prop_physics_override entities.[/QUOTE] but how do i select a prop? xD
[QUOTE=blown25;20459034]but how do i select a prop? xD[/QUOTE] Lots of different ways. [lua] player.GetAll()[1]:GetEyeTrace().Entity:Remove() [/lua] Take a look at the wiki for references.
What kind of props do you want to select?
-snip-
[QUOTE=Overv;20459078]What kind of props do you want to select?[/QUOTE] prop_physic_multiplayer and func_button
[QUOTE=blown25;20459238]prop_physic_multiplayer and func_button[/QUOTE] [lua] for k,v in pairs(ents.GetAll()) do if ( v:GetClass() == "prop_physics_multiplayer" || v:GetClass() == "func_button" ) then v:Remove() // Bai end end [/lua]
will that remove every buttons and props?
[QUOTE=Hoffa;20459310][lua] for k,v in pairs(ents.GetAll()) do if ( v:GetClass() == "prop_physics_multiplayer" || v:GetClass() == "func_button" ) then v:Remove() // Bai end end [/lua][/QUOTE] where do i put it btw?
lua/server/myfile.lua
didnt work :(
[QUOTE=Kialtia;20459674]lua/[b]autorun/[/b]server/myfile.lua[/QUOTE]
[lua] local types = { "prop_physics", "prop_dynamic", "func_shitdick", "etc" } for k,v in pairs( types ) do for c,d in pairs( ents.FindByClass( v ) ) do d:Remove() end end[/lua]
[QUOTE=Rambo_9;20459840][lua] local types = { "prop_physics", "prop_dynamic", "func_shitdick", "etc" } for k,v in pairs( types ) do for c,d in pairs( ents.FindByClass( v ) ) do d:Remove() end end[/lua][/QUOTE] i made a file in lua/autorun/server/remove.lua with that code but it didnt work :'(
Put it in the GM:InitializePostEntity hook (or whatever it's named). [editline]11:17PM[/editline] [url]http://wiki.garrysmod.com/?title=Gamemode.InitPostEntity[/url]
[QUOTE=Rambo_9;20459925]Put it in the GM:InitializePostEntity hook (or whatever it's named). [editline]11:17PM[/editline] [url]http://wiki.garrysmod.com/?title=Gamemode.InitPostEntity[/url][/QUOTE] [CODE]local types = { "prop_physics", "prop_dynamic", "prop_vehicle" } for k,v in pairs( types ) do for c,d in pairs( ents.FindByClass( v ) ) do d:Remove() end end hook.Add( "InitPostEntity", "MapStartTrigger", Init_TriggerLogic )[/CODE] im trying that. [editline]12:22AM[/editline] can someone be nice and copy the whole code for me? //Thx
you need to put it inside a function that you're hooking. [lua] function RemoveShit() // put the original code here end hook.Add( "InitPostEntity", "fuck my slutty asshole", RemoveShit )[/lua]
-snip- found it. Env_fire
So what would be the whole code? Cause it isn't working for me.
Sorry, you need to Log In to post a reply to this thread.