roflmuffin / CounterStrikeSharp

CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
https://docs.cssharp.dev
Other
742 stars 111 forks source link

playerPawn vs playerPawn.Value, etc #412

Open WeirdPhrog opened 4 months ago

WeirdPhrog commented 4 months ago

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?

Yarukon commented 4 months ago
  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
WeirdPhrog commented 4 months ago

Should I also check handler of the entity for valid?

roflmuffin commented 4 weeks ago

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.

github-actions[bot] commented 4 weeks ago

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

github-actions[bot] commented 2 weeks ago

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.