mirror of
https://github.com/CapsAdmin/pac3.git
synced 2025-03-04 03:03:01 -05:00
don't auto indent net. library
This commit is contained in:
parent
a8d0a0505d
commit
17a498a532
9
lint.lua
9
lint.lua
@ -55,15 +55,6 @@ local config = {
|
||||
cam_Start3D2D = {to = "cam_End3D2D"},
|
||||
cam_Start = {to = "cam_End"},
|
||||
|
||||
Start = {
|
||||
to = {
|
||||
SendToServer = true,
|
||||
Send = true,
|
||||
Broadcast = true,
|
||||
End = true,
|
||||
}
|
||||
},
|
||||
|
||||
SetPropertyGroup = "toggle",
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ function net.Stream.ReadStream:Request()
|
||||
-- print("Requesting",self.identifier,false,false,#self.chunks)
|
||||
|
||||
net.Start("NetStreamRequest")
|
||||
net.WriteUInt(self.identifier, 32)
|
||||
net.WriteBit(false)
|
||||
net.WriteBit(false)
|
||||
net.WriteUInt(#self.chunks, 32)
|
||||
net.WriteUInt(self.identifier, 32)
|
||||
net.WriteBit(false)
|
||||
net.WriteBit(false)
|
||||
net.WriteUInt(#self.chunks, 32)
|
||||
|
||||
if CLIENT then
|
||||
if CLIENT then
|
||||
net.SendToServer()
|
||||
else
|
||||
net.Send(self.player)
|
||||
@ -78,11 +78,11 @@ function net.Stream.ReadStream:Remove()
|
||||
end
|
||||
|
||||
net.Start("NetStreamRequest")
|
||||
net.WriteUInt(self.identifier, 32)
|
||||
net.WriteBit(false)
|
||||
net.WriteBit(true)
|
||||
net.WriteUInt(self.identifier, 32)
|
||||
net.WriteBit(false)
|
||||
net.WriteBit(true)
|
||||
|
||||
if CLIENT then
|
||||
if CLIENT then
|
||||
net.SendToServer()
|
||||
else
|
||||
net.Send(self.player)
|
||||
@ -123,12 +123,12 @@ function net.Stream.WriteStream:Write(ply)
|
||||
if chunk then
|
||||
self.clients[ply].progress = progress
|
||||
net.Start("NetStreamDownload")
|
||||
net.WriteUInt(#chunk.data, 32)
|
||||
net.WriteUInt(progress, 32)
|
||||
net.WriteString(chunk.crc)
|
||||
net.WriteData(chunk.data, #chunk.data)
|
||||
net.WriteUInt(#chunk.data, 32)
|
||||
net.WriteUInt(progress, 32)
|
||||
net.WriteString(chunk.crc)
|
||||
net.WriteData(chunk.data, #chunk.data)
|
||||
|
||||
if CLIENT then
|
||||
if CLIENT then
|
||||
net.SendToServer()
|
||||
else
|
||||
net.Send(ply)
|
||||
@ -169,10 +169,10 @@ function net.Stream.WriteStream:Remove()
|
||||
end
|
||||
|
||||
net.Start("NetStreamDownload")
|
||||
net.WriteUInt(0, 32)
|
||||
net.WriteUInt(self.identifier, 32)
|
||||
net.WriteUInt(0, 32)
|
||||
net.WriteUInt(self.identifier, 32)
|
||||
|
||||
if SERVER then
|
||||
if SERVER then
|
||||
net.Send(sendTo)
|
||||
else
|
||||
net.SendToServer()
|
||||
@ -358,10 +358,10 @@ function net.ReadStream(ply, callback)
|
||||
if #queue > 1 then
|
||||
timer.Create("NetStreamKeepAlive" .. identifier, net.Stream.Timeout / 2, 0, function()
|
||||
net.Start("NetStreamRequest")
|
||||
net.WriteUInt(identifier, 32)
|
||||
net.WriteBit(true)
|
||||
net.WriteUInt(identifier, 32)
|
||||
net.WriteBit(true)
|
||||
|
||||
if CLIENT then
|
||||
if CLIENT then
|
||||
net.SendToServer()
|
||||
else
|
||||
net.Send(ply)
|
||||
|
@ -69,7 +69,7 @@ if SERVER then
|
||||
local verbose = args[1] == "1"
|
||||
info = PAC_VERSION()
|
||||
net.Start("pac_version")
|
||||
net.WriteTable(info)
|
||||
net.WriteTable(info)
|
||||
net.Broadcast()
|
||||
dump(info, verbose)
|
||||
end)
|
||||
@ -81,7 +81,7 @@ if SERVER then
|
||||
if self == ply and not cmd:IsForced() then
|
||||
hook.Remove("SetupMove", id)
|
||||
net.Start("pac_version")
|
||||
net.WriteTable(info)
|
||||
net.WriteTable(info)
|
||||
net.Send(ply)
|
||||
end
|
||||
end)
|
||||
|
@ -130,12 +130,12 @@ function PART:SetBlendMode(str)
|
||||
|
||||
if src_color and dst_color then
|
||||
self.blend_override = {
|
||||
src_color,
|
||||
dst_color,
|
||||
src_alpha,
|
||||
dst_alpha,
|
||||
tbl[5],
|
||||
}
|
||||
src_color,
|
||||
dst_color,
|
||||
src_alpha,
|
||||
dst_alpha,
|
||||
tbl[5],
|
||||
}
|
||||
else
|
||||
self.blend_override = nil
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ local function pac_request_precache(name)
|
||||
already[name] = true
|
||||
PrecacheParticleSystem(name)
|
||||
net.Start("pac_request_precache")
|
||||
net.WriteString(name)
|
||||
net.WriteString(name)
|
||||
net.SendToServer()
|
||||
end
|
||||
|
||||
|
@ -1059,7 +1059,7 @@ do
|
||||
|
||||
if val then
|
||||
net.Start("pac.AllowPlayerButtons")
|
||||
net.WriteUInt(val, 8)
|
||||
net.WriteUInt(val, 8)
|
||||
net.SendToServer()
|
||||
end
|
||||
|
||||
|
@ -219,69 +219,69 @@ function PART:PlaySound(_, additiveVolumeFraction)
|
||||
stream:Resume()
|
||||
else
|
||||
stream:Start()
|
||||
end
|
||||
|
||||
self.last_stream = stream
|
||||
end
|
||||
|
||||
function PART:StopSound()
|
||||
for key, stream in pairs(self.streams) do
|
||||
if not stream:IsValid() then
|
||||
self.streams[key] = nil
|
||||
self.last_stream = stream
|
||||
end
|
||||
|
||||
goto CONTINUE
|
||||
function PART:StopSound()
|
||||
for key, stream in pairs(self.streams) do
|
||||
if not stream:IsValid() then
|
||||
self.streams[key] = nil
|
||||
|
||||
goto CONTINUE
|
||||
end
|
||||
|
||||
if not self.StopOnHide then
|
||||
if self.PauseOnHide then
|
||||
stream:Pause()
|
||||
else
|
||||
stream:Stop()
|
||||
end
|
||||
|
||||
if not self.StopOnHide then
|
||||
if self.PauseOnHide then
|
||||
stream:Pause()
|
||||
else
|
||||
stream:Stop()
|
||||
end
|
||||
end
|
||||
|
||||
::CONTINUE::
|
||||
end
|
||||
end
|
||||
|
||||
function PART:OnShow(from_rendering)
|
||||
if not from_rendering then
|
||||
self:PlaySound()
|
||||
end
|
||||
end
|
||||
|
||||
function PART:OnHide()
|
||||
self:StopSound()
|
||||
end
|
||||
|
||||
function PART:OnRemove()
|
||||
for key, stream in pairs(self.streams) do
|
||||
if not stream:IsValid() then
|
||||
self.streams[key] = nil
|
||||
|
||||
goto CONTINUE
|
||||
end
|
||||
|
||||
stream:Remove()
|
||||
|
||||
::CONTINUE::
|
||||
end
|
||||
end
|
||||
|
||||
function PART:SetDoppler(num)
|
||||
for key, stream in pairs(self.streams) do
|
||||
if not stream:IsValid() then
|
||||
self.streams[key] = nil
|
||||
|
||||
goto CONTINUE
|
||||
end
|
||||
|
||||
stream:EnableDoppler(num)
|
||||
|
||||
::CONTINUE::
|
||||
end
|
||||
|
||||
self.Doppler = num
|
||||
::CONTINUE::
|
||||
end
|
||||
end
|
||||
|
||||
function PART:OnShow(from_rendering)
|
||||
if not from_rendering then
|
||||
self:PlaySound()
|
||||
end
|
||||
end
|
||||
|
||||
function PART:OnHide()
|
||||
self:StopSound()
|
||||
end
|
||||
|
||||
function PART:OnRemove()
|
||||
for key, stream in pairs(self.streams) do
|
||||
if not stream:IsValid() then
|
||||
self.streams[key] = nil
|
||||
|
||||
goto CONTINUE
|
||||
end
|
||||
|
||||
stream:Remove()
|
||||
|
||||
::CONTINUE::
|
||||
end
|
||||
end
|
||||
|
||||
function PART:SetDoppler(num)
|
||||
for key, stream in pairs(self.streams) do
|
||||
if not stream:IsValid() then
|
||||
self.streams[key] = nil
|
||||
|
||||
goto CONTINUE
|
||||
end
|
||||
|
||||
stream:EnableDoppler(num)
|
||||
|
||||
::CONTINUE::
|
||||
end
|
||||
|
||||
pac.RegisterPart(PART)
|
||||
self.Doppler = num
|
||||
end
|
||||
|
||||
pac.RegisterPart(PART)
|
||||
|
@ -19,8 +19,8 @@ local function ADD(PART, name, default, ...)
|
||||
ply.pac_movement = ply.pac_movement or table.Copy(pac_movement_default)
|
||||
ply.pac_movement[name] = val
|
||||
net.Start("pac_modify_movement")
|
||||
net.WriteString(name)
|
||||
net.WriteType(val)
|
||||
net.WriteString(name)
|
||||
net.WriteType(val)
|
||||
net.SendToServer()
|
||||
end
|
||||
end
|
||||
@ -99,10 +99,10 @@ function PART:OnHide()
|
||||
|
||||
if ent == pac.LocalPlayer then
|
||||
net.Start("pac_modify_movement")
|
||||
net.WriteString("disable")
|
||||
net.SendToServer()
|
||||
ent.pac_movement = nil
|
||||
end
|
||||
net.WriteString("disable")
|
||||
net.SendToServer()
|
||||
ent.pac_movement = nil
|
||||
end
|
||||
end
|
||||
|
||||
pac.RegisterPart(PART)
|
||||
|
@ -154,9 +154,9 @@ function PART:Shoot(pos, ang)
|
||||
end
|
||||
|
||||
net.Start("pac_projectile")
|
||||
net.WriteVector(pos)
|
||||
net.WriteAngle(ang)
|
||||
net.WriteTable(tbl)
|
||||
net.WriteVector(pos)
|
||||
net.WriteAngle(ang)
|
||||
net.WriteTable(tbl)
|
||||
net.SendToServer()
|
||||
else
|
||||
self.projectiles = self.projectiles or {}
|
||||
|
@ -268,8 +268,8 @@ function run_lua_on_server(code, cb)
|
||||
local id = util.CRC(code .. tostring(cb))
|
||||
lua_server_run_callbacks[id] = cb
|
||||
net.Start("pac3_test_sutie_backdoor")
|
||||
net.WriteString(id)
|
||||
net.WriteString(code)
|
||||
net.WriteString(id)
|
||||
net.WriteString(code)
|
||||
net.SendToServer()
|
||||
end
|
||||
|
||||
|
@ -29,7 +29,7 @@ util.AddNetworkString("pac_request_precache")
|
||||
function pac.PrecacheEffect(name)
|
||||
PrecacheParticleSystem(name)
|
||||
net.Start("pac_effect_precached")
|
||||
net.WriteString(name)
|
||||
net.WriteString(name)
|
||||
net.Broadcast()
|
||||
end
|
||||
|
||||
|
@ -14,9 +14,9 @@ concommand.Add("pac_event", function(ply, _, args)
|
||||
end
|
||||
|
||||
net.Start("pac_event", true)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(event)
|
||||
net.WriteInt(extra, 8)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(event)
|
||||
net.WriteInt(extra, 8)
|
||||
net.Broadcast()
|
||||
end)
|
||||
|
||||
@ -28,14 +28,14 @@ concommand.Add("+pac_event", function(ply, _, args)
|
||||
ply.pac_event_toggles = ply.pac_event_toggles or {}
|
||||
ply.pac_event_toggles[event] = true
|
||||
net.Start("pac_event", true)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(event)
|
||||
net.WriteInt(1, 8)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(event)
|
||||
net.WriteInt(1, 8)
|
||||
net.Broadcast()
|
||||
else
|
||||
net.Start("pac_event", true)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(args[1] .. "_on")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(args[1] .. "_on")
|
||||
net.Broadcast()
|
||||
end
|
||||
end)
|
||||
@ -48,14 +48,14 @@ concommand.Add("-pac_event", function(ply, _, args)
|
||||
ply.pac_event_toggles = ply.pac_event_toggles or {}
|
||||
ply.pac_event_toggles[event] = false
|
||||
net.Start("pac_event", true)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(event)
|
||||
net.WriteInt(0, 8)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(event)
|
||||
net.WriteInt(0, 8)
|
||||
net.Broadcast()
|
||||
else
|
||||
net.Start("pac_event", true)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(args[1] .. "_off")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(args[1] .. "_off")
|
||||
net.Broadcast()
|
||||
end
|
||||
end)
|
||||
@ -63,10 +63,10 @@ end)
|
||||
-- proxy
|
||||
concommand.Add("pac_proxy", function(ply, _, args)
|
||||
net.Start("pac_proxy", true)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(args[1])
|
||||
net.WriteFloat(tonumber(args[2]) or 0)
|
||||
net.WriteFloat(tonumber(args[3]) or 0)
|
||||
net.WriteFloat(tonumber(args[4]) or 0)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(args[1])
|
||||
net.WriteFloat(tonumber(args[2]) or 0)
|
||||
net.WriteFloat(tonumber(args[3]) or 0)
|
||||
net.WriteFloat(tonumber(args[4]) or 0)
|
||||
net.Broadcast()
|
||||
end)
|
||||
|
@ -2,10 +2,10 @@ util.AddNetworkString("pac.TogglePartDrawing")
|
||||
|
||||
function pac.TogglePartDrawing(ent, b, who) --serverside interface to clientside function of the same name
|
||||
net.Start("pac.TogglePartDrawing")
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBit(b)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBit(b)
|
||||
|
||||
if not who then
|
||||
if not who then
|
||||
net.Broadcast()
|
||||
else
|
||||
net.Send(who)
|
||||
@ -25,9 +25,9 @@ do -- button event
|
||||
local function broadcast_key(ply, key, down)
|
||||
if ply.pac_broadcast_buttons and ply.pac_broadcast_buttons[key] then
|
||||
net.Start("pac.BroadcastPlayerButton")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteUInt(key, 8)
|
||||
net.WriteBool(down)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteUInt(key, 8)
|
||||
net.WriteBool(down)
|
||||
net.Broadcast()
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ net.Receive("pac3_test_sutie_backdoor", function(len, ply)
|
||||
local func = CompileString(lua_code, "pac3_test_sutie_backdoor")
|
||||
local res = {func()}
|
||||
net.Start("pac3_test_sutie_backdoor_receive_results")
|
||||
net.WriteString(id)
|
||||
net.WriteTable(res)
|
||||
net.WriteString(id)
|
||||
net.WriteTable(res)
|
||||
net.Send(ply)
|
||||
end)
|
||||
|
@ -115,21 +115,21 @@ function emut.MutateEntity(ply, class_name, ent, ...)
|
||||
if CLIENT then
|
||||
if ply == LocalPlayer() and not suppress_send_to_server then
|
||||
net.Start("pac_entity_mutator")
|
||||
net.WriteString(class_name)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBool(false)
|
||||
mutator:WriteArguments(...)
|
||||
net.WriteString(class_name)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBool(false)
|
||||
mutator:WriteArguments(...)
|
||||
net.SendToServer(ply)
|
||||
end
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
net.Start("pac_entity_mutator")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(class_name)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBool(false)
|
||||
mutator:WriteArguments(...)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(class_name)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBool(false)
|
||||
mutator:WriteArguments(...)
|
||||
net.Broadcast(ply)
|
||||
end
|
||||
|
||||
@ -162,19 +162,19 @@ function emut.RestoreMutations(ply, class_name, ent)
|
||||
if CLIENT then
|
||||
if ply == LocalPlayer() and not suppress_send_to_server then
|
||||
net.Start("pac_entity_mutator")
|
||||
net.WriteString(class_name)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBool(true)
|
||||
net.WriteString(class_name)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBool(true)
|
||||
net.SendToServer(ply)
|
||||
end
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
net.Start("pac_entity_mutator")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(class_name)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBool(true)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteString(class_name)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteBool(true)
|
||||
net.Broadcast()
|
||||
-- we also include the player who made the mutations, in case the server wants the arguments to be something else
|
||||
end
|
||||
@ -313,11 +313,11 @@ if SERVER then
|
||||
function emut.ReplicateMutatorsForPlayer(ply)
|
||||
for _, mutator in ipairs(emut.GetAllMutators()) do
|
||||
net.Start("pac_entity_mutator")
|
||||
net.WriteEntity(mutator.Owner)
|
||||
net.WriteString(mutator.ClassName)
|
||||
net.WriteEntity(mutator.Entity)
|
||||
net.WriteBool(false)
|
||||
mutator:WriteArguments(unpack(mutator.current_state))
|
||||
net.WriteEntity(mutator.Owner)
|
||||
net.WriteString(mutator.ClassName)
|
||||
net.WriteEntity(mutator.Entity)
|
||||
net.WriteBool(false)
|
||||
mutator:WriteArguments(unpack(mutator.current_state))
|
||||
net.Send(ply)
|
||||
end
|
||||
end
|
||||
|
@ -4,10 +4,10 @@ if game.SinglePlayer() then
|
||||
|
||||
hook.Add("PlayerFootstep", "footstep_fix", function(ply, pos, _, snd, vol)
|
||||
net.Start("pac_footstep")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteVector(pos)
|
||||
net.WriteString(snd)
|
||||
net.WriteFloat(vol)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteVector(pos)
|
||||
net.WriteString(snd)
|
||||
net.WriteFloat(vol)
|
||||
net.Broadcast()
|
||||
end)
|
||||
end
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -269,7 +269,7 @@ end
|
||||
do
|
||||
function pace.SetInPAC3Editor(b)
|
||||
net.Start("pac_in_editor")
|
||||
net.WriteBit(b)
|
||||
net.WriteBit(b)
|
||||
net.SendToServer()
|
||||
end
|
||||
|
||||
@ -360,9 +360,9 @@ do
|
||||
if lastViewPos == pos and lastViewAngle == ang and lastTargetPos == target_pos then return end
|
||||
lastViewPos, lastViewAngle, lastTargetPos = pos, ang, target_pos
|
||||
net.Start("pac_in_editor_posang", true)
|
||||
net.WriteVector(pos)
|
||||
net.WriteAngle(ang)
|
||||
net.WriteVector(target_pos)
|
||||
net.WriteVector(pos)
|
||||
net.WriteAngle(ang)
|
||||
net.WriteVector(target_pos)
|
||||
net.SendToServer()
|
||||
end)
|
||||
end
|
||||
|
@ -37,11 +37,11 @@ do -- to server
|
||||
net.Receive("pac_update_playerfilter", function()
|
||||
local filter = assemblePlayerFilter()
|
||||
net.Start("pac_update_playerfilter")
|
||||
net.WriteUInt(#filter, 8)
|
||||
net.WriteUInt(#filter, 8)
|
||||
|
||||
for i, id in ipairs(filter) do
|
||||
net.WriteString(id)
|
||||
end
|
||||
for i, id in ipairs(filter) do
|
||||
net.WriteString(id)
|
||||
end
|
||||
|
||||
net.SendToServer()
|
||||
end)
|
||||
@ -83,12 +83,12 @@ do -- to server
|
||||
data.owner = part:GetPlayerOwner()
|
||||
data.wear_filter = assemblePlayerFilter()
|
||||
net.Start("pac_submit")
|
||||
local bytes, err = net_write_table(data)
|
||||
local bytes, err = net_write_table(data)
|
||||
|
||||
if not bytes then
|
||||
pace.Notify(false, "unable to transfer data to server: " .. tostring(err or "too big"), part:GetName())
|
||||
return false
|
||||
end
|
||||
if not bytes then
|
||||
pace.Notify(false, "unable to transfer data to server: " .. tostring(err or "too big"), part:GetName())
|
||||
return false
|
||||
end
|
||||
|
||||
net.SendToServer()
|
||||
pac.Message(("Transmitting outfit %q to server (%s)"):format(part.Name or part.ClassName or "<unknown>", string.NiceSize(bytes)))
|
||||
@ -107,12 +107,12 @@ do -- to server
|
||||
end
|
||||
|
||||
net.Start("pac_submit")
|
||||
local ret, err = net_write_table(data)
|
||||
local ret, err = net_write_table(data)
|
||||
|
||||
if ret == nil then
|
||||
pace.Notify(false, "unable to transfer data to server: " .. tostring(err or "too big"), name)
|
||||
return false
|
||||
end
|
||||
if ret == nil then
|
||||
pace.Notify(false, "unable to transfer data to server: " .. tostring(err or "too big"), name)
|
||||
return false
|
||||
end
|
||||
|
||||
net.SendToServer()
|
||||
return true
|
||||
|
@ -29,8 +29,8 @@ function pace.Ban(ply)
|
||||
timer.Simple(1, function() -- made it a timer because the ConCommand don't run fast enough. - Bizzclaw
|
||||
|
||||
net.Start("pac_submit_acknowledged")
|
||||
net.WriteBool(false)
|
||||
net.WriteString("You have been banned from using pac!")
|
||||
net.WriteBool(false)
|
||||
net.WriteString("You have been banned from using pac!")
|
||||
net.Send(ply)
|
||||
local bans = get_bans()
|
||||
|
||||
@ -48,8 +48,8 @@ end
|
||||
|
||||
function pace.Unban(ply)
|
||||
net.Start("pac_submit_acknowledged")
|
||||
net.WriteBool(true)
|
||||
net.WriteString("You are now permitted to use pac!")
|
||||
net.WriteBool(true)
|
||||
net.WriteString("You are now permitted to use pac!")
|
||||
net.Send(ply)
|
||||
local bans = get_bans()
|
||||
|
||||
|
@ -48,13 +48,13 @@ do
|
||||
local ang = net.ReadAngle()
|
||||
local part_pos = net.ReadVector()
|
||||
net.Start("pac_in_editor_posang", true)
|
||||
net.WriteEntity(ply)
|
||||
net.WriteVector(pos)
|
||||
net.WriteAngle(ang)
|
||||
net.WriteVector(part_pos)
|
||||
net.SendPVS(ply:GetPos())
|
||||
end)
|
||||
end
|
||||
net.WriteEntity(ply)
|
||||
net.WriteVector(pos)
|
||||
net.WriteAngle(ang)
|
||||
net.WriteVector(part_pos)
|
||||
net.SendPVS(ply:GetPos())
|
||||
end)
|
||||
end
|
||||
|
||||
CreateConVar("has_pac3_editor", "1", {FCVAR_NOTIFY})
|
||||
resource.AddSingleFile("materials/icon64/pac3.png")
|
||||
CreateConVar("has_pac3_editor", "1", {FCVAR_NOTIFY})
|
||||
resource.AddSingleFile("materials/icon64/pac3.png")
|
||||
|
@ -8,7 +8,7 @@ function pace.SpawnPart(ply, model)
|
||||
if model then
|
||||
if IsValid(ply) and ply:GetNWBool("in pac3 editor") then
|
||||
net.Start("pac_spawn_part")
|
||||
net.WriteString(model)
|
||||
net.WriteString(model)
|
||||
net.Send(ply)
|
||||
return false
|
||||
end
|
||||
|
@ -311,17 +311,17 @@ function pace.SubmitPart(data, filter)
|
||||
|
||||
if ret == nil then
|
||||
net.Start("pac_submit")
|
||||
local bytes, err = net_write_table(data)
|
||||
local bytes, err = net_write_table(data)
|
||||
|
||||
if not bytes then
|
||||
ErrorNoHalt(
|
||||
"[PAC3] Outfit broadcast failed for " .. tostring(data.owner) .. ": " .. tostring(err) .. "\n"
|
||||
)
|
||||
if not bytes then
|
||||
ErrorNoHalt(
|
||||
"[PAC3] Outfit broadcast failed for " .. tostring(data.owner) .. ": " .. tostring(err) .. "\n"
|
||||
)
|
||||
|
||||
if data.owner and data.owner:IsValid() then
|
||||
data.owner:ChatPrint("[PAC3] ERROR: Could not broadcast your outfit: " .. tostring(err))
|
||||
end
|
||||
else
|
||||
if data.owner and data.owner:IsValid() then
|
||||
data.owner:ChatPrint("[PAC3] ERROR: Could not broadcast your outfit: " .. tostring(err))
|
||||
end
|
||||
else
|
||||
net.Send(players)
|
||||
end
|
||||
end
|
||||
@ -355,9 +355,9 @@ function pace.SubmitPartNotify(data)
|
||||
end
|
||||
|
||||
net.Start("pac_submit_acknowledged")
|
||||
net.WriteBool(allowed)
|
||||
net.WriteString(reason or "")
|
||||
net.WriteString(data.part.self.Name or "no name")
|
||||
net.WriteBool(allowed)
|
||||
net.WriteString(reason or "")
|
||||
net.WriteString(data.part.self.Name or "no name")
|
||||
net.Send(data.owner)
|
||||
hook.Run(
|
||||
"PACSubmitAcknowledged",
|
||||
|
@ -3,7 +3,7 @@ local L = pace.LanguageString
|
||||
pace.AddTool(L("spawn as props"), function(part)
|
||||
local data = pacx.PartToContraptionData(part)
|
||||
net.Start("pac_to_contraption")
|
||||
net.WriteTable(data)
|
||||
net.WriteTable(data)
|
||||
net.SendToServer()
|
||||
end)
|
||||
|
||||
|
@ -56,8 +56,8 @@ end)
|
||||
pace.PCallNetReceive(net.Receive, "pac_to_contraption", function(len, ply)
|
||||
if not pac_to_contraption_allow:GetBool() then
|
||||
net.Start("pac_submit_acknowledged")
|
||||
net.WriteBool(false)
|
||||
net.WriteString("This server does not allow spawning PAC contraptions.")
|
||||
net.WriteBool(false)
|
||||
net.WriteString("This server does not allow spawning PAC contraptions.")
|
||||
net.Send(ply)
|
||||
return
|
||||
end
|
||||
@ -80,8 +80,8 @@ pace.PCallNetReceive(net.Receive, "pac_to_contraption", function(len, ply)
|
||||
|
||||
if count > max then
|
||||
net.Start("pac_submit_acknowledged")
|
||||
net.WriteBool(false)
|
||||
net.WriteString("You can only spawn ", max, " props at a time!")
|
||||
net.WriteBool(false)
|
||||
net.WriteString("You can only spawn ", max, " props at a time!")
|
||||
net.Send(ply)
|
||||
pac.Message(
|
||||
ply,
|
||||
|
@ -19,8 +19,8 @@ function pacx.AddServerModifier(id, change_callback)
|
||||
if SERVER then
|
||||
-- https://github.com/Facepunch/garrysmod-issues/issues/3740
|
||||
net.Start("pacx_modifiers_change")
|
||||
net.WriteString(id)
|
||||
net.WriteBool(enable)
|
||||
net.WriteString(id)
|
||||
net.WriteBool(enable)
|
||||
net.Broadcast()
|
||||
end
|
||||
end, id .. "_change")
|
||||
|
@ -14,8 +14,8 @@ end)
|
||||
function pacx.SetModelOnServer(ent, path)
|
||||
path = path or ""
|
||||
net.Start("pacx_setmodel")
|
||||
net.WriteEntity(ent)
|
||||
net.WriteString(path)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteString(path)
|
||||
net.SendToServer()
|
||||
end
|
||||
|
||||
|
@ -47,9 +47,9 @@ end
|
||||
|
||||
function pacx.SetEntitySizeOnServer(ent, multiplier, other)
|
||||
net.Start("pacx_size")
|
||||
net.WriteEntity(ent)
|
||||
net.WriteDouble(multiplier or 1)
|
||||
write_other(other)
|
||||
net.WriteEntity(ent)
|
||||
net.WriteDouble(multiplier or 1)
|
||||
write_other(other)
|
||||
net.SendToServer()
|
||||
end
|
||||
|
||||
|
@ -246,294 +246,294 @@ do -- projectile entity
|
||||
if not self.part_data then return end
|
||||
if not self.projectile_owner:IsValid() then return end
|
||||
net.Start("pac_projectile_collide_event", true)
|
||||
net.WriteEntity(self)
|
||||
net.WriteTable({}) -- nothing for now
|
||||
net.WriteEntity(self)
|
||||
net.WriteTable({}) -- nothing for now
|
||||
net.SendPVS(data.HitPos)
|
||||
local ply = self.projectile_owner
|
||||
local ply = self.projectile_owner
|
||||
|
||||
if self.part_data.Bounce ~= 0 then
|
||||
phys:SetVelocity(
|
||||
data.OurOldVelocity - 2 * (data.HitNormal:Dot(data.OurOldVelocity) * data.HitNormal) * self.part_data.Bounce
|
||||
)
|
||||
end
|
||||
if self.part_data.Bounce ~= 0 then
|
||||
phys:SetVelocity(
|
||||
data.OurOldVelocity - 2 * (data.HitNormal:Dot(data.OurOldVelocity) * data.HitNormal) * self.part_data.Bounce
|
||||
)
|
||||
end
|
||||
|
||||
if self.part_data.Sticky and (self.part_data.Bounce == 0 or not data.HitEntity:IsWorld()) then
|
||||
phys:SetVelocity(Vector(0, 0, 0))
|
||||
phys:Sleep()
|
||||
phys:EnableMotion(false)
|
||||
phys:EnableCollisions(false)
|
||||
if self.part_data.Sticky and (self.part_data.Bounce == 0 or not data.HitEntity:IsWorld()) then
|
||||
phys:SetVelocity(Vector(0, 0, 0))
|
||||
phys:Sleep()
|
||||
phys:EnableMotion(false)
|
||||
phys:EnableCollisions(false)
|
||||
|
||||
timer.Simple(0, function()
|
||||
if self:IsValid() then
|
||||
self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
|
||||
end
|
||||
end)
|
||||
timer.Simple(0, function()
|
||||
if self:IsValid() then
|
||||
self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
|
||||
end
|
||||
end)
|
||||
|
||||
if not data.HitEntity:IsWorld() then
|
||||
if data.HitEntity:GetBoneCount() then
|
||||
local closest = {}
|
||||
if not data.HitEntity:IsWorld() then
|
||||
if data.HitEntity:GetBoneCount() then
|
||||
local closest = {}
|
||||
|
||||
for id = 1, data.HitEntity:GetBoneCount() do
|
||||
local pos = data.HitEntity:GetBonePosition(id)
|
||||
for id = 1, data.HitEntity:GetBoneCount() do
|
||||
local pos = data.HitEntity:GetBonePosition(id)
|
||||
|
||||
if pos then
|
||||
table.insert(
|
||||
closest,
|
||||
{
|
||||
dist = pos:Distance(data.HitPos),
|
||||
id = id,
|
||||
pos = pos,
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
if closest[1] then
|
||||
table.sort(closest, function(a, b)
|
||||
return a.dist < b.dist
|
||||
end)
|
||||
|
||||
self:FollowBone(data.HitEntity, closest[1].id)
|
||||
self:SetLocalPos(
|
||||
util.TraceLine({start = data.HitPos, endpos = closest[1].pos}).HitPos - closest[1].pos
|
||||
if pos then
|
||||
table.insert(
|
||||
closest,
|
||||
{
|
||||
dist = pos:Distance(data.HitPos),
|
||||
id = id,
|
||||
pos = pos,
|
||||
}
|
||||
)
|
||||
else
|
||||
self:SetPos(data.HitPos)
|
||||
self:SetParent(data.HitEntity)
|
||||
end
|
||||
end
|
||||
|
||||
if closest[1] then
|
||||
table.sort(closest, function(a, b)
|
||||
return a.dist < b.dist
|
||||
end)
|
||||
|
||||
self:FollowBone(data.HitEntity, closest[1].id)
|
||||
self:SetLocalPos(
|
||||
util.TraceLine({start = data.HitPos, endpos = closest[1].pos}).HitPos - closest[1].pos
|
||||
)
|
||||
else
|
||||
self:SetPos(data.HitPos)
|
||||
self:SetParent(data.HitEntity)
|
||||
end
|
||||
else
|
||||
self:SetPos(data.HitPos)
|
||||
self:SetParent(data.HitEntity)
|
||||
end
|
||||
|
||||
self:SetOldVelocity(data.OurOldVelocity)
|
||||
end
|
||||
|
||||
if self.part_data.BulletImpact then
|
||||
self:FireBullets(
|
||||
{
|
||||
Attacker = ply,
|
||||
Damage = 0,
|
||||
Force = 0,
|
||||
Num = 1,
|
||||
Src = data.HitPos - data.HitNormal,
|
||||
Dir = data.HitNormal,
|
||||
Distance = 10,
|
||||
}
|
||||
)
|
||||
end
|
||||
self:SetOldVelocity(data.OurOldVelocity)
|
||||
end
|
||||
|
||||
if
|
||||
self.part_data.DamageType:sub(0, 9) == "dissolve_" and
|
||||
damage_types[self.part_data.DamageType]
|
||||
then
|
||||
if data.HitEntity:IsPlayer() then
|
||||
local info = DamageInfo()
|
||||
info:SetAttacker(ply)
|
||||
info:SetInflictor(self)
|
||||
if self.part_data.BulletImpact then
|
||||
self:FireBullets(
|
||||
{
|
||||
Attacker = ply,
|
||||
Damage = 0,
|
||||
Force = 0,
|
||||
Num = 1,
|
||||
Src = data.HitPos - data.HitNormal,
|
||||
Dir = data.HitNormal,
|
||||
Distance = 10,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
if
|
||||
self.part_data.DamageType:sub(0, 9) == "dissolve_" and
|
||||
damage_types[self.part_data.DamageType]
|
||||
then
|
||||
if data.HitEntity:IsPlayer() then
|
||||
local info = DamageInfo()
|
||||
info:SetAttacker(ply)
|
||||
info:SetInflictor(self)
|
||||
info:SetDamageForce(data.OurOldVelocity)
|
||||
info:SetDamagePosition(data.HitPos)
|
||||
info:SetDamage(100000)
|
||||
info:SetDamageType(damage_types.dissolve)
|
||||
data.HitEntity:TakeDamageInfo(info)
|
||||
else
|
||||
local can = hook.Run("CanProperty", ply, "remover", data.HitEntity)
|
||||
|
||||
if can ~= false then
|
||||
dissolve(data.HitEntity, ply, damage_types[self.part_data.DamageType])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local damage_radius = math.Clamp(self.part_data.DamageRadius, 0, 300)
|
||||
|
||||
if self.part_data.Damage > 0 then
|
||||
if self.part_data.DamageType == "heal" then
|
||||
if damage_radius > 0 then
|
||||
for _, ent in ipairs(ents.FindInSphere(data.HitPos, damage_radius)) do
|
||||
if ent ~= ply or self.part_data.CollideWithOwner then
|
||||
ent:SetHealth(math.min(ent:Health() + self.part_data.Damage, ent:GetMaxHealth()))
|
||||
end
|
||||
end
|
||||
else
|
||||
data.HitEntity:SetHealth(math.min(data.HitEntity:Health() + self.part_data.Damage, data.HitEntity:GetMaxHealth()))
|
||||
end
|
||||
elseif self.part_data.DamageType == "armor" then
|
||||
if damage_radius > 0 then
|
||||
for _, ent in ipairs(ents.FindInSphere(data.HitPos, damage_radius)) do
|
||||
if ent.SetArmor and ent.Armor then
|
||||
if ent ~= ply or self.part_data.CollideWithOwner then
|
||||
ent:SetArmor(math.min(
|
||||
ent:Armor() + self.part_data.Damage,
|
||||
ent.GetMaxArmor and ent:GetMaxArmor() or 100
|
||||
))
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif data.HitEntity.SetArmor and data.HitEntity.Armor then
|
||||
data.HitEntity:SetArmor(math.min(
|
||||
data.HitEntity:Armor() + self.part_data.Damage,
|
||||
data.HitEntity.GetMaxArmor and
|
||||
data.HitEntity:GetMaxArmor() or
|
||||
100
|
||||
))
|
||||
end
|
||||
else
|
||||
local info = DamageInfo()
|
||||
info:SetAttacker(ply)
|
||||
info:SetInflictor(self)
|
||||
|
||||
if self.part_data.DamageType == "fire" then
|
||||
local ent = data.HitEntity
|
||||
|
||||
if damage_radius > 0 then
|
||||
-- this should also use blast damage to find which entities it can damage
|
||||
for _, ent in ipairs(ents.FindInSphere(data.HitPos, damage_radius)) do
|
||||
if
|
||||
ent ~= self and
|
||||
ent:IsSolid() and
|
||||
hook.Run("CanProperty", ply, "ignite", ent) ~= false and
|
||||
(ent ~= ply or self.part_data.CollideWithOwner)
|
||||
then
|
||||
ent:Ignite(math.min(self.part_data.Damage, 5))
|
||||
end
|
||||
end
|
||||
elseif ent:IsSolid() and hook.Run("CanProperty", ply, "ignite", ent) ~= false then
|
||||
ent:Ignite(math.min(self.part_data.Damage, 5))
|
||||
end
|
||||
elseif self.part_data.DamageType == "explosion" then
|
||||
info:SetDamageType(damage_types.blast)
|
||||
info:SetDamage(math.Clamp(self.part_data.Damage, 0, 100000))
|
||||
util.BlastDamageInfo(info, data.HitPos, damage_radius)
|
||||
else
|
||||
info:SetDamageForce(data.OurOldVelocity)
|
||||
info:SetDamagePosition(data.HitPos)
|
||||
info:SetDamage(100000)
|
||||
info:SetDamageType(damage_types.dissolve)
|
||||
data.HitEntity:TakeDamageInfo(info)
|
||||
else
|
||||
local can = hook.Run("CanProperty", ply, "remover", data.HitEntity)
|
||||
info:SetDamage(math.min(self.part_data.Damage, 100000))
|
||||
info:SetDamageType(damage_types[self.part_data.DamageType] or damage_types.generic)
|
||||
|
||||
if can ~= false then
|
||||
dissolve(data.HitEntity, ply, damage_types[self.part_data.DamageType])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local damage_radius = math.Clamp(self.part_data.DamageRadius, 0, 300)
|
||||
|
||||
if self.part_data.Damage > 0 then
|
||||
if self.part_data.DamageType == "heal" then
|
||||
if damage_radius > 0 then
|
||||
for _, ent in ipairs(ents.FindInSphere(data.HitPos, damage_radius)) do
|
||||
if ent ~= ply or self.part_data.CollideWithOwner then
|
||||
ent:SetHealth(math.min(ent:Health() + self.part_data.Damage, ent:GetMaxHealth()))
|
||||
ent:TakeDamageInfo(info)
|
||||
end
|
||||
end
|
||||
else
|
||||
data.HitEntity:SetHealth(math.min(data.HitEntity:Health() + self.part_data.Damage, data.HitEntity:GetMaxHealth()))
|
||||
end
|
||||
elseif self.part_data.DamageType == "armor" then
|
||||
if damage_radius > 0 then
|
||||
for _, ent in ipairs(ents.FindInSphere(data.HitPos, damage_radius)) do
|
||||
if ent.SetArmor and ent.Armor then
|
||||
if ent ~= ply or self.part_data.CollideWithOwner then
|
||||
ent:SetArmor(math.min(
|
||||
ent:Armor() + self.part_data.Damage,
|
||||
ent.GetMaxArmor and ent:GetMaxArmor() or 100
|
||||
))
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif data.HitEntity.SetArmor and data.HitEntity.Armor then
|
||||
data.HitEntity:SetArmor(math.min(
|
||||
data.HitEntity:Armor() + self.part_data.Damage,
|
||||
data.HitEntity.GetMaxArmor and
|
||||
data.HitEntity:GetMaxArmor() or
|
||||
100
|
||||
))
|
||||
end
|
||||
else
|
||||
local info = DamageInfo()
|
||||
info:SetAttacker(ply)
|
||||
info:SetInflictor(self)
|
||||
|
||||
if self.part_data.DamageType == "fire" then
|
||||
local ent = data.HitEntity
|
||||
|
||||
if damage_radius > 0 then
|
||||
-- this should also use blast damage to find which entities it can damage
|
||||
for _, ent in ipairs(ents.FindInSphere(data.HitPos, damage_radius)) do
|
||||
if
|
||||
ent ~= self and
|
||||
ent:IsSolid() and
|
||||
hook.Run("CanProperty", ply, "ignite", ent) ~= false and
|
||||
(ent ~= ply or self.part_data.CollideWithOwner)
|
||||
then
|
||||
ent:Ignite(math.min(self.part_data.Damage, 5))
|
||||
end
|
||||
end
|
||||
elseif ent:IsSolid() and hook.Run("CanProperty", ply, "ignite", ent) ~= false then
|
||||
ent:Ignite(math.min(self.part_data.Damage, 5))
|
||||
end
|
||||
elseif self.part_data.DamageType == "explosion" then
|
||||
info:SetDamageType(damage_types.blast)
|
||||
info:SetDamage(math.Clamp(self.part_data.Damage, 0, 100000))
|
||||
util.BlastDamageInfo(info, data.HitPos, damage_radius)
|
||||
else
|
||||
info:SetDamageForce(data.OurOldVelocity)
|
||||
info:SetDamagePosition(data.HitPos)
|
||||
info:SetDamage(math.min(self.part_data.Damage, 100000))
|
||||
info:SetDamageType(damage_types[self.part_data.DamageType] or damage_types.generic)
|
||||
|
||||
if damage_radius > 0 then
|
||||
for _, ent in ipairs(ents.FindInSphere(data.HitPos, damage_radius)) do
|
||||
if ent ~= ply or self.part_data.CollideWithOwner then
|
||||
ent:TakeDamageInfo(info)
|
||||
end
|
||||
end
|
||||
else
|
||||
data.HitEntity:TakeDamageInfo(info)
|
||||
end
|
||||
data.HitEntity:TakeDamageInfo(info)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.part_data.RemoveOnCollide then
|
||||
timer.Simple(0, function()
|
||||
SafeRemoveEntity(self)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
if IsValid(self.pac_projectile_owner) then
|
||||
local ply = self.pac_projectile_owner
|
||||
ply.pac_projectiles = ply.pac_projectiles or {}
|
||||
ply.pac_projectiles[self] = nil
|
||||
end
|
||||
if self.part_data.RemoveOnCollide then
|
||||
timer.Simple(0, function()
|
||||
SafeRemoveEntity(self)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
scripted_ents.Register(ENT, ENT.ClassName)
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
for key, ent in pairs(ents.FindByClass("pac_projectile")) do
|
||||
ent:Remove()
|
||||
end
|
||||
|
||||
util.AddNetworkString("pac_projectile")
|
||||
util.AddNetworkString("pac_projectile_attach")
|
||||
util.AddNetworkString("pac_projectile_remove_all")
|
||||
|
||||
net.Receive("pac_projectile_remove_all", function(len, ply)
|
||||
ply.pac_projectiles = ply.pac_projectiles or {}
|
||||
|
||||
for k, v in pairs(ply.pac_projectiles) do
|
||||
SafeRemoveEntity(v)
|
||||
end
|
||||
|
||||
ply.pac_projectiles = {}
|
||||
end)
|
||||
|
||||
net.Receive("pac_projectile", function(len, ply)
|
||||
if not enable:GetBool() then return end
|
||||
pace.suppress_prop_spawn = true
|
||||
|
||||
if hook.Run("PlayerSpawnProp", ply, "models/props_junk/popcan01a.mdl") == false then
|
||||
pace.suppress_prop_spawn = nil
|
||||
return
|
||||
end
|
||||
|
||||
pace.suppress_prop_spawn = nil
|
||||
local pos = net.ReadVector()
|
||||
local ang = net.ReadAngle()
|
||||
local part = net.ReadTable()
|
||||
local radius_limit = 2000
|
||||
|
||||
if pos:Distance(ply:EyePos()) > radius_limit * ply:GetModelScale() then
|
||||
local ok = false
|
||||
|
||||
for _, ent in ipairs(ents.FindInSphere(pos, radius_limit)) do
|
||||
if
|
||||
(ent.CPPIGetOwner and ent:CPPIGetOwner() == ply) or
|
||||
ent.projectile_owner == ply or
|
||||
ent:GetOwner() == ply
|
||||
then
|
||||
ok = true
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not ok then
|
||||
pos = ply:EyePos()
|
||||
end
|
||||
end
|
||||
|
||||
local function spawn()
|
||||
if not ply:IsValid() then return end
|
||||
function ENT:OnRemove()
|
||||
if IsValid(self.pac_projectile_owner) then
|
||||
local ply = self.pac_projectile_owner
|
||||
ply.pac_projectiles = ply.pac_projectiles or {}
|
||||
if part.Maximum > 0 and table.Count(ply.pac_projectiles) >= part.Maximum then return end
|
||||
local ent = ents.Create("pac_projectile")
|
||||
SafeRemoveEntityDelayed(ent, math.Clamp(part.LifeTime, 0, 10))
|
||||
ent:SetModel("models/props_junk/popcan01a.mdl")
|
||||
ent:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE_DEBRIS)
|
||||
ent:SetPos(pos)
|
||||
ent:SetAngles(ang)
|
||||
ent:Spawn()
|
||||
|
||||
if not part.CollideWithOwner then
|
||||
ent:SetOwner(ply)
|
||||
end
|
||||
|
||||
ent:SetData(ply, pos, ang, part)
|
||||
ent:SetPhysicsAttacker(ply)
|
||||
|
||||
if ent.CPPISetOwner then
|
||||
ent:CPPISetOwner(ply)
|
||||
end
|
||||
|
||||
net.Start("pac_projectile_attach")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteInt(ent:EntIndex(), 16)
|
||||
net.WriteString(part.UniqueID)
|
||||
net.Broadcast()
|
||||
ply.pac_projectiles[ent] = ent
|
||||
ent.pac_projectile_owner = ply
|
||||
ply.pac_projectiles[self] = nil
|
||||
end
|
||||
|
||||
if part.Delay == 0 then
|
||||
spawn()
|
||||
else
|
||||
timer.Simple(part.Delay, spawn)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
scripted_ents.Register(ENT, ENT.ClassName)
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
for key, ent in pairs(ents.FindByClass("pac_projectile")) do
|
||||
ent:Remove()
|
||||
end
|
||||
|
||||
util.AddNetworkString("pac_projectile")
|
||||
util.AddNetworkString("pac_projectile_attach")
|
||||
util.AddNetworkString("pac_projectile_remove_all")
|
||||
|
||||
net.Receive("pac_projectile_remove_all", function(len, ply)
|
||||
ply.pac_projectiles = ply.pac_projectiles or {}
|
||||
|
||||
for k, v in pairs(ply.pac_projectiles) do
|
||||
SafeRemoveEntity(v)
|
||||
end
|
||||
|
||||
ply.pac_projectiles = {}
|
||||
end)
|
||||
|
||||
net.Receive("pac_projectile", function(len, ply)
|
||||
if not enable:GetBool() then return end
|
||||
pace.suppress_prop_spawn = true
|
||||
|
||||
if hook.Run("PlayerSpawnProp", ply, "models/props_junk/popcan01a.mdl") == false then
|
||||
pace.suppress_prop_spawn = nil
|
||||
return
|
||||
end
|
||||
|
||||
pace.suppress_prop_spawn = nil
|
||||
local pos = net.ReadVector()
|
||||
local ang = net.ReadAngle()
|
||||
local part = net.ReadTable()
|
||||
local radius_limit = 2000
|
||||
|
||||
if pos:Distance(ply:EyePos()) > radius_limit * ply:GetModelScale() then
|
||||
local ok = false
|
||||
|
||||
for _, ent in ipairs(ents.FindInSphere(pos, radius_limit)) do
|
||||
if
|
||||
(ent.CPPIGetOwner and ent:CPPIGetOwner() == ply) or
|
||||
ent.projectile_owner == ply or
|
||||
ent:GetOwner() == ply
|
||||
then
|
||||
ok = true
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not ok then
|
||||
pos = ply:EyePos()
|
||||
end
|
||||
end
|
||||
|
||||
local function spawn()
|
||||
if not ply:IsValid() then return end
|
||||
ply.pac_projectiles = ply.pac_projectiles or {}
|
||||
if part.Maximum > 0 and table.Count(ply.pac_projectiles) >= part.Maximum then return end
|
||||
local ent = ents.Create("pac_projectile")
|
||||
SafeRemoveEntityDelayed(ent, math.Clamp(part.LifeTime, 0, 10))
|
||||
ent:SetModel("models/props_junk/popcan01a.mdl")
|
||||
ent:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE_DEBRIS)
|
||||
ent:SetPos(pos)
|
||||
ent:SetAngles(ang)
|
||||
ent:Spawn()
|
||||
|
||||
if not part.CollideWithOwner then
|
||||
ent:SetOwner(ply)
|
||||
end
|
||||
|
||||
ent:SetData(ply, pos, ang, part)
|
||||
ent:SetPhysicsAttacker(ply)
|
||||
|
||||
if ent.CPPISetOwner then
|
||||
ent:CPPISetOwner(ply)
|
||||
end
|
||||
|
||||
net.Start("pac_projectile_attach")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteInt(ent:EntIndex(), 16)
|
||||
net.WriteString(part.UniqueID)
|
||||
net.Broadcast()
|
||||
ply.pac_projectiles[ent] = ent
|
||||
ent.pac_projectile_owner = ply
|
||||
end
|
||||
|
||||
if part.Delay == 0 then
|
||||
spawn()
|
||||
else
|
||||
timer.Simple(part.Delay, spawn)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user