mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-18 06:03:47 +03:00
Upload
This commit is contained in:
41
lua/pac3/core/server/net_messages.lua
Normal file
41
lua/pac3/core/server/net_messages.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
--[[
|
||||
| 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
|
||||
Reference in New Issue
Block a user