Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

NativeFunction.Natives.HasEntityCollidedWithAnything('x') crashes plugin

Featured Replies

Spoiler

                        if (crimeCar != null)
                        {
                            Game.LogTrivial("######### Signal before collision check ############\");.");

                            if (NativeFunction.Natives.HasEntityCollidedWithAnything(crimeCar))
                            {
                                Game.LogTrivial("######### Signal from collision monitor ############\");.");
                                crimeCar.EngineHealth = crimeCar.EngineHealth - 50;
                                Game.DisplaySubtitle("~r~purp-Car damaged is: " + crimeCar.EngineHealth, 5000);
                            }
                        }

Above is a snippet that i expected to be functional, but it crashes my plugin, with :
Exception message: Cannot convert null to 'bool' because it is a non-nullable value type


But that makes no sense.
The check in HasEntityCollidedWithAnything(crimeCar) is secured in the entrance of the segment:
if (crimeCar != null)
HasEntityCollidedWithAnything(null) is not possible(?)
If crimeCar was null, then the expression should never be executed.
The api says that HasEntityCollidedWithAnything() returns a bool:

Spoiler

HAS_ENTITY_COLLIDED_WITH_ANYTHING
bool HasEntityCollidedWithAnything(int /* Entity */ entity);

Called on tick. Tested with vehicles, returns true whenever the vehicle is touching any entity. Note: for vehicles, the wheels can touch the ground and it will still return false, but if the body of the vehicle touches the ground, it will return true.

Namespace: ENTITY

What am i missing?

See my plugin here:
https://www.youtube.com/watch?v=peqSXuTfIyY

Let me know if you find it interesting.
Best Regards.

  • Management Team

The problem is that the dynamic call resolution is missing the return value hint, so it does not know what to return. You need to use the generic parameter to hint, such as HasEntityCollidedWithAnything<bool>(..). All functions invoked via the Natives class are dynamically resolved and there is zero type information available unless explicitly provided by you.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

  • Author
19 hours ago, LMS said:

The problem is that the dynamic call resolution is missing the return value hint, so it does not know what to return. You need to use the generic parameter to hint, such as HasEntityCollidedWithAnything<bool>(..). All functions invoked via the Natives class are dynamically resolved and there is zero type information available unless explicitly provided by you.

Thanks once again!
You are a life-saver! 👍

See my plugin here:
https://www.youtube.com/watch?v=peqSXuTfIyY

Let me know if you find it interesting.
Best Regards.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.