Log in to reply

Help with LemonUI - Slider Implementation

  • Trying to implement the Slider in a LemonUI menu to change the paint Index. But I"m pretty sure I have it wrong because it's taking 2 clicks for each increment of a value of 1. The max is 160 based on what Menyoo displays.

    Documentation is very sparse:
    You can get the value with the Value property. There is also another property called Multiplier that will set the increase when moving the slider (for example, increase the numeric value by 10 instead of by 1).

    That's it, that's all.
    My code attempt:
    private static readonly NativeSliderItem PaintIndex = new NativeSliderItem("Change Paint Index", 160, 34);//160 is max based on Menyoo, 34 is start

    Vehicle LastVehicle = Function.Call<Vehicle>(Hash.GET_VEHICLE_PED_IS_IN, Game.Player.Character, true);
    // int MyIndex = PaintIndex.Value;
    { Function.Call(Hash.SET_VEHICLE_COLOURS, LastVehicle, PaintIndex.Value, PaintIndex.Value); }

    UI.ShowSubtitle("Paint IndexValue is "+ PaintIndex.Value, 4000);

  • Ok, I know I'm talking to myself but I think I figured out how to fix this.
    Seems I'm calling the function to identify the vehicle each time the slider is invoked rather than just once.
    Going to try something with a public variable, suspense is killing me.

    Update: Moved the get_vehicle_ped_is_in to public, no syntax errors, function picked it up nicely, but still requires two clicks, one to increment/decrement, the second to get the value. I'm sure it can be done in one click.

  • @JohnFromGWN
    Are you using the EventHandler like:
    "PaintIndex.ValueChanged += PaintIndex_ValueChanged;" and then just put
    "Function.Call(Hash.SET_VEHICLE_COLOURS, LastVehicle, PaintIndex.Value, PaintIndex.Value)" into the new function?

    Wasn't sure how you had it all setup but was just curious. Working on a mod now so I'll give this a try and see if I can make it work.

    So quick test and it works fine for me using

    private void PaintIndex_ValueChanged(object sender, EventArgs e)
                Function.Call(Hash.SET_VEHICLE_COLOURS, Game.Player.Character.LastVehicle, PaintIndex.Value, PaintIndex.Value);
                GTA.UI.Screen.ShowSubtitle("Paint IndexValue is " + PaintIndex.Value, 4000);

    Obviously you'd have to check if the vehicle exists and all of that but I had no issues.

  • @IAmJFry Perfect. Thank you so much for the answer and taking the time to test it.
    I was using the wrong event handler. And here is the super frustrating part. I didn't even know there were other event handlers. Not sure if this can be blamed on the fact that I don't always know what I'm trying to do or the fact that I can't find documentation other than the few lines from the wiki.

    Can you point me to the documentation or is this C#101? Again thank you!

    On a related topic, from the wiki:
    There is also another property called Multiplier that will set the increase when moving the slider (for example, increase the numeric value by 10 instead of by 1).

    This can be incredibly useful, but not sure how it would be implemented?

  • @JohnFromGWN
    No problem.
    What exactly are you looking for documentation on? The EventHandler I found was just by scrolling through the autocomplete menu that pops. I knew of the EventHandlers being a thing I think from back when I used to mess with VB when I was younger.

    I used this:

    if (Game.IsKeyPressed(Keys.ShiftKey))
                settingsVehicleSpeedRequired.Multiplier = 2;
                settingsVehicleSpeedRequired.Multiplier = 1;

    in the OnTick function to let me move the slider faster.

    Just an example of what I did.

  • @JohnFromGWN If try a workaround, since I don't know how to use the multiplier, I get unexpected results.

    Vehicle LastVehicle = Function.Call<Vehicle>(Hash.GET_VEHICLE_PED_IS_IN, Game.Player.Character, true);
    int MyIndex = PaintIndex.Value * 2;
    { Function.Call(Hash.SET_VEHICLE_COLOURS, LastVehicle, MyIndex, MyIndex); }

    Instead of multiplying by 2, it adds 2. So 47, 49, 51, 53, etc....as an example

  • @JohnFromGWN
    Are you wanting to multiply the current value by 2 because yea the multiplier is just the amount it increments by.

  • @IAmJFry Hi. In the example I'm using above, let's forget about multiplier property from LemonUI for now, why is my integer increasing by 2 rather than multiplying by 2.
    I'm expecting 3*2= 6 but getting 5 (3+2 instead). Why is that?

  • @JohnFromGWN
    Oh ok I misunderstood.
    Not sure really but where are you putting "int MyIndex = PaintIndex.Value * 2;" part at?

  • This post is deleted!

  • @JohnFromGWN Ok I figured this out. Classic PEBKAC or ID10T.
    My code was executing perfectly, it was the display that was misleading.
    For example, i had 35 which became 70, and 36 which become 72.
    Since my display showed 70 and 72, i wrongly concluded it was adding 2.
    Display should have been 35 to 70, 36 to 72.
    Stupid me!

    And again many thanks for showing me how to get the correct event handler.
    P.S. I should have known better as well because I write VBA code for Excel regularly.

  • This post is deleted!

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.