mythlessninja Posted February 12, 2019 Posted February 12, 2019 For example ref test let test := GetContainer And than I want to check if "test" is a player. Is it possible? Or meybe there is another way. Im noob so idk.
QQuix Posted February 12, 2019 Posted February 12, 2019 Use: if test == playerref Keyword Player refers to the Player Base ObjectKeyword PlayerRef refers to the Player reference
mythlessninja Posted February 12, 2019 Author Posted February 12, 2019 Thanks for help! It works! It is exacly what I was looking for. But I don't understand the diffrence beetwen "Player" and "PlayerRef". I tried both and both worked.
QQuix Posted February 12, 2019 Posted February 12, 2019 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.
mythlessninja Posted February 13, 2019 Author Posted February 13, 2019 Thanks for the reply. It's something good to know if I get similar problem in the future.
Recommended Posts