Jump to content

How to check if reference is a player?


Recommended Posts

First, make sure you understand the terms 'Reference' and 'Base Object' (in Modding Terminology)

 

Both work because, when you use Player, the compiler tries to guess whether you mean Player or PlayerRef and use whatever it guesses in that compilation.

Since referencing the Player Base Object is quite rare, the compiler usually silently converts Player to PlayerRef and all works.

 

I used to use Player to reference the Player reference in all my scripts until one day I had to waste many, many hours in a bug that I could not find.

That was when Scruggs explained me the above.

In that particular case, the compiler decided to assume that Player really meant Player (Base Object) which broke the script.

After that I always use Player and PlayerRef correctly to make sure I will never fall in that trap again.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...