mirror of
https://github.com/wiremod/wire.git
synced 2025-03-04 03:03:04 -05:00
e:propNoDupe(n) (#3146)
* e:propNoDupe(n) * Add additional anti-abuse check * Not tested in-game * simplified + tested
This commit is contained in:
parent
06a7637998
commit
26aed14f44
@ -2,6 +2,9 @@ language.Add("Undone_e2_spawned_prop", "Undone E2 Spawned Prop")
|
||||
language.Add("Undone_e2_spawned_seat", "Undone E2 Spawned Seat")
|
||||
language.Add("Undone_e2_spawned_sent", "Undone E2 Spawned SENT")
|
||||
E2Helper.Descriptions["propManipulate(e:vannn)"] = "Allows to do any single prop core function in one term (position, rotation, freeze, gravity, notsolid)"
|
||||
E2Helper.Descriptions["e:propIsDupeable()"] = "Returns 1, if the prop can be duplicated with the duplicator/advdupe2/similar tool, 0 otherwise."
|
||||
E2Helper.Descriptions["e:propCanSetDupeable()"] = "Returns 1, if you can change entity dupeable state, 0 otherwise. (If you can make it either dupeable or non-dupeable)"
|
||||
E2Helper.Descriptions["e:propNoDupe(n)"] = "Set to 1 to prevent the prop from being duplicated with the duplicator/advdupe2 tool. Set to 0 to allow duplication. (You will not be able to make already non-dupeable prop as dupeable)"
|
||||
E2Helper.Descriptions["propSpawn(sn)"] = "Use the model string or a template entity to spawn a prop. You can set the position and/or the rotation as well. The last number indicates frozen/unfrozen."
|
||||
E2Helper.Descriptions["propSpawn(en)"] = "Entity template, Frozen Spawns a prop with the model of the template entity. If frozen is 0, then it will spawn unfrozen."
|
||||
E2Helper.Descriptions["propSpawn(svn)"] = "Model path, Position, Frozen Spawns a prop with the model denoted by the string filepath at the position denoted by the vector. If frozen is 0, then it will spawn unfrozen."
|
||||
|
@ -61,7 +61,7 @@ local ValidSpawn = PropCore.ValidSpawn
|
||||
local canHaveInvalidPhysics = {
|
||||
delete=true, parent=true, deparent=true, solid=true,
|
||||
shadow=true, draw=true, use=true, pos=true, ang=true,
|
||||
manipulate=true
|
||||
manipulate=true, noDupe=true
|
||||
}
|
||||
|
||||
function PropCore.ValidAction(self, entity, cmd, bone)
|
||||
@ -772,10 +772,39 @@ e2function void propDeleteAll()
|
||||
self.data.spawnedProps = {}
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function canMarkDupeable(ent, ply)
|
||||
if not duplicator.IsAllowed(ent:GetClass()) then return false end -- Entity is not dupeable by default.
|
||||
if ent.markedNoDupeBy == ply:SteamID() then return true end -- Player already changed status. Thus can do this again.
|
||||
return ent.DoNotDuplicate ~= true -- If false or nil -> can mark as dupeable.
|
||||
end
|
||||
|
||||
__e2setcost(1)
|
||||
[nodiscard]
|
||||
e2function number entity:propIsDupeable()
|
||||
return (this.DoNotDuplicate == true or not duplicator.IsAllowed(this:GetClass())) and 0 or 1
|
||||
end
|
||||
|
||||
[nodiscard]
|
||||
e2function number entity:propCanSetDupeable()
|
||||
local isOk, Val = pcall(ValidAction, self, this, "noDupe")
|
||||
if not isOk then return 0 end
|
||||
|
||||
return canMarkDupeable(this, self.player) and 1 or 0
|
||||
end
|
||||
|
||||
__e2setcost(2)
|
||||
e2function void entity:propNoDupe(number noDupe)
|
||||
if not ValidAction(self, this, "noDupe") then return end
|
||||
noDupe = noDupe ~= 0
|
||||
|
||||
if not canMarkDupeable(this, self.player) then return self:throw("Can't mark this entity as "..(noDupe and "un" or "").."dupeable!", nil) end
|
||||
|
||||
this.markedNoDupeBy = self.player:SteamID()
|
||||
this.DoNotDuplicate = noDupe
|
||||
end
|
||||
|
||||
__e2setcost(10)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
e2function void entity:propManipulate(vector pos, angle rot, number freeze, number gravity, number notsolid)
|
||||
if not ValidAction(self, this, "manipulate") then return end
|
||||
PhysManipulate(this, pos, rot, freeze, gravity, notsolid)
|
||||
|
Loading…
Reference in New Issue
Block a user