• Accepting something from a command.
    9 replies, posted
  • If I want to except a prop from this command [code] for _, ent in pairs( ents.FindByClass( "prop_physics" ) ) do if ent:IsValid() then ent:Remove() ent.NoCopy = true end end [/code] And this is the prop path models/hunter/plates/plate32x32.mdl How would i go about doing this? (Basically i want it to remove all prop_physics except for the plate 32x32)
  • Avatar of deluvas
  • for _, ent in pairs( ents.FindByClass( "prop_physics" ) ) do if ent:IsValid() then if ent:GetModel() ~= "models/hunter/plates/plate32x32" then ent:Remove() ent.NoCopy = true end end end EDIT: without ".mdl" , sorry (at least that's what the wiki says, test it and see out :))
  • Avatar of Unrealomega
  • [QUOTE=Kakburken;16852581]Wait, won't that remove ONLY the 32x32 plates?[/QUOTE] [code]local function RemoveEntity(modelName) if !modelName then return end --Makes sure there's actually a value being passed. for _, ent in ipairs( ents.FindByModel( modelName ) ) do if ent:IsValid() and ent:GetClass() == "prop_physics" then ent:Remove() ent.NoCopy = true end end end[/code]
  • Avatar of Joerdgs
  • [QUOTE=Kakburken;16852581]Wait, won't that remove ONLY the 32x32 plates?[/QUOTE] " ~= " means "is not" in lua.
  • Avatar of maurits150
  • I recommend you to use != instead of ~= because it's easier to type and used more frequently.
  • Thanks for the help everyone, It's appreciated. [editline]08:48PM[/editline] Hearts for everyone!
  • Avatar of Kogitsune
  • [QUOTE=maurits150;16859168]I recommend you to use != instead of ~= because it's easier to type and used more frequently.[/QUOTE] But then your code loses portability, so it comes down to using what you prefer. I've been using ~= since GM9, so it's not likely that I'm going to change this late in the game.
  • Avatar of Gmod4ever
  • [QUOTE=Kogitsune;16863869]But then your code loses portability, so it comes down to using what you prefer. I've been using ~= since GM9, so it's not likely that I'm going to change this late in the game.[/QUOTE] I find myself alternating them intermittently. Hell, sometimes I'll use them both in the same line. [lua]if (value ~= arg1) and (value ~= arg2) and (value != arg3) and (value ~=arg4) then[/lua] :v:
  • Avatar of Kogitsune
  • [QUOTE=Gmod4ever;16864017]I find myself alternating them intermittently. Hell, sometimes I'll use them both in the same line. [lua]if (value ~= arg1) and (value ~= arg2) and (value != arg3) and (value ~=arg4) then[/lua] :v:[/QUOTE] Just mixing things up so you don't get bored, of course.