Log in to reply
 

ScriptHookVDotNet Says error about NativeUI



  • when i open the command in gta5 (F4) it tells me about MenuPool and NativeMenu that it doesnt have the right references even tho im 1000% sure it does any fix?

    (https://imgur.com/zMI8QO6)



  • You can't use NativeUI via an uncompiled (.cs) script. You have to compile it to a .dll to be able to use NativeUI.

    The reason this happens is because SHVDN automatically compiles .cs files for you using a hard-coded list of assemblies to reference, such as System.Windows.Forms. It does not reference NativeUI, so it will not be able to compile a mod using NativeUI.



  • @Jitnaught but it wont let me build the scrip when i hit build its showing that its building but then it randomly stops and it wont be in a debug file



  • You're in Visual Studio right? Make sure you've referenced NativeUI.dll in Visual Studio. And check the Error List to see what the problem is



  • This post is deleted!


  • @Jitnaught

    i used a NativeUITemplate:

    // Native UI Menu Template 3.0 - Abel Software
    // You must download and use Scripthook V Dot Net Reference and NativeUI Reference (LINKS AT BOTTOM OF THE TEMPLATE)
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Linq;
    using System.Text;
    using GTA;
    using GTA.Native;
    using NativeUI;

    public class NativeUITemplate : Script
    {
    private Ped playerPed = Game.Player.Character;
    private Player player = Game.Player;
    private MenuPool _menuPool;

    //Here we will add the code to use a .INI file for your menu open key
    ScriptSettings config;
    Keys OpenMenu;

    //Now, we will add your sub menu, which in this case, will be player menu to change your player model.
    public void PlayerModelMenu(UIMenu menu)
    {
    var playermodelmenu = _menuPool.AddSubMenu(menu, "Player Model Menu");
    for (int i = 0; i < 1; i++) ;

    //We will change our player model to the male LSPD officer
    var malecop = new UIMenuItem("Male LSPD Officer", "");
    playermodelmenu.AddItem(malecop);
    playermodelmenu.OnItemSelect += (sender, item, index) =>
    {
        if (item == malecop)
        {
            Game.Player.ChangeModel("S_M_Y_COP_01");
        }
    };
    

    }

    //Now, we will add your sub menu, which in this case, will be vehicle menu to spawn a car
    public void VehicleMenu(UIMenu menu)
    {
    var vehiclemenu = _menuPool.AddSubMenu(menu, "Vehicle Spawning");
    for (int i = 0; i < 1; i++) ;

    //For this example, we will be spawning the Adder
    var adder = new UIMenuItem("Adder", "");
    vehiclemenu.AddItem(adder);
    vehiclemenu.OnItemSelect += (sender, item, index) =>
    {
        if (item == adder)
        {
            Vehicle car = World.CreateVehicle("ADDER", Game.Player.Character.Position);
            Game.Player.Character.SetIntoVehicle(car, VehicleSeat.Driver);
        }
    };
    

    }

    //Now, we will add your sub menu, which in this case, will be weapon menu to equip a weapon
    public void WeaponMenu(UIMenu menu)
    {
    var weapons = _menuPool.AddSubMenu(menu, "Weapon Menu");
    for (int i = 0; i < 1; i++) ;

    //For this example, we will equipping a flashlight, combat pistol, and pump shotgun
    var newweapons = new UIMenuItem("Issue Weapons", "");
    weapons.AddItem(newweapons);
    weapons.OnItemSelect += (sender, item, index) =>
    {
        if (item == newweapons)
        {
            Game.Player.Character.Weapons.Give((WeaponHash)Function.Call<int>(Hash.GET_HASH_KEY, "WEAPON_FLASHLIGHT"), 1, true, true); //Weapon Hash, Weapon Equipped, Ammo Loaded
            Game.Player.Character.Weapons.Give((WeaponHash)Function.Call<int>(Hash.GET_HASH_KEY, "WEAPON_COMBATPISTOL"), 9999, false, true);
            Game.Player.Character.Weapons.Give((WeaponHash)Function.Call<int>(Hash.GET_HASH_KEY, "WEAPON_PUMPSHOTGUN"), 9999, false, true);
            UI.Notify("~g~You have been issued weapons!"); //This notification will appear with green text above the radar
            UI.ShowSubtitle("~g~You have been issued weapons!"); //This notification will appear at the bottom of the screen with green text
        }
    };
    

    }

    //Now we will add all of our sub menus into our main menu, and set the general information of the entire menu
    public NativeUITemplate()
    {
    _menuPool = new MenuPool();
    var mainMenu = new UIMenu("~r~Police~w~Menu ~b~V", "~b~Mod by Abel Gaming! ~r~V 1.9");
    _menuPool.Add(mainMenu);
    PlayerModelMenu(mainMenu); //Here we add the Player Model Sub Menu
    VehicleMenu(mainMenu); //Here we add the Vehicle Spawning Sub Menu
    WeaponMenu(mainMenu); //Here we add the Weapon Sub Menu
    _menuPool.RefreshIndex();

    //We will now call from the .INI file for our controls
    config = ScriptSettings.Load("scripts\\settings.ini");
    OpenMenu = config.GetValue<Keys>("Options", "OpenMenu", Keys.F7); //The F7 key will be set my default, but the user can change the key
    
    //This code will run with every ms tick
    Tick += (o, e) => _menuPool.ProcessMenus();
    
    //This code will open the menu
    KeyDown += (o, e) =>
    {
        if (e.KeyCode == OpenMenu && !_menuPool.IsAnyMenuOpen()) // Our menu on/off switch
            mainMenu.Visible = !mainMenu.Visible;
    };
    

    }
    }
    //Useful Links
    //All Vehicles - https://pastebin.com/uTxZnhaN
    //All Player Models - https://pastebin.com/i5c1zA0W
    //All Weapons - https://pastebin.com/M3kD9pnJ
    //Native UI - https://gtaforums.com/topic/809284-net-nativeui/
    //GTA V ScriptHook V Dot Net - https://www.gta5-mods.com/tools/scripthookv-net

    and this was the error:

    The type or namespace name 'GTA' could not be found (are you missing a using directive or an assembly reference?)

    Error CS0246 The type or namespace name 'GTA' could not be found (are you missing a using directive or an assembly reference?)

    and so it goes with : Ped/Player/Script/Scriptsetting

    Also got a few Warnings:

    Load of property 'RootNamespace' failed. The string for the root namespace must be a valid identifier.

    Warning There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "ScriptHookVDotNet2", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

    and yes it is on Visual Studio

    0



  • So it said i needed a different targeted version so i did that and now the build options are grayed out



  • Make sure to reference the latest ScriptHookVDotNet2.dll.

    To fix this warning:

    Warning There was a mismatch between the processor architecture of the project...

    Create an X64 platform in the Configuration Manager.
    Configuration Manager



  • i've done that and it dindt let me build still.
    i was able to build solution but ingame i got the exact same error in the comand



  • [22:56:30] [DEBUG] Loading API from .\ScriptHookVDotNet2.dll ...
    [22:56:30] [DEBUG] Loading API from .\ScriptHookVDotNet3.dll ...
    [22:56:30] [DEBUG] Loading scripts from C:\Program Files\Rockstar Games\Grand Theft Auto V\scripts ...
    [22:56:30] [ERROR] Failed to compile Class1.cs with 5 error(s):
    at line 11: The type or namespace name 'NativeUI' could not be found (are you missing a using directive or an assembly reference?)
    at line 17: The type or namespace name 'MenuPool' could not be found (are you missing a using directive or an assembly reference?)
    at line 24: The type or namespace name 'UIMenu' could not be found (are you missing a using directive or an assembly reference?)
    at line 42: The type or namespace name 'UIMenu' could not be found (are you missing a using directive or an assembly reference?)
    at line 61: The type or namespace name 'UIMenu' could not be found (are you missing a using directive or an assembly reference?)

    [22:56:30] [DEBUG] Loading assembly MyMenuMod.dll ...
    [22:56:30] [INFO] Found 1 script(s) in MyMenuMod.dll resolved to API 2.10.12.
    [22:56:30] [DEBUG] Loading assembly NativeUI.dll ...
    [22:56:30] [INFO] Found 1 script(s) in NativeUI.dll resolved to API 2.10.12.
    [22:56:30] [DEBUG] Instantiating script NativeUITemplate ...
    [22:56:31] [INFO] Started script NativeUITemplate.
    [22:56:31] [DEBUG] Instantiating script NativeUI.BigMessageThread ...
    [22:56:31] [INFO] Started script NativeUI.BigMessageThread.



  • You have to compile using Visual Studio then copy the .dll file to your scripts folder. Not the .cs file.



  • oo sorry i had both the .cs file and dll file into my scripts

    thx btw for the help im gonne test it rn



  • This post is deleted!


  • @Jitnaught Worked ty So much


Log in to reply
 

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