NullReferenceException when using BasePlayer in OnRotateVendingMachineFixed
The Method:
object OnRotateVendingMachine(VendingMachine machine, BasePlayer player)
{
   Puts("Player: " + player);
   return null;
}​

Puts Return: "Player: " on console.
If i set 
Puts("Player: "+player.displayName);​
Return this error.




I'ts my error?

Thanks in advanced!
The first code you've posted should actually return InvalidCastException cuz you can't turn BasePlayer into a string. As for following - always make null checks before using objects from game engine (Something always can go wrong and every object in the hook could be null (if it's reference type ofcourse))
Player could be null :thinking:
In response to misticos ():
Player could be null :thinking:
if (player == null) return null;


So in the try... when player rotates the machine... nothing occur.
The event is not detecting the player, always the player is null.

In response to 2CHEVSKII ():
The first code you've posted should actually return InvalidCastException cuz you can't turn BasePlay...
The first code return "empty"... nothing. (Consider that this is just a test for Exceptions)
I do the validation with null, but always player is null.
The 2nd argument was not being set, was always null. Fixed in upcoming builds.
Locked automatically