Skip to content

Commit

Permalink
Fix PlayerUse event issues (#3171)
Browse files Browse the repository at this point in the history
* Add PlayerUse hook to pod controller use

* Change the way E2 tracks playerUse

* Revised solution
  • Loading branch information
Denneisk authored Nov 8, 2024
1 parent b541f31 commit b9cca7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 1 addition & 10 deletions lua/entities/gmod_wire_expression2/core/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1025,17 +1025,8 @@ E2Lib.registerEvent("playerDeath", {
{ "Attacker", "e" }
})

local Using = WireLib.RegisterPlayerTable()

hook.Add("PlayerBindDown", "Exp2PlayerButtonDownUse", function(ply, binding, button)
if binding == "use" then
Using[ply] = nil
end
end)

hook.Add("PlayerUse", "Exp2PlayerUse", function(ply, ent)
if not Using[ply] then
Using[ply] = true
if not ply:KeyDownLast(IN_USE) then
E2Lib.triggerEvent("playerUse", { ply, ent })
end
end)
Expand Down
4 changes: 3 additions & 1 deletion lua/entities/gmod_wire_pod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ function ENT:Think()
if IsValid(button) and (inAttack and not mouseDown) and not button:IsVehicle() and button.Use then
-- Generic support (Buttons, Dynamic Buttons, Levers, EGP screens, etc)
selfTbl.MouseDown = true
button:Use(ply, self, USE_ON, 0)
if hook.Run("PlayerUse", ply, button) ~= false then
button:Use(ply, self, USE_ON, 0)
end
elseif not inAttack and mouseDown then
selfTbl.MouseDown = false
end
Expand Down

0 comments on commit b9cca7a

Please sign in to comment.