Simple menu scripts

Posts 1–3 of 3 · Page 1 of 1
Simple menu scripts
Hey people, lets make some clever menus

I've made these simple menu scripts, hope you like it and feel inspired to come up with more.

more info here
http://www.mpgh.net/forum/754-payday...-crimenet.html

SKILL MENU SCRIPT

Code:
-- SKILL MENUSCRIPT 

-- PLAY SOUND
managers.menu_component:post_event("menu_enter")

if not SimpleMenu then
    SimpleMenu = class()

    function SimpleMenu:init(title, message, options)
        self.dialog_data = { title = title, text = message, button_list = {},
                             id = tostring(math.random(0,0xFFFFFFFF)) }
        self.visible = false
        for _,opt in ipairs(options) do
            local elem = {}
            elem.text = opt.text
            opt.data = opt.data or nil
            opt.callback = opt.callback or nil
            elem.callback_func = callback(self, self, "_do_callback",
                                          { data = opt.data,
                                            callback = opt.callback})
            elem.cancel_button = opt.is_cancel_button or false
            if opt.is_focused_button then
                self.dialog_data.focus_button = #self.dialog_data.button_list+1
            end
            table.insert(self.dialog_data.button_list, elem)
        end
        return self
    end

    function SimpleMenu:_do_callback(info)
        if info.callback then
            if info.data then
                info.callback(info.data)
            else
                info.callback()
            end
        end
        self.visible = false
    end

    function SimpleMenu:show()
        if self.visible then
            return
        end
        self.visible = true
        managers.system_menu:show(self.dialog_data)
    end

    function SimpleMenu:hide()
        if self.visible then
            managers.system_menu:close(self.dialog_data.id)
            self.visible = false
            return
        end
    end
end

optionone = optionone or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET SKILLPOINTS TO 1
managers.skilltree:_set_points(1)
end

optiontwo = optiontwo or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET SKILLPOINTS TO 10
managers.skilltree:_set_points(10)
end

optionthree = optionthree or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET SKILLPOINTS TO 100
managers.skilltree:_set_points(100)
end

optionfour = optionfour or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET SKILLPOINTS TO 580
managers.skilltree:_set_points(580)
end

