CounterStrikeSharp icon indicating copy to clipboard operation
CounterStrikeSharp copied to clipboard

playerPawn vs playerPawn.Value, etc

Open WeirdPhrog opened this issue 1 year ago • 5 comments

What's the difference between playerPawn and playerPawn.Value? weapon and weapon.Value? etc. What should I work with and when? What should I check for null and IsValid? Where can I read about this?

WeirdPhrog avatar Apr 12 '24 12:04 WeirdPhrog

  1. e.g. playerPawn is the handler of the entity, playerPawn.Value is the actual entity
  2. playerPawn.Value after check valid
  3. whenever you wanna change value or use function on the entity, check with != null && IsValid (not 100% accurate)
  4. docs.cssharp.dev

Yarukon avatar Apr 13 '24 01:04 Yarukon

Should I also check handler of the entity for valid?

WeirdPhrog avatar Apr 14 '24 08:04 WeirdPhrog

When you access .Value or .Get() on a handle, it will return null if its invalid, so you only need to check for null after accessing the value.

roflmuffin avatar Jul 26 '24 12:07 roflmuffin

This issue has been marked needs-author-action and may be missing some important information.

github-actions[bot] avatar Jul 26 '24 12:07 github-actions[bot]

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

github-actions[bot] avatar Aug 10 '24 03:08 github-actions[bot]

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days.

github-actions[bot] avatar Aug 25 '24 03:08 github-actions[bot]