[Question] LUA Menu & ChaiScript

Topic created · 4 Posts · 160 Views
  • I'll start with LUA:
    Because of quarantine, I wanted to make a mod for an arms store (I wanted to repeat Survival Mod MW 2), but having made a menu for assault and sniper rifles, I asked myself: HOW TO GIVE THEM OUT ?!
    After thinking a bit, I decided to add a script (about it later) and it worked!
    [I used Game.SetDvar to implement this...]
    So questions about LUA:

    1. Can LUA notify the server?
    2. Is it possible to make a menu for the server so that it opens through:
    player.openMenu("menu"); // now i used it i get crush, i use default menu perk_display
    

    ChaiScript:
    Some commands crush server, so I could not use:

    player.giveWeapon("weapon"); // and other it command version giveWeapon(name, variant, akimbo) (private match and dedicate server)
    
    player.openMenu("menu"); // i getting crush server (private match and dedicate server)
    
    //probably the list is bigger, but I wrote only those that caused the server crash
    

    Source code menu: https://pastebin.com/raw/Nnmwt19M

    How to install it(Menu):

    1 - after starting the game open file common.lua (path: C:\Users\USERNAME\AppData\Local\Plutonium\storage\iw5\ui), open it with notepad, find

    function Popup_AddButton_Advanced(menu, text, xpos, ypos, width, onclickcb, onfocuscb, isvisiblecb, isenabledcb)
    

    add after menu:AddItem(button) (end function)

    return button
    

    2 - copy source and create new file(Ex: weapons.lua) in C:\Users\USERNAME\AppData\Local\Plutonium\storage\iw5\ui_mp

    3 - Start private match(your can open menu in dedicate server or ingame menu)

    4 - open console and write command

    openmenu weapon_class_selector
    

    Class Selector
    Sniper Rifle selector
    Assault Rifle selector
    Assault Rifle selector

  • @S3VDITO that just work for private right now or? So I can‘t do that on a Server ?
    Greetings Rosamaha

  • @Rosamaha said in [Question] LUA Menu & ChaiScript:

    @S3VDITO that just work for private right now or? So I can‘t do that on a Server ?
    Greetings Rosamaha

    I achieved work only in Private Match, it will not work on a dedicated server
    But you will have to make small improvements, add a small piece of code

    Chai

    // ChaiScript (giweWeapon not work(i getting crush))
    level.onNotify("connected", fun(args) {
    	var player = args[0];
            // Trying jump notify for check currnetly selected weapon
    	player.onNotify("jumped", fun(player) 
    	{
    		if(gsc.getDvar("weapon") != "null")
    		{
    			player.iprintlnbold(gsc.getDvar("weapon"));
    		}
    	});
    });
    

    LUA

    // Example(but add Game.SetDvar for all OnClick event)
    weapon_m16a4 = Popup_AddButton_Advanced(weapons, "M16A4", -225, -40, 450,
    	function(menu, item)	-- on click
    		// ADDED
                    Game.SetDvar("weapon", "iw5_m16a4_mp")
                    Game.CloseMenu("assault_class");
    	end,
            function(menu, item)	-- on focus
    		weapon_icon_assault:SetMaterial("weapon_m16a4")
    		weapon_info_assault:SetText("Short burst shot")
    	end,
    	nil,
    	nil,
    	nil)
    
  • @S3VDITO okay good work tho! Hope to see it working on servers soon too!

Log in to reply