optionfive = optionfive or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- RESET SKILLPOINTS
managers.skilltree:_set_points(0)
end
opts = {}
opts[#opts+1] = { text = "ADD 1 SKILLPOINT", callback = optionone }
opts[#opts+1] = { text = "ADD 10 SKILLPOINTS", callback = optiontwo }
opts[#opts+1] = { text = "ADD 100 SKILLPOINT", callback = optionthree }
opts[#opts+1] = { text = "ADD 580 SKILLPOINT", callback = optionfour }
opts[#opts+1] = { text = "RESET SKILLPOINTS", callback = optionfive }
opts[#opts+1] = { text = "CANCEL", is_cancel_button = true }
mymenu = SimpleMenu:new("Skill Menu", "Set/reset skillpoints.", opts)

if not managers.hud then
mymenu:show()
end

-- DISPLAY MESSAGE ON SCREEN
if managers.hud then
managers.hud:show_hint( { text = "SKILL MENU NOT AVAILABLE INGAME" } )
end

LEVEL MENU SCRIPT

Code:
-- LEVEL MENU SCRIPT

-- PLAY SOUND
managers.menu_component:post_event("menu_enter")

if not SimpleMenu then
    SimpleMenu = class()

    function SimpleMenu:init(title, message, options)
        self.dialog_data = { title = title, text = message, button_list = {},
                             id = tostring(math.random(0,0xFFFFFFFF)) }
        self.visible = false
        for _,opt in ipairs(options) do
            local elem = {}
            elem.text = opt.text
            opt.data = opt.data or nil
            opt.callback = opt.callback or nil
            elem.callback_func = callback(self, self, "_do_callback",
                                          { data = opt.data,
                                            callback = opt.callback})
            elem.cancel_button = opt.is_cancel_button or false
            if opt.is_focused_button then
                self.dialog_data.focus_button = #self.dialog_data.button_list+1
            end
            table.insert(self.dialog_data.button_list, elem)
        end
        return self
    end

    function SimpleMenu:_do_callback(info)
        if info.callback then
            if info.data then
                info.callback(info.data)
            else
                info.callback()
            end
        end
        self.visible = false
    end

    function SimpleMenu:show()
        if self.visible then
            return
        end
        self.visible = true
        managers.system_menu:show(self.dialog_data)
    end

    function SimpleMenu:hide()
        if self.visible then
            managers.system_menu:close(self.dialog_data.id)
            self.visible = false
            return
        end
    end
end

optionone = optionone or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET LEVEL TO 1
managers.experience :_set_current_level(1)
end

optiontwo = optiontwo or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET LEVEL TO 25
managers.experience :_set_current_level(25)
end

optionthree = optionthree or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET LEVEL TO 50 
managers.experience :_set_current_level(50)
end

optionfour = optionfour or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET LEVEL TO 75
managers.experience :_set_current_level(75)
end

optionfive = optionfive or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- SET LEVEL TO 100
managers.experience :_set_current_level(100)
end

opts = {}
opts[#opts+1] = { text = "SET LEVEL TO 1", callback = optionone }
opts[#opts+1] = { text = "SET LEVEL TO 25", callback = optiontwo }
opts[#opts+1] = { text = "SET LEVEL TO 50", callback = optionthree }
opts[#opts+1] = { text = "SET LEVEL TO 75", callback = optionfour }
opts[#opts+1] = { text = "SET LEVEL TO 100", callback = optionfive }
opts[#opts+1] = { text = "CANCEL", is_cancel_button = true }
mymenu = SimpleMenu:new("Level Menu", "Change your level.", opts)

if not managers.hud then
mymenu:show()
end

-- DISPLAY MESSAGE ON SCREEN
if managers.hud then
managers.hud:show_hint( { text = "LEVEL MENU NOT AVAILABLE INGAME" } )
end
MONEY MENU SCRIPT

Code:
-- MONEY MENU SCRIPT 

-- PLAY SOUND
managers.menu_component:post_event("menu_enter")

if not SimpleMenu then
    SimpleMenu = class()

    function SimpleMenu:init(title, message, options)
        self.dialog_data = { title = title, text = message, button_list = {},
                             id = tostring(math.random(0,0xFFFFFFFF)) }
        self.visible = false
        for _,opt in ipairs(options) do
            local elem = {}
            elem.text = opt.text
            opt.data = opt.data or nil
            opt.callback = opt.callback or nil
            elem.callback_func = callback(self, self, "_do_callback",
                                          { data = opt.data,
                                            callback = opt.callback})
            elem.cancel_button = opt.is_cancel_button or false
            if opt.is_focused_button then
                self.dialog_data.focus_button = #self.dialog_data.button_list+1
            end
            table.insert(self.dialog_data.button_list, elem)
        end
        return self
    end

    function SimpleMenu:_do_callback(info)
        if info.callback then
            if info.data then
                info.callback(info.data)
            else
                info.callback()
            end
        end
        self.visible = false
    end

    function SimpleMenu:show()
        if self.visible then
            return
        end
        self.visible = true
        managers.system_menu:show(self.dialog_data)
    end

    function SimpleMenu:hide()
        if self.visible then
            managers.system_menu:close(self.dialog_data.id)
            self.visible = false
            return
        end
    end
end

optionone = optionone or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- ADD 1 MILLION AND 4 MILLION OFFSHORE
managers.money : _add_to_total(5000000)
end

optiontwo = optiontwo or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- ADD 10 MILLION AND 40 MILLION OFFSHORE
managers.money : _add_to_total(50000000)
end

optionthree = optionthree or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- ADD 100 MILLION AND 400 MILLION OFFSHORE
managers.money : _add_to_total(500000000)
end

optionfour = optionfour or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- ADD 1 BILLION AND 4 BILLION OFFSHORE
managers.money : _add_to_total(5000000000)

end

optionfive = optionfive or function()
-- PLAY SOUND
managers.menu_component:post_event("menu_enter")
-- RESET CASH AND OFFSHOREFUND
managers.money:_deduct_from_total(999999999999999999999)
managers.money:_deduct_from_offshore(999999999999999999999)
end

opts = {}
opts[#opts+1] = { text = "ADD 1 MILL CASH + 4 MILL OFFSHORE", callback = optionone }
opts[#opts+1] = { text = "ADD 10 MILL CASH + 40 MILL OFFSHORE", callback = optiontwo }
opts[#opts+1] = { text = "ADD 100 MILL CASH + 400 MILL OFFSHORE", callback = optionthree }
opts[#opts+1] = { text = "Add 1 BILLION CASH + 4 BILLION OFFSHORE", callback = optionfour }
opts[#opts+1] = { text = "RESET CASH AND OFFSHORE ACCOUNT", callback = optionfive }
opts[#opts+1] = { text = "CANCEL", is_cancel_button = true }
mymenu = SimpleMenu:new("Money Menu", "Add/remove cash and offshore funds.", opts)

if not managers.hud then
mymenu:show()
end

-- DISPLAY MESSAGE ON SCREEN
if managers.hud then
managers.hud:show_hint( { text = "MONEY MENU NOT AVAILABLE INGAME" } )
end

This one is not made by me, credits to @iligal_odin and Harfatus

JOB MENU SCRIPT

Code:
if not SimpleMenu then
    SimpleMenu = class()

    function SimpleMenu:init(title, message, options)
        self.dialog_data = { title = title, text = message, button_list = {},
                             id = tostring(math.random(0,0xFFFFFFFF)) }
        self.visible = false
        for _,opt in ipairs(options) do
            local elem = {}
            elem.text = opt.text
            opt.data = opt.data or nil
            opt.callback = opt.callback or nil
            elem.callback_func = callback(self, self, "_do_callback",
                                          { data = opt.data,
                                            callback = opt.callback})
            elem.cancel_button = opt.is_cancel_button or false
            if opt.is_focused_button then
                self.dialog_data.focus_button = #self.dialog_data.button_list+1
            end
            table.insert(self.dialog_data.button_list, elem)
        end
        return self
    end

    function SimpleMenu:_do_callback(info)
        if info.callback then
            if info.data then
                info.callback(info.data)
            else
                info.callback()
            end
        end
        self.visible = false
    end

    function SimpleMenu:show()
        if self.visible then
            return
        end
        self.visible = true
        managers.system_menu:show(self.dialog_data)
    end

    function SimpleMenu:hide()
        if self.visible then
            managers.system_menu:close(self.dialog_data.id)
            self.visible = false
            return
        end
    end
end

add_job = add_job or function(data)
    local difficulty_id = tweak_data:difficulty_to_index( data.difficulty )
    table.insert( managers.crimenet._presets, { job_id = data.job_id, difficulty_id = difficulty_id, difficulty = data.difficulty, chance = 1 } )
    managers.crimenet._MAX_ACTIVE_JOBS = managers.crimenet._MAX_ACTIVE_JOBS + 1
end

show_menu = show_menu or function(menu)
    menu:show()
end

mission = mission or function(job_id)
    local difficulty_opts = {
        { text = "Normal", callback = add_job, data = { difficulty = "normal", job_id = job_id } },
        { text = "Hard", callback = add_job, data = { difficulty = "hard", job_id = job_id } },
        { text = "Very Hard", callback = add_job, data = { difficulty = "overkill", job_id = job_id  } },
        { text = "Overkill", callback = add_job, data = { difficulty = "overkill_145", job_id = job_id } },
        { text = "Cancel", is_cancel_button = true},
    }
    local difficulty_menu = SimpleMenu:new("Mission Selector", "Choose Difficulty", difficulty_opts)
    difficulty_menu:show()
end
 

--Menu Contractor
bain = bain or {
{ text = "Jewelry Store", callback = mission, data = "jewelry_store" },
{ text = "Bank Heist: Gold*", callback = mission, data = "branchbank_gold" },
{ text = "Bank Heist: Cash", callback = mission, data = "branchbank_cash" },
{ text = "Bank Heist: Deposit", callback = mission, data = "branchbank_deposit" },
{ text = "Bank Heist*", callback = mission, data="branchbank" },
{ text = "Diamond Store", callback = mission, data="family" },
{ text = "Jewelry Store (Pro Job)*", callback = mission, data = "jewelry_store_prof" },
{ text = "Bank Heist: Gold (Pro Job)", callback = mission, data = "branchbank_gold_prof" },
{ text = "Bank Heist: Cash (Pro Job)*", callback = mission, data = "branchbank_cash_prof" },
{ text = "Bank Heist: Deposit (Pro Job)*", callback = mission, data = "branchbank_deposit_prof" },
{ text = "Bank Heist (Pro Job)", callback = mission, data = "branchbank_prof" },
{ text = "Diamond Store (Pro Job)*", callback = mission, data = "family_prof" },
{ text = "Cancel", is_cancel_button = true },
}
bainmenu = bainmenu or SimpleMenu:new("Mission Selector", "Choose Map", bain)
hector = hector or {
{ text = "Watchdogs", callback = mission, data = "watchdogs" },
{ text = "Fire Starter", callback = mission, data = "firestarter" },
{ text = "Rats", callback = mission, data = "alex" },
{ text = "Watchdogs (Pro Job)", callback = mission, data = "watchdogs_prof" },
{ text = "Fire Starter (Pro Job)", callback = mission, data = "firestarter_prof" },
{ text = "Rats (Pro Job)", callback = mission, data = "alex_prof" },
{ text = "Cancel", is_cancel_button = true},
}
hectormenu = hectormenu or SimpleMenu:new("Mission Selector", "Choose Map", hector)
elephant = elephant or {
{ text = "Framing Frame", callback = mission, data = "framing_frame" },
{ text = "Big Oil*", callback = mission, data = "welcome_to_the_jungle" },
{ text = "Framing Frame (Pro Job)", callback = mission, data = "mallcrasher" },
{ text = "Big Oil (Pro Job)", callback = mission, data = "welcome_to_the_jungle_prof" },
{ text = "Cancel", is_cancel_button = true},
}
elephantmenu = elephantmenu or SimpleMenu:new("Mission Selector", "Choose Map",elephant)
vlad = vlad or {
{ text = "Four Stores", callback = mission, data = "four_stores" },
{ text = "Mallcrasher", callback = mission, data = "mallcrasher" },
{ text = "Nightclub", callback = mission, data = "nightclub" },
{ text = "Ukrainian Job*", callback = mission, data= "ukrainian_job" },
{ text = "Four Stores (Pro Job)*", callback = mission, data = "four_stores_prof" },
{ text = "Mallcrasher (Pro Job)*", callback = mission, data = "mallcrasher_prof" },
{ text = "Nightclub (Pro Job)*", callback = mission, data = "nightclub_prof" },
{ text = "Ukrainian Job (Pro Job)", callback = mission, data= "ukrainian_job_prof" },
{ text = "Cancel", is_cancel_button = true},
}
vladmenu = vladmenu or SimpleMenu:new("Mission Selector", "Choose Map",vlad)

rootopts = rootopts or {
{ text = "Bain", callback = show_menu, data = bainmenu},
{ text = "Hector", callback = show_menu, data = hectormenu},
{ text = "The Elephant", callback = show_menu, data = elephantmenu},
{ text = "Vlad", callback = show_menu, data = vladmenu},
{ text = "Cancel", is_cancel_button = true},
}
if not rootmenu then
    managers.crimenet._NEW_JOB_MIN_TIME = 0
    managers.crimenet._NEW_JOB_MAX_TIME = 0
    managers.crimenet._presets = { }
    managers.crimenet._active_jobs = { }
    managers.crimenet._MAX_ACTIVE_JOBS = 0
    rootmenu = rootmenu or SimpleMenu:new("Mission Selector", "Choose Contractor", rootopts)
end

rootmenu:show()
How can i binded on a key? working? how?
Quote Originally Posted by jdario93 View Post
How can i binded on a key? working? how?
if you have no clue its probably

copy paste the code into script.lua
press INSERT ingame..

read the faq, its has general questions answered..
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us