mirror of
https://github.com/HaodongMo/ArcCW.git
synced 2025-03-04 03:13:30 -05:00
network optimizations
This commit is contained in:
parent
0d1b2fe317
commit
8970ba4fdf
@ -150,9 +150,9 @@ hook.Add( "OnEntityCreated", "ArcCW_NPCWeaponReplacement", function(ent)
|
||||
|
||||
wpnent:Spawn()
|
||||
|
||||
if engine.ActiveGamemode() == "terrortown" and ArcCW.ConVars["ttt_atts"]:GetBool() then
|
||||
wpnent:NPC_SetupAttachments()
|
||||
end
|
||||
-- if engine.ActiveGamemode() == "terrortown" and ArcCW.ConVars["ttt_atts"]:GetBool() then
|
||||
-- wpnent:NPC_SetupAttachments()
|
||||
-- end
|
||||
|
||||
timer.Simple(0, function()
|
||||
if !ent:IsValid() then return end
|
||||
|
@ -746,9 +746,11 @@ function SWEP:DrawWorldModel()
|
||||
self:DoScopeGlint()
|
||||
end
|
||||
|
||||
if !self.CertainAboutAtts and !self.AttReqSent and IsValid(self:GetOwner()) then
|
||||
if !self.CertainAboutAtts and !self.AttReqSent and !IsValid(self:GetOwner()) then
|
||||
self.AttReqSent = true
|
||||
print(self, "network weapon from cl_viewmodel")
|
||||
-- print(self, "network weapon from cl_viewmodel")
|
||||
debugoverlay.Cross(self:GetPos(), 8, 10, color_white, true)
|
||||
debugoverlay.EntityTextAtPosition(self:GetPos(), 1, tostring(self) .. " requesting networking data", 10, color_white)
|
||||
net.Start("arccw_rqwpnnet")
|
||||
net.WriteEntity(self)
|
||||
net.SendToServer()
|
||||
|
@ -96,10 +96,11 @@ function SWEP:Deploy()
|
||||
-- Also not a good idea because networking many weapons will cause mass lag (e.g. TTT round setup)
|
||||
-- Instead, make client send a request when it is valid there
|
||||
--self:NetworkWeapon()
|
||||
elseif CLIENT and !self.CertainAboutAtts and IsValid(self:GetOwner()) then
|
||||
elseif CLIENT and !self.CertainAboutAtts and !self.AttReqSent and IsValid(self:GetOwner()) then
|
||||
-- If client is aware of this weapon and it's not on the ground, ask for attachment info
|
||||
-- If it is not on a player, delay networking until it is rendered (in cl_viewmodel)
|
||||
print(self, "network weapon from sh_deploy")
|
||||
-- print(self, "network weapon from sh_deploy")
|
||||
self.AttReqSent = true
|
||||
net.Start("arccw_rqwpnnet")
|
||||
net.WriteEntity(self)
|
||||
net.SendToServer()
|
||||
|
@ -86,9 +86,9 @@ function SWEP:WasBought(buyer)
|
||||
for i, k in pairs(self.Attachments) do
|
||||
k.RandomChance = 100
|
||||
end
|
||||
if ArcCW.ConVars["ttt_atts"]:GetBool() then
|
||||
self:NPC_SetupAttachments()
|
||||
end
|
||||
-- if ArcCW.ConVars["ttt_atts"]:GetBool() then
|
||||
-- self:NPC_SetupAttachments()
|
||||
-- end
|
||||
end
|
||||
|
||||
function SWEP:TTT_PostAttachments()
|
||||
@ -110,8 +110,13 @@ function SWEP:TTT_Init()
|
||||
self.Primary.ClipMax = 0
|
||||
end
|
||||
|
||||
if SERVER and ArcCW.ConVars["ttt_atts"]:GetBool() then
|
||||
self:NPC_SetupAttachments()
|
||||
if ArcCW.ConVars["ttt_atts"]:GetBool() then
|
||||
if SERVER then
|
||||
self:NPC_SetupAttachments()
|
||||
end
|
||||
elseif !IsValid(self:GetOwner()) then
|
||||
-- If attachments aren't randomized, client will not need to ask for att info.
|
||||
self.CertainAboutAtts = true
|
||||
end
|
||||
|
||||
if self.ForgetDefaultBehavior then return end
|
||||
|
Loading…
Reference in New Issue
Block a user