Can this LemonUI glitch be fixed?
I'm not saying the UI is glitched, but my implementation is. So, I have 2 of 3 LemonUI fav menus progressing well.
Why create 3 separate Menus? Just because it makes organizing the favs and using them quicker and because I have tons of code in the Peds (and same will happen for vehicles) because I change their components, add weapons, god mod, relationships, etc and conditionals for the list items.
Ok so the problem. It only happens once, and on reloading SH the problem is gone for the remainder of the session. If I start the menus with the Peds, and then launch the Locations, the Locations won't respond. I need to hit F11 (my reload) and that's it, problem is fixed. I use different names for the pools to possibly avoid conflicts but that didn't work.
AFAIK, no other bindings to F5 (Peds) and F7 (Locations).
Issue can be seen at 25 or 26 seconds. Location does not respond, reload script, end of problem for remaining of game play.
Appears for some reason that the Location Menu will not initialize properly if Peds is used first. But on reload, problem disappears, until the next session of GTA V.
Maybe this is similar to Menyoo needing two shots to initialize. Probably not.
From your video, it looks like it stopped working after you changed the player's model. In your Locations menu, are you saving Game.Player.Character to a global variable? When you change your model, it will change the character, so you need to retrieve it again.
@Jitnaught Hi. I only refer to the player once and since I was testing at the time I played it safe. I think it's the only time player is called for that matter.
However I don't think the video was clear. The behaviour seems to be inconsistent. What is consistent: if the first instance/menu (Peds) is opened first (even leaving default Michael) then the second menu/second instance) will load but won't execute. Reloading scripts (insert, i use F11) restores functionality for both menus.
I gave the pools and menus different names but that doesn't appear to be the issue. To be perfectly honest I haven't troubleshooted this systematically but I'm not convinced that after the first reload the problem goes away.
It's a nuisance right now but I'm really happy with these menus - I mean it was more like a proof of concept for me but they can evolve and make life easier because as much as I love Menyoo it's way overkill and I don't have the expertise to modify its source code and recompile it.
@Jitnaught Ok. It appears you were right again, or right as usual. Quick test seems to confirm that changing the player is what breaks executing an item from second men.
I searched through my code for Peds menu (I wish we wouldn't call them Peds) and there is no reference to "PedPlayer". Even the character spawns, to avoid any issues while testing, i used
However, the Locations Menu is likely where the issue is because there i used a variable which isn't global and didn't need to be on its own.
private Ped PedPlayer = Game.Player.Character;.
Will do a search and replace (100+ lines, thank god for search and replace) but why is this happening since they are effectively different scripts, each in their own .dll?
Ironically it would be great if one script (in its own file or dll) could call another, but that would be tricky, no?
The closest I've been able to do that, well for the sake of organizing code, is to have multiple tabs in Visual Studio. I did this VB.Net by using
Not sure what equivalent is in C#, haven't had the need...yet.
Update: Confirmed that was the issue. THANKS!
Now I understand how one script could interfere with the other in this specific manner - realizing it is the player and not some ped that is teleporting. And, yes, I've experienced this issue before when the variable wasn't global, so I should have thought of it. But its the two separate .dlls that got me. Funny part, is i tried to have a script with all my ped spawns in one .dll and then have tasks in another and gave up trying. Here, I didn't want the scripts to interact and it seems they did.
But this is different because it's the player, so this issue would not have occurred with another ped.
@Jitnaught P.S. If it wasn't for your help, I would have given up scripting pretty quickly. The more I learn the more I realize how little I know, but I am learning.
why is this happening since they are effectively different scripts, each in their own .dll?
When you change the model, you are effectively creating a new Ped for the player to use. This makes any old reference to the player's Ped invalid, across all scripts. This is why most scripts will retrieve the player's Ped each tick, instead of once globally.
it would be great if one script (in its own file or dll) could call another, but that would be tricky, no?
It is possible, but kind of a pain. Easiest way to go about it would be to put all of the scripts (.cs files) into one project, then make whatever you want to be accessible from other scripts public static. For example this is how I toggle my menu from another script.
@Jitnaught Thanks again for the clarifications and sharing. I think I did something similar, but with VB.Net.
I broke up what was really 1 script into 4 pieces, using Partial. I think C# uses the same keyword?
It was also the first time I used Namespace, I normally omit it, but this time it was necessary. I had really done this just to organize my code. Cheers.
P.S. I was sloppy with my declarations, should have just written
Public Ped0, Ped1, Ped2 As Ped, etc