1. Post #1
    Gold Member
    Kakburken's Avatar
    November 2007
    554 Posts
    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
    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)
    Reply With Quote Edit / Delete Reply Turkey Show Events Dumb Dumb x 1 (list)

  2. Post #2
    deluvas's Avatar
    September 2006
    85 Posts
    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 :))
    Reply With Quote Edit / Delete Reply Romania Show Events Agree Agree x 1Disagree Disagree x 1Friendly Friendly x 1Dumb Dumb x 1 (list)

  3. Post #3
    Gold Member
    Kakburken's Avatar
    November 2007
    554 Posts
    Wait, won't that remove ONLY the 32x32 plates?
    Reply With Quote Edit / Delete Reply Turkey Show Events Friendly Friendly x 1Optimistic Optimistic x 1 (list)

  4. Post #4
    Unrealomega's Avatar
    January 2009
    262 Posts
    Wait, won't that remove ONLY the 32x32 plates?
    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
    Reply With Quote Edit / Delete Reply United States Show Events Disagree Disagree x 2Friendly Friendly x 1 (list)

  5. Post #5
    Gold Member
    Joerdgs's Avatar
    July 2005
    372 Posts
    Wait, won't that remove ONLY the 32x32 plates?
    " ~= " means "is not" in lua.
    Reply With Quote Edit / Delete Reply Netherlands Show Events Friendly Friendly x 1 (list)

  6. Post #6
    Gold Member
    maurits150's Avatar
    February 2007
    1,803 Posts
    I recommend you to use != instead of ~= because it's easier to type and used more frequently.
    Reply With Quote Edit / Delete Reply Netherlands Show Events Dumb Dumb x 2Friendly Friendly x 1 (list)

  7. Post #7
    Gold Member
    Kakburken's Avatar
    November 2007
    554 Posts
    Thanks for the help everyone, It's appreciated.

    Edited:

    Hearts for everyone!

  8. Post #8
    Gold Member
    Kogitsune's Avatar
    September 2005
    2,748 Posts
    I recommend you to use != instead of ~= because it's easier to type and used more frequently.
    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.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 1 (list)

  9. Post #9
    Please waste more of your money changing this title again.
    Gmod4ever's Avatar
    August 2005
    6,672 Posts
    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.
    I find myself alternating them intermittently.

    Hell, sometimes I'll use them both in the same line.

    if (value ~= arg1) and (value ~= arg2) and (value != arg3) and (value ~=arg4) then


  10. Post #10
    Gold Member
    Kogitsune's Avatar
    September 2005
    2,748 Posts
    I find myself alternating them intermittently.

    Hell, sometimes I'll use them both in the same line.

    if (value ~= arg1) and (value ~= arg2) and (value != arg3) and (value ~=arg4) then

    Just mixing things up so you don't get bored, of course.