LabAPI icon indicating copy to clipboard operation
LabAPI copied to clipboard

[BUG]: 'RoleExtensions.TryGetRandomSpawnPoint' throws NullReferenceException for some IFpcRole roles

Open CCrous opened this issue 10 months ago • 2 comments

Before You Report

  • [x] I have searched for existing reports of this bug, and this bug report is unique.

Version

1.1.4.2

Description

RoleExtensions.TryGetRandomSpawnPoint may throw a NullReferenceException for certain roles that implement IFpcRole.

The method assumes that all IFpcRole implementations have a non-null SpawnpointHandler, but in practice this is not always true (e.g. Scp0492).

To Reproduce

RoleTypeId.Scp0492.TryGetRandomSpawnPoint(out Vector3 position, out float rotation);

Expected Behavior

The method should safely return false when no spawn point is available, without throwing exceptions.

Additional Information

[ERROR] [LabApi] 'NullReferenceException' occurred while invoking 'OnServerRoundStarted' on '***': 'Object reference not set to an instance of an object', stack trace:
                                   at LabApi.Features.Extensions.RoleExtensions.TryGetRandomSpawnPoint (PlayerRoles.RoleTypeId role, UnityEngine.Vector3& position, System.Single& horizontalRotation) [0x00010] in <9e8e00107de94d4f8ea9fc96c93d382f>:0
                                   at ...

CCrous avatar Jan 29 '26 16:01 CCrous

Fixed and merged into internal dev branch. Will close issue after next update (No ETA)

davidsebesta1 avatar Feb 13 '26 17:02 davidsebesta1

This bug has been fixed in Game version: 14.2.6 LabApi Version: 1.1.6. If you encounter the bug again please reopen this issue!

SlejmUr avatar Mar 26 '26 09:03 SlejmUr