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.

Problem With Vehicle Spawn

Featured Replies

Can someone try to identify what causes the game to crash when a vehicle is spawned, the source code is here - https://github.com/jmwgamingyt/JMWs-GTA-V-Mods/blob/eab3c1f857f47a705b0b80beecbc4c21fedbb8bf/Police%20Trainer/Trainer.cs . The vehicle spawning code is :

 

spawnPoint = (Game.LocalPlayer.Character.GetOffsetPositionFront(5F));

new Vehicle(selectedItem.Text, spawnPoint);

 

(selectedItem.Text being the label of a RageNativeUI button)

 

Thanks in advance

Start a new Gamefiber, like this:
Gamefiber.StartNew(delegate
{
        spawnPoint = (Game.LocalPlayer.Character.GetOffsetPositionFront(5F));
        
new Vehicle(selectedItem.Text, spawnPoint);
});

 

The reason is that the ItemSelected event gets called from the FrameRender, but in the frame render you can't sleep its fiber/thread because it will crash, so you start a new one. The Vehicle constructor calls Model.LoadAndWait() internally, there is when your mod sleeps the frame render fiber/thread. 

There's some similar code in the RAGENativeUI examples: https://github.com/alexguirre/RAGENativeUI/blob/master/Example/MenuExample.cs#L140

Edited by alexguirre

You may want to check for the sender of the eventargs to confirm it's really one of the vehicle items. This is also done in the ragenativeUI example so you can check the code there.

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

  • Author
22 minutes ago, alexguirre said:

Start a new Gamefiber, like this:
Gamefiber.StartNew(delegate
{
        spawnPoint = (Game.LocalPlayer.Character.GetOffsetPositionFront(5F));
        
new Vehicle(selectedItem.Text, spawnPoint);
});

 

The reason is that the ItemSelected event gets called from the FrameRender, but in the frame render you can't sleep its fiber/thread because it will crash, so you start a new one. The Vehicle constructor calls Model.LoadAndWait() internally, there is when your mod sleeps the frame render fiber/thread. 

There's some similar code in the RAGENativeUI examples: https://github.com/alexguirre/RAGENativeUI/blob/master/Example/MenuExample.cs#L140

 

22 minutes ago, Albo1125 said:

You may want to check for the sender of the eventargs to confirm it's really one of the vehicle items. This is also done in the ragenativeUI example so you can check the code there.

Thanks :)

Edited by jmwgamingyt

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.