![]() | ![]() |
Modest Menu Lua Scripting Megathread |
'; }
![]() | #2 | |||||||||||
Hacked North Korea Join Date: Mar 2017 Location: F000:FFF0 Posts: 2,183 Reputation: 111360 Points: 485,037, Level: 59
Level up: 98%, 8,963 Points needed
Activity: 6.0%
| Please note, every script will run in its own thread and each script can run only once at a time. Prefer many small scripts using dedicated actions rather than one script that combines everything. To always set the the vehicle heatlh to max when you first enter it: lua: local function OnVehicleChanged(oldVehicle, newVehicle)if newVehicle ~= nil thenif newVehicle:get_health() < 1000 thennewVehicle:set_health(1000)endendendmenu.register_callback('OnVehicleChanged', OnVehicleChanged) To set initial settings when switching player character (Michael, Trevor, Franklin or Online): lua: local function OnPlayerChanged(oldPlayer, newPlayer)-- When switching player, instantly refill health and armorif newPlayer ~= nil thennewPlayer:set_armour(100)newPlayer:set_health(newPlayer:get_max_health())menu.max_all_ammo()endendmenu.register_callback('OnPlayerChanged', OnPlayerChanged) __________________ "Perfect moments can be had, but not preserved, except in memory." -- Leonard Nimoy GTA5 Modest Menu | Modest Menu Scripts | |||||||||||
![]() | #3 | |||||||||||
n00bie Join Date: Aug 2014 Posts: 7 Reputation: 442 Points: 5,432, Level: 8
Level up: 3%, 1,068 Points needed
Activity: 0%
| Quote: Originally Posted by Kiddion Please note, every script will run in its own thread and each script can run only once at a time. Prefer many small scripts using dedicated actions rather than one script that combines everything. To always set the the vehicle heatlh to max when you first enter it: lua: local function OnVehicleChanged(oldVehicle, newVehicle)if newVehicle ~= nil thenif newVehicle:get_health() < 1000 thennewVehicle:set_health(1000)endendendmenu.register_callback('OnVehicleChanged', OnVehicleChanged) To set initial settings when switching player character (Michael, Trevor, Franklin or Online): lua: local function OnPlayerChanged(oldPlayer, newPlayer)-- When switching player, instantly refill health and armorif newPlayer ~= nil thennewPlayer:set_armour(100)newPlayer:set_health(newPlayer:get_max_health())menu.max_all_ammo()endendmenu.register_callback('OnPlayerChanged', OnPlayerChanged) I've tried alot to get the repair vehicle working, but im not familiar with lua and it keeps giving me errors if i try to make it a toggle/action in menu.lua. Any tips for a newcomer to lua to get this to work? I really appreciate you posted that function because the repair vehicle function on the menu isnt working properly as we speak. Thanks for your awesome efforts and hope to hear from you | |||||||||||
![]() | #4 | |||||||||||
Member Join Date: Mar 2020 Posts: 61 Reputation: 176 Points: 3,642, Level: 6
Level up: 5%, 858 Points needed
Activity: 4.0%
| intriguing Last edited by MokaMateria; 4th August 2021 at 03:49 AM. | |||||||||||
![]() | #6 | |||||||||||
^(.*)(S\d\dE\d\d).*.(mkv| mp4|mov|avi)$ Join Date: Jun 2020 Posts: 453 Reputation: 15005 Points: 22,765, Level: 21
Level up: 23%, 1,235 Points needed
Activity: 0%
| Quote: Originally Posted by Azamaticon Hello! Didn't find anything on animations. Can I make a character play an animation when a key is pressed? If it's not in the API "Readme.api" it probably doesn't exist. __________________
| |||||||||||
'; }
![]() | #7 | |||||||||||
Hacked North Korea Join Date: Mar 2017 Location: F000:FFF0 Posts: 2,183 Reputation: 111360 Points: 485,037, Level: 59
Level up: 98%, 8,963 Points needed
Activity: 6.0%
| Quote: Originally Posted by Azamaticon Hello! Didn't find anything on animations. Can I make a character play an animation when a key is pressed? If you find a way to do it externally, please let me know. __________________ "Perfect moments can be had, but not preserved, except in memory." -- Leonard Nimoy GTA5 Modest Menu | Modest Menu Scripts | |||||||||||
![]() | #8 | |||||||||||
n00bie Join Date: Jul 2020 Posts: 1 Reputation: 458 Points: 1, Level: 1
Level up: 0%, 1 Points needed
Activity: 0%
| dose copying and pasting lua scripts from other menus work? if so i have a bunch of scripts such as crash protections and crash options | |||||||||||
![]() | #10 | |||||||||||
Supreme H4x0|2 Join Date: Apr 2020 Location: to your left Posts: 643 Reputation: 4672 Points: 9,196, Level: 11
Level up: 46%, 604 Points needed
Activity: 0%
| Quote: Originally Posted by Blasted324 dose copying and pasting lua scripts from other menus work? if so i have a bunch of scripts such as crash protections and crash options Kiddion explicitly said no so your skidded p2c scripts will not work. | |||||||||||
![]() | #11 | |||||||||||
Hacked North Korea Join Date: Mar 2017 Location: F000:FFF0 Posts: 2,183 Reputation: 111360 Points: 485,037, Level: 59
Level up: 98%, 8,963 Points needed
Activity: 6.0%
| Some more examples... How to make a Snow toggle: snow.lua: menu.add_toggle("Snow", function()return globals.get_boolean(262145 + 4724) end, function(value)globals.set_boolean(262145 + 4724, value)end) Add a tiny player toggle: tiny_player.lua: menu.add_toggle("Tiny Player", function()if localplayer == nil thenreturn nilendreturn localplayer:get_config_flag(223)end, function(value)localplayer:set_config_flag(223, value)end) __________________ "Perfect moments can be had, but not preserved, except in memory." -- Leonard Nimoy GTA5 Modest Menu | Modest Menu Scripts | |||||||||||
'; }
![]() | #12 | |||||||||||
God-Like Join Date: Jun 2015 Posts: 170 Reputation: 1034 Points: 8,138, Level: 10
Level up: 49%, 562 Points needed
Activity: 10.0%
| Hello. But after that how do u load it from the menu in game ? is it automatic ? Cause in the script menu they don't show up. I've tried with the snow lua and tinyplayer | |||||||||||
![]() | #13 | |||||||||||
^(.*)(S\d\dE\d\d).*.(mkv| mp4|mov|avi)$ Join Date: Jun 2020 Posts: 453 Reputation: 15005 Points: 22,765, Level: 21
Level up: 23%, 1,235 Points needed
Activity: 0%
| Quote: Originally Posted by Tinny Hello. But after that how do u load it from the menu in game ? is it automatic ? Cause in the script menu they don't show up. I've tried with the snow lua and tinyplayer They're automatically loaded on startup, but you can manually reload them too from menu > reload scripts. For example if you add a script to the script folder while modest menu is already running, then you'll want to manually reload the scripts for them to show up. When you open the menu you should see "scripts" towards the bottom, that's where you should see "snow" toggle if you're using the snow script. __________________
Last edited by guylet; 4th August 2021 at 11:33 PM. | |||||||||||
![]() | #14 | |||||||||||
God-Like Join Date: Jun 2015 Posts: 170 Reputation: 1034 Points: 8,138, Level: 10
Level up: 49%, 562 Points needed
Activity: 10.0%
| I think I misunderstood it : I thought i have to put each code in different lua files with the desired name, but it seems that i have to add the code in the menu.lua file. Will go and try so | |||||||||||
![]() | #15 | |||||||||||
^(.*)(S\d\dE\d\d).*.(mkv| mp4|mov|avi)$ Join Date: Jun 2020 Posts: 453 Reputation: 15005 Points: 22,765, Level: 21
Level up: 23%, 1,235 Points needed
Activity: 0%
| Quote: Originally Posted by Tinny I think I misunderstood it : I thought i have to put each code in different lua files with the desired name, but it seems that i have to add the code in the menu.lua file. Will go and try so No you can have separate files __________________
| |||||||||||
![]() | #16 | |||||||||||
God-Like Join Date: Jun 2015 Posts: 170 Reputation: 1034 Points: 8,138, Level: 10
Level up: 49%, 562 Points needed
Activity: 10.0%
| My fault, totally forgot to remove the dot after the lua extension while renaming it. Anyway thank you, and i will try to fool around with it. Code: local function OnVehicleChanged(oldVehicle, newVehicle)if newVehicle ~= nil thenif newVehicle:get_health() < 1000 thennewVehicle:set_health(1000)endendend menu.register_callback('OnVehicleChanged', OnVehicleChanged) this one is automatic from what I can understand, but is it possible to be add it to the menu like the snow ? cause at the end it would be really suspicious if someone is just watching u by mistake | |||||||||||
'; }
![]() | #17 | |||||||||||
^(.*)(S\d\dE\d\d).*.(mkv| mp4|mov|avi)$ Join Date: Jun 2020 Posts: 453 Reputation: 15005 Points: 22,765, Level: 21
Level up: 23%, 1,235 Points needed
Activity: 0%
| Quote: Originally Posted by Tinny My fault, totally forgot to remove the dot after the lua extension while renaming it. Anyway thank you, and i will try to fool around with it. Code: local function OnVehicleChanged(oldVehicle, newVehicle)if newVehicle ~= nil thenif newVehicle:get_health() < 1000 thennewVehicle:set_health(1000)endendend menu.register_callback('OnVehicleChanged', OnVehicleChanged) this one is automatic from what I can understand, but is it possible to be add it to the menu like the snow ? cause at the end it would be really suspicious if someone is just watching u by mistake If you want to add a menu option, all you have to do is menu.add_toggle(string name, function name). You can see all the available functions in the "Readme.api" file. Edit: Have a look at menu.add_action too __________________
| |||||||||||
![]() | #19 | |||||||||||
Hacked North Korea Join Date: Mar 2017 Location: F000:FFF0 Posts: 2,183 Reputation: 111360 Points: 485,037, Level: 59
Level up: 98%, 8,963 Points needed
Activity: 6.0%
| Quote: Originally Posted by Tinny this one is automatic from what I can understand, but is it possible to be add it to the menu like the snow ? cause at the end it would be really suspicious if someone is just watching u by mistake I'm not sure what you mean, if you want a toggle to enable setting the health to 1000 when you enter a new vehicle, you could use: vehicle.lua: local heal_vehicle_on_change = falsem*nu.add_toggle("Heal Vehicle on Change", function() return heal_vehicle_on_change end, function(value)heal_vehicle_on_change = valueend) local function OnVehicleChanged(oldVehicle, newVehicle)if newVehicle ~= nil and heal_vehicle_on_change thenif newVehicle:get_health() < 1000 thennewVehicle:set_health(1000)endendendmenu.register_callback('OnVehicleChanged', OnVehicleChanged) If you want an action button to heal the vehicle, you can use: lua: menu.add_action("Heal Vehicle", function()if localplayer == nil thenreturnendcurrent_vehicle = localplayer:get_current_vehicle()if current_vehicle ~= nil thenif current_vehicle:get_health() < 1000 thencurrent_vehicle:set_health(1000)endendend) __________________ "Perfect moments can be had, but not preserved, except in memory." -- Leonard Nimoy GTA5 Modest Menu | Modest Menu Scripts | |||||||||||
![]() | #20 | |||||||||||
n00bie Join Date: Aug 2014 Posts: 7 Reputation: 442 Points: 5,432, Level: 8
Level up: 3%, 1,068 Points needed
Activity: 0%
| Quote: Originally Posted by Kiddion I'm not sure what you mean, if you want a toggle to enable setting the health to 1000 when you enter a new vehicle, you could use: vehicle.lua: local heal_vehicle_on_change = falsem*nu.add_toggle("Heal Vehicle on Change", function() return heal_vehicle_on_change end, function(value)heal_vehicle_on_change = valueend) local function OnVehicleChanged(oldVehicle, newVehicle)if newVehicle ~= nil and heal_vehicle_on_change thenif newVehicle:get_health() < 1000 thennewVehicle:set_health(1000)endendendmenu.register_callback('OnVehicleChanged', OnVehicleChanged) If you want an action button to heal the vehicle, you can use: lua: menu.add_action("Heal Vehicle", function()if localplayer == nil thenreturnendcurrent_vehicle = localplayer:get_current_vehicle()if current_vehicle ~= nil thenif current_vehicle:get_health() < 1000 thencurrent_vehicle:set_health(1000)endendend) These dont work, just hopped in to Online solely to check these 2 variations on heal vehicle. Both shown up in the menu but both didnt fix my car. | |||||||||||
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Release] [LUA] MenuHook - Lua Hack in Menu State | Detours | File Hider | Load Before Autorun | Leithzzze | Garry's Mod | 44 | 28th July 2019 08:32 AM |
Anyone have .LUA scripting experience? | BooGer | General Programming and Reversing | 0 | 2nd July 2004 08:34 PM |
Tags |
[coding], modest, menu, lua, scripting, megathread |
«Previous Thread|Next Thread»
All times are GMT. The time now is 11:18 AM.
no new posts