• Changing SWEP hold type not appearing to change on other clients besides you.
    19 replies, posted
I am intentionally changing player's hold type a number of times, most of the time during when they attack. At first, it was working fine, changing the hold type throughout the duration was working for me. However, as I have limited my testing to bots, i noticed using bot_mimic 1 that making the bots call the functions to change their hold type isn't applying for them. It seems to only be working for the client(?) but for other players they see their hold type isn't changing. Is there perhaps a specific way to make their hold types change correctly for other clients? small example mock up of what I have been doing: SWEP.HoldType = "fist" function SWEP:ChangeHoldType() if SERVER then self.Owner:SetHoldType("normal") timer.Simple(0.5,function() self.Owner:SetHoldType(self.Holdtype) end) end end From what Ive gathered from google and the forums here, hold type should be networked properly to every client. Perhaps I am misreading. (No, changing hold type out of an if server check doesn't seem to fix this)
Can you do a print statement to check that the function and timer are each being called properly in the first place?
Small bump but unfortunately yes all code is running(since its calling a bunch of functions to do the attack, the code above was an example and not the actual code) the example i wrote would't work anyway since you dont set the hold type on the weapons owner. :P (then again, fixing that example code wouldnt fix my issue besides making the code work) In fact, changing the code to just this SWEP.HoldType = "fist" function SWEP:ChangeHoldType() self:SetHoldType("normal") end does not change it to the normal hold type. I have an odd feeling that you can't change hold types on the fly on Garry's Mod, which is a real shame because I really would want this to be possible.
A bump, but I also even added a self:SetHoldType("normal") to the think hook of the swep, but it still only changes your hold type on your screen but others are not changed on your screen. Is there any way I can get around this or do I have to suggest this on the github?
Having tried this myself, it appears setting the hold type doesn't change the viewmodel for clients, just the world model. I don't know if there's a way to change this behaviour, like overriding the viewmodel draw functions, but that's worth a look in to.
That is not what im asking about. Of course hold types only affect the world model.
That looks like networking failure. Try checking the holdtype on client from both players to see if it got networked properly. This should not be a problem however since SetHoldType should auto network it to all players
https://files.facepunch.com/forum/upload/107320/db182c26-6ebd-4c0f-8fda-9bb87f8b9ee0/2018-07-28 15-13-09.mp4 No clue still.
I do it successfully with my lightsaber addon using self:SetHoldType() ON THE SERVER SIDE.
Unfortunately, doing it serverside only is also not changing the outcome.
I tried this with some bots on listen and local dedicated servers, and it appears to work for me. Have you tried this in a clean context with no other addons?
Considering this is being done via my own gamemode, the only addon is pointshop and ulx, both should have no affect. I also am using Jetboom's Lua Animation API. removing that however has no fixed this. If this is supposedly working, what could possibly be screwing it up for me? I really need my hold types to change.
When you say local server do you mean like a single player lan type thing?
indeed. Before that it was my dedicated server which is what i need.
as much as i hate bumping, ive halted any work i could be doing until i can fix this as this is a problem big enough that i cant avoid fixing. Is there any potential reason why on my dedicated server the hold types are not syncing but on a local server that i created from the singleplayer tab, works?
As of yet I have not been able to make this not work. Can you please describe explicitly your testing setup when it doesn't work? Where and on what platform is the dedicated server running? Please give the same information for the client, and also the server settings (particularly with regards to download/upload). Finally could you explain where the weapon files are and which files are being sent to clients etc. Ideally if you could post the entire you're using, we may be able to see what is happening.
Dedicated server is on my own pc that I'm also using to join the server: 3ghz intel pentium cpu 8gb ram i do not know any server settings for download/upload as i never had set one up (so I suppose whatever srcds defaults to) Client (me) only has workshop items the server uses, which are player models and i have checked all of them and they only have what player models should have. weapon files in the game mode is just ROOT(the game mode)/entities/weapons. AddCSLuaFile() SWEP.Contact         = "" SWEP.Author            = "" SWEP.Instructions    = "" SWEP.Spawnable            = true SWEP.AdminSpawnable        = true SWEP.ViewModelFOV     = 90 SWEP.ViewModel            = "models/weapons/cstrike/c_rif_ak47.mdl" SWEP.WorldModel            = "models/weapons/w_rif_ak47.mdl" SWEP.HoldType = "smg" SWEP.FiresUnderwater = true SWEP.Primary.Damage         = 50 SWEP.base                    = "weapon_base" SWEP.Primary.ClipSize        = 60 SWEP.Primary.DefaultClip    = 60 SWEP.Primary.Automatic        = true SWEP.Primary.Ammo            = "SMG1" SWEP.Primary.Delay = 1.25 SWEP.Weight                = 5 SWEP.AutoSwitchTo        = true SWEP.AutoSwitchFrom        = false SWEP.Category            = "test" SWEP.PrintName            = "AK47" SWEP.Slot                = 1 SWEP.SlotPos            = 1 SWEP.DrawAmmo            = false SWEP.DrawCrosshair        = false function SWEP:CustomAmmoDisplay()     self.AmmoDisplay = self.AmmoDisplay or {}     self.AmmoDisplay.Draw = false     return self.AmmoDisplay end function SWEP:SecondaryAttack()      end function SWEP:ShouldDropOnDie()     return false end function SWEP:Reload() end   function SWEP:Think() end function SWEP:Initialize() self:SetHoldType( self.HoldType ) end function SWEP:PrimaryAttack() self:SetHoldType( "normal" ) end   function SWEP:Deploy() return true; end function SWEP:Equip() end function SWEP:Holster() return true; end THIS is working, this will change the hold type for me and other players will change their hold type on my screen. However, this is a watered down "to the point" swep. the real swep has the problems with hold type changes. pastebin the entire wall of code that is having issues Here is the ENTIRE swep, regardless if you understand all of it or not it has setholdtype code all over it. (And while i wish i didnt have to give you the entire wall of code, i cannot find the issues myself)
Okay, after a significant amount of picking your script apart, I believe I have your answer. It would seem that if the SWEP's WorldModel is set to an empty string, SetHoldType doesn't work on the client rendering for other players. In essence, your solution is to use this instead: SWEP.WorldModel = "models/weapons/c_arms.mdl" which should draw empty hands. I don't know if this quirk is something @Rubat would be interested to know, but I will put a warning about it on the wiki page for SetHoldType anyway. As to why this doesn't happen with listen servers, my guess would be that the issue is related to the prediction system.
i used an empty string because the default fists swep does that. if thats truly the case, thats a little unfortunate since im sure alot of fist sweps do this.
This only affects bots in my tests.
Sorry, you need to Log In to post a reply to this thread.