Skip to content
  • 0 Unread 0
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse

Plutonium

  1. Home
  2. MW3 Modding Support & Discussion
  3. [Question] LUA Menu & ChaiScript

[Question] LUA Menu & ChaiScript

Scheduled Pinned Locked Moved MW3 Modding Support & Discussion
4 Posts 2 Posters 885 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S3VDITOundefined Offline
    S3VDITOundefined Offline
    S3VDITO
    wrote on last edited by S3VDITO
    #1

    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

    Rosamahaundefined 1 Reply Last reply
    0
    • S3VDITOundefined S3VDITO

      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

      Rosamahaundefined Offline
      Rosamahaundefined Offline
      Rosamaha
      wrote on last edited by
      #2

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

      S3VDITOundefined 1 Reply Last reply
      0
      • Rosamahaundefined Rosamaha

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

        S3VDITOundefined Offline
        S3VDITOundefined Offline
        S3VDITO
        wrote on last edited by S3VDITO
        #3

        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)
        
        Rosamahaundefined 1 Reply Last reply
        0
        • S3VDITOundefined S3VDITO

          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)
          
          Rosamahaundefined Offline
          Rosamahaundefined Offline
          Rosamaha
          wrote on last edited by
          #4

          S3VDITO okay good work tho! Hope to see it working on servers soon too!

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Unread 0
          • Recent
          • Tags
          • Popular
          • Users
          • Groups