Closed
Description
Details
Held objects triggered by either Player:PickupObject
or the normal +use method have a few issues:
When dropping or releasing an object by either left or right click, SWEP:PrimaryAttack
or SWEP:SecondaryAttack
is triggered on the previously held weapon on the server only
Recreated by inserting a print into either function and comparing between server and client
Workaround:
function GM:OnPlayerPhysicsDrop(ply, ent, thrown)
ply.DroppedPhysicsFrame = FrameNumber()
end
function SWEP:PrimaryAttack()
if SERVER and FrameNumber() == self:GetOwner().DroppedPhysicsFrame then
return
end
end
Picking up an object triggers it's compiled physgun interactions as if they were picked up by the gravity gun/super gravity gun
This is mostly an issue when trying to pick up ragdolls belonging to combine soldiers/elites through PickupObject, as they're compiled with the boogie
interaction which causes them to flail around wildly and throw out tesla effects when dropped
Relevant code from the SDK:
void CRagdollProp::OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason )
{
CDefaultPlayerPickupVPhysics::OnPhysGunDrop( pPhysGunUser, Reason );
m_hPhysicsAttacker = pPhysGunUser;
m_flLastPhysicsInfluenceTime = gpGlobals->curtime;
if( HasPhysgunInteraction( "onpickup", "boogie" ) )
{
CRagdollBoogie::Create( this, 150, gpGlobals->curtime, 3.0f, SF_RAGDOLL_BOOGIE_ELECTRICAL );
}
Workaround:
function GM:OnEntityCreated(ent)
if ent:GetClass() == "env_ragdoll_boogie" then
ent:Remove()
end
end
Calling Player:PickupObject
from SWEP:PrimaryAttack
or SWEP:SecondaryAttack
causes it to immediately be thrown/dropped
Took a moment to figure out what was going on here, from what I can tell it ends up checking whether the player is holding down either button on the same frame as the object was picked up, thus immediately causing it to be dropped
Workaround:
function SWEP:SecondaryAttack()
local ply = self:GetOwner()
if CLIENT or FrameNumber() == ply.DroppedPhysicsFrame then
return
end
local ent = ply:GetUseEntity()
timer.Simple(0, function()
if not IsValid(ply) or not IsValid(ent) then
return
end
ply:PickupObject(ent)
end)
ply:ConCommand("-attack2")
end
Metadata
Metadata
Assignees
Labels
No labels