• constraint.RemoveAll not working for me
    3 replies, posted
[CODE] -- If the entity belongs to a ship if shipId then -- Check to see if the entity that was hit was a mast. -- If it was, break the mast. local mast = FindMast(target) if mast then if (target:Health() - amount) <= 50 then local mastEnt = ents.FindByName("ship" .. shipId .. "weldmast" .. mast)[1] if mastEnt then constraint.RemoveAll( mastEnt ) Ships[shipId].status.masts = Ships[shipId].status.masts - 1 CheckIfSinking(shipId) Ships[shipId].forward:SetKeyValue("force", SpeedPerMast * Ships[shipId].status.masts) Ships[shipId].backward:SetKeyValue("force", SpeedPerMast * Ships[shipId].status.masts) if attacker:IsPlayer() then attacker:PS_GivePoints(PS.Config.MastBreakGold) end end end end[/CODE] The above code is my attempt at removing constraints when a mast in the gamemode Pirate Ship Wars is shot at instead of simply breaking using Ent:Fire. However, the mast is still welded together when the entity has less than 50 HP. So my question is, what am I doing wrong?
It only works on constrains created with constraint library, i.e. through Lua.
[QUOTE=Robotboy655;51826874]It only works on constrains created with constraint library, i.e. through Lua.[/QUOTE] What would I use if I want to remove map-created constraints?
You'd have to target the specific entity on the map, using something like [url]http://wiki.garrysmod.com/page/ents/GetMapCreatedEntity[/url]
Sorry, you need to Log In to post a reply to this thread.