mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
41 lines
1.0 KiB
Lua
41 lines
1.0 KiB
Lua
--[[
|
|
| This file was obtained through the combined efforts
|
|
| of Madbluntz & Plymouth Antiquarian Society.
|
|
|
|
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
|
| Maloy, DrPepper10 @ RIP, Atle!
|
|
|
|
|
| Visit for more: https://plymouth.thetwilightzone.ru/
|
|
--]]
|
|
|
|
|
|
util.AddNetworkString("pac.AllowPlayerButtons")
|
|
util.AddNetworkString("pac.BroadcastPlayerButton")
|
|
|
|
do -- button event
|
|
net.Receive("pac.AllowPlayerButtons", function(length, client)
|
|
local key = net.ReadUInt(8)
|
|
|
|
client.pac_broadcast_buttons = client.pac_broadcast_buttons or {}
|
|
client.pac_broadcast_buttons[key] = true
|
|
end)
|
|
|
|
local function broadcast_key(ply, key, down)
|
|
if not ply.pac_broadcast_buttons then return end
|
|
if not ply.pac_broadcast_buttons[key] then return end
|
|
|
|
net.Start("pac.BroadcastPlayerButton")
|
|
net.WriteEntity(ply)
|
|
net.WriteUInt(key, 8)
|
|
net.WriteBool(down)
|
|
net.Broadcast()
|
|
end
|
|
|
|
pac.AddHook("PlayerButtonDown", "event", function(ply, key)
|
|
broadcast_key(ply, key, true)
|
|
end)
|
|
|
|
pac.AddHook("PlayerButtonUp", "event", function(ply, key)
|
|
broadcast_key(ply, key, false)
|
|
end)
|
|
end |