CW2 keep attachments after death

So I have


RunConsoleCommand("cw_disable_all_attachments_on_spawn")

on so people dont spawn with all the attachments, but when they die the loose them, I just want them to NOT have them when they FIRST spawn but to keep them after death.
Is there any way I can do that?

As far as I know when people attach mods to a weapon there is no data saved. When the player dies he drops the weapon and for example it just drops an entity named weapon_cw2_ak47 (I don’t know the actual naming for CW2) if the player picks that entity up it only knows how to give an AK-47, without the attachments it previously had. If you’d want to do that you’d probably have to do some data saving somehow.

You could make a table containing the players owned attachments, which would be empty in

GM:PlayerInitialSpawn, then use

GM:FindUseEntity and check if it was a CW attachment and if the player does not already have it, add it to the table. Then, use

GM:PlayerSpawn and if the table is not empty, iterate through the table and give the attachments to the player.

Sounds intresting, but wont this cause to give all players the entities from other players?

If you code it right, it wont. You should have a table for each player, not a global/local table

Not sure how to make player specific tables, any gmod wiki article that might help me with that?

Have you tried doing it or are you just saying you dont know so someone will give you code to copy/paste?

While it would be great to get a copy paste id like to see a gmod wiki page so I can see what else I can combine it with.




player
Search
Hooks
GM:AllowPlayerPickup
GM:CanPlayerEnterVehicle
GM:CanPlayerSuicide
GM:CanPlayerUnfreeze
GM:DoPlayerDeath
GM:HandlePlayerDriving
GM:HandlePlayerDucking
GM:HandlePlayerJumping
GM:HandlePlayerLanding
GM:HandlePlayerNoClipping
GM:HandlePlayerSwimming
GM:HandlePlayerVaulting
GM:OnPlayerChangedTeam
GM:OnPlayerChat
GM:OnPlayerHitGround
GM:PlayerAuthed
GM:PlayerBindPress
GM:PlayerButtonDown
GM:PlayerButtonUp
GM:PlayerCanHearPlayersVoice
GM:PlayerCanJoinTeam
GM:PlayerCanPickupItem
GM:PlayerCanPickupWeapon
GM:PlayerCanSeePlayersChat
GM:PlayerConnect
GM:PlayerDeath
GM:PlayerDeathSound
GM:PlayerDeathThink
GM:PlayerDisconnected
GM:PlayerDriveAnimate
GM:PlayerEndVoice
GM:PlayerEnteredVehicle
GM:PlayerFootstep
GM:PlayerFrozeObject
GM:PlayerHurt
GM:PlayerInitialSpawn
GM:PlayerJoinTeam
GM:PlayerLeaveVehicle
GM:PlayerLoadout
GM:PlayerNoClip
GM:PlayerPostThink
GM:PlayerRequestTeam
GM:PlayerSay
GM:PlayerSelectSpawn
GM:PlayerSelectTeamSpawn
GM:PlayerSetHandsModel
GM:PlayerSetModel
GM:PlayerShouldTakeDamage
GM:PlayerShouldTaunt
GM:PlayerSilentDeath
GM:PlayerSpawn
GM:PlayerSpawnAsSpectator
GM:PlayerSpray
GM:PlayerStartTaunt
GM:PlayerStartVoice
GM:PlayerStepSoundTime
GM:PlayerSwitchFlashlight
GM:PlayerSwitchWeapon
GM:PlayerTick
GM:PlayerTraceAttack
GM:PlayerUnfrozeObject
GM:PlayerUse
GM:PostDrawPlayerHands
GM:PostPlayerDeath
GM:PostPlayerDraw
GM:PreDrawPlayerHands
GM:PrePlayerDraw
GM:ScalePlayerDamage
GM:SetPlayerSpeed
GM:SetupPlayerVisibility
GM:ShouldDrawLocalPlayer
Hooks: PLAYER
PLAYER:FinishMove
PLAYER:GetHandsModel
PLAYER:Init
PLAYER:Loadout
PLAYER:Move
PLAYER:PostDrawViewModel
PLAYER:PreDrawViewModel
PLAYER:SetModel
PLAYER:SetupDataTables
PLAYER:Spawn
PLAYER:StartMove
PLAYER:ViewModelChanged
SANDBOX:PlayerGiveSWEP
SANDBOX:PlayerSpawnedEffect
SANDBOX:PlayerSpawnedNPC
SANDBOX:PlayerSpawnedProp
SANDBOX:PlayerSpawnedRagdoll
SANDBOX:PlayerSpawnedSENT
SANDBOX:PlayerSpawnedSWEP
SANDBOX:PlayerSpawnedVehicle
SANDBOX:PlayerSpawnEffect
SANDBOX:PlayerSpawnNPC
SANDBOX:PlayerSpawnObject
SANDBOX:PlayerSpawnProp
SANDBOX:PlayerSpawnRagdoll
SANDBOX:PlayerSpawnSENT
SANDBOX:PlayerSpawnSWEP
SANDBOX:PlayerSpawnVehicle
Libraries
drive.PlayerStartDriving
drive.PlayerStopDriving
game.MaxPlayers
game.SinglePlayer
gmsave.PlayerLoad
gmsave.PlayerSave
navmesh.GetPlayerSpawnName
navmesh.SetPlayerSpawnName
Library: player
player.CreateNextBot
player.GetAll
player.GetBots
player.GetByID
player.GetBySteamID
player.GetBySteamID64
player.GetByUniqueID
player.GetCount
player.GetHumans
Library: player_manager
player_manager.AddValidHands
player_manager.AddValidModel
player_manager.AllValidModels
player_manager.ClearPlayerClass
player_manager.GetPlayerClass
player_manager.OnPlayerSpawn
player_manager.RegisterClass
player_manager.RunClass
player_manager.SetPlayerClass
player_manager.TranslatePlayerHands
player_manager.TranslatePlayerModel
player_manager.TranslateToPlayerModelName
serverlist.PlayerList
steamworks.GetPlayerName
steamworks.RequestPlayerInfo
team.GetPlayers
team.NumPlayers
undo.SetPlayer
util.GetPlayerTrace
widgets.PlayerTick
Global
LocalPlayer
Player
Classes
CRecipientFilter:AddAllPlayers
CRecipientFilter:AddPlayer
CRecipientFilter:GetPlayers
CRecipientFilter:RemoveAllPlayers
CRecipientFilter:RemovePlayer
Entity:ForcePlayerDrop
Entity:IsPlayer
Entity:IsPlayerHolding
Panel:SetPlayer
Class: Player
Player:AccountID
Player:AddCleanup
Player:AddCount
Player:AddDeaths
Player:AddFrags
Player:AddFrozenPhysicsObject
Player:AddPlayerOption
Player:AddVCDSequenceToGestureSlot
Player:Alive
Player:AllowFlashlight
Player:AllowImmediateDecalPainting
Player:AnimResetGestureSlot
Player:AnimRestartGesture
Player:AnimRestartMainSequence
Player:AnimSetGestureSequence
Player:AnimSetGestureWeight
Player:Armor
Player:Ban
Player:CanUseFlashlight
Player:ChatPrint
Player:CheckLimit
Player:ConCommand
Player:CreateRagdoll
Player:CrosshairDisable
Player:CrosshairEnable
Player:Crouching
Player:Deaths
Player:DebugInfo
Player:DetonateTripmines
Player:DoAnimationEvent
Player:DoAttackEvent
Player:DoCustomAnimEvent
Player:DoReloadEvent
Player:DoSecondaryAttack
Player:DrawViewModel
Player:DrawWorldModel
Player:DropNamedWeapon
Player:DropObject
Player:DropWeapon
Player:EnterVehicle
Player:EquipSuit
Player:ExitVehicle
Player:Flashlight
Player:FlashlightIsOn
Player:Frags
Player:Freeze
Player:GetActiveWeapon
Player:GetAimVector
Player:GetAllowFullRotation
Player:GetAllowWeaponsInVehicle
Player:GetAmmoCount
Player:GetAvoidPlayers
Player:GetCanWalk
Player:GetCanZoom
Player:GetClassID
Player:GetCount
Player:GetCrouchedWalkSpeed
Player:GetCurrentCommand
Player:GetCurrentViewOffset
Player:GetDrivingEntity
Player:GetDrivingMode
Player:GetDuckSpeed
Player:GetEyeTrace
Player:GetEyeTraceNoCursor
Player:GetFOV
Player:GetFriendStatus
Player:GetHands
Player:GetHoveredWidget
Player:GetHull
Player:GetHullDuck
Player:GetInfo
Player:GetInfoNum
Player:GetJumpPower
Player:GetLaggedMovementValue
Player:GetMaxSpeed
Player:GetName
Player:GetNoCollideWithTeammates
Player:GetObserverMode
Player:GetObserverTarget
Player:GetPData
Player:GetPlayerColor
Player:GetPlayerInfo
Player:GetPreferredCarryAngles
Player:GetPressedWidget
Player:GetPunchAngle
Player:GetRagdollEntity
Player:GetRenderAngles
Player:GetRunSpeed
Player:GetShootPos
Player:GetStepSize
Player:GetTimeoutSeconds
Player:GetTool
Player:GetUnDuckSpeed
Player:GetUserGroup
Player:GetVehicle
Player:GetViewEntity
Player:GetViewModel
Player:GetViewOffset
Player:GetViewOffsetDucked
Player:GetViewPunchAngles
Player:GetWalkSpeed
Player:GetWeapon
Player:GetWeaponColor
Player:GetWeapons
Player:Give
Player:GiveAmmo
Player:GodDisable
Player:GodEnable
Player:HasGodMode
Player:HasWeapon
Player:InVehicle
Player:IPAddress
Player:IsAdmin
Player:IsBot
Player:IsConnected
Player:IsDrivingEntity
Player:IsFrozen
Player:IsFullyAuthenticated
Player:IsListenServerHost
Player:IsMuted
Player:IsPlayingTaunt
Player:IsSpeaking
Player:IsSuitEquipped
Player:IsSuperAdmin
Player:IsTimingOut
Player:IsTyping
Player:IsUserGroup
Player:IsVoiceAudible
Player:IsWorldClicking
Player:KeyDown
Player:KeyDownLast
Player:KeyPressed
Player:KeyReleased
Player:Kick
Player:Kill
Player:KillSilent
Player:LagCompensation
Player:LastHitGroup
Player:LimitHit
Player:Lock
Player:MotionSensorPos
Player:Name
Player:Nick
Player:PacketLoss
Player:PhysgunUnfreeze
Player:PickupObject
Player:Ping
Player:PlayStepSound
Player:PrintMessage
Player:RemoveAllAmmo
Player:RemoveAllItems
Player:RemoveAmmo
Player:RemovePData
Player:RemoveSuit
Player:ResetHull
Player:Say
Player:ScreenFade
Player:SelectWeapon
Player:SendHint
Player:SendLua
Player:SetActiveWeapon
Player:SetAllowFullRotation
Player:SetAllowWeaponsInVehicle
Player:SetAmmo
Player:SetArmor
Player:SetAvoidPlayers
Player:SetCanWalk
Player:SetCanZoom
Player:SetClassID
Player:SetCrouchedWalkSpeed
Player:SetCurrentViewOffset
Player:SetDeaths
Player:SetDrivingEntity
Player:SetDSP
Player:SetDuckSpeed
Player:SetEyeAngles
Player:SetFOV
Player:SetFrags
Player:SetHands
Player:SetHoveredWidget
Player:SetHull
Player:SetHullDuck
Player:SetJumpPower
Player:SetLaggedMovementValue
Player:SetMaxSpeed
Player:SetMuted
Player:SetNoCollideWithTeammates
Player:SetNoTarget
Player:SetObserverMode
Player:SetPData
Player:SetPlayerColor
Player:SetPressedWidget
Player:SetRenderAngles
Player:SetRunSpeed
Player:SetStepSize
Player:SetSuppressPickupNotices
Player:SetTeam
Player:SetUnDuckSpeed
Player:SetupHands
Player:SetUserGroup
Player:SetViewEntity
Player:SetViewOffset
Player:SetViewOffsetDucked
Player:SetViewPunchAngles
Player:SetWalkSpeed
Player:SetWeaponColor
Player:ShouldDrawLocalPlayer
Player:ShouldDropWeapon
Player:ShowProfile
Player:SimulateGravGunDrop
Player:SimulateGravGunPickup
Player:Spectate
Player:SpectateEntity
Player:SprayDecal
Player:SprintDisable
Player:SprintEnable
Player:StartSprinting
Player:StartWalking
Player:SteamID
Player:SteamID64
Player:StopSprinting
Player:StopWalking
Player:StopZooming
Player:StripAmmo
Player:StripWeapon
Player:StripWeapons
Player:SuppressHint
Player:SwitchToDefaultWeapon
Player:Team
Player:TimeConnected
Player:TraceHullAttack
Player:TranslateWeaponActivity
Player:UnfreezePhysicsObjects
Player:UniqueID
Player:UniqueIDTable
Player:UnLock
Player:UnSpectate
Player:UserID
Player:ViewPunch
Player:ViewPunchReset
Player:VoiceVolume
Weapon:IsCarriedByLocalPlayer


There are a lot of player related hooks so it is quite hard to find the right one.

Player:UniqueIDTable or PLAYER:SetupDataTables are possibly the ones that could be used.

Well using a little bit of that common sense, you can use process of elimination by doing something like this:

  • Do I need to do anything with attachments when the player enters or exits noclip?
  • No? Then I dont need the GM:PlayerNoClip hook.

Also did you just search for “player” on the wiki and paste the list? Just use

GM:DoPlayerDeath and

GM:PlayerLoadout.

Once again I was thinking too much, you are just going to set “cw_keep_attachments_post_death” to 1. That way you keep attachments you picked up, and you already disabled giving any on spawn, so that is what you are looking for. Why dont you look to the CW Menu tho, the option is at the very top