Initial commit
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
// Конфиг сделан под ШколуРП. Но можете запроста изменить под DarkRP
|
||||
|
||||
MoonContextMenu.config_cmds = {
|
||||
{
|
||||
items = {
|
||||
{
|
||||
name = 'Админка',
|
||||
func = function()
|
||||
RunConsoleCommand('sam', 'menu')
|
||||
end,
|
||||
icon = 'wrench'
|
||||
},
|
||||
{
|
||||
name = 'Логи',
|
||||
func = function()
|
||||
RunConsoleCommand('say', '!plogs')
|
||||
end,
|
||||
icon = 'logs'
|
||||
}
|
||||
},
|
||||
check = function()
|
||||
return LocalPlayer():getJobTable().command == 'job_admin'
|
||||
end
|
||||
},
|
||||
{
|
||||
items = {
|
||||
{
|
||||
name = 'Выкинуть оружие',
|
||||
func = function()
|
||||
RunConsoleCommand('darkrp', 'dropweapon')
|
||||
end,
|
||||
icon = 'gun'
|
||||
},
|
||||
{
|
||||
name = 'Купить патроны',
|
||||
func = function()
|
||||
if not LocalPlayer():GetActiveWeapon().Primary then return end
|
||||
RunConsoleCommand("darkrp", "buyammo", string.lower(LocalPlayer():GetActiveWeapon().Primary.Ammo))
|
||||
end,
|
||||
icon = 'gun'
|
||||
},
|
||||
{
|
||||
name = 'Выбросить деньги',
|
||||
func = function()
|
||||
Mantle.ui.text_box('Выбросить деньги', 'Сколько желаете?', function(s)
|
||||
RunConsoleCommand('darkrp', 'dropmoney', s)
|
||||
end)
|
||||
end,
|
||||
icon = 'drop_money'
|
||||
},
|
||||
{
|
||||
name = 'Передать игроку деньги',
|
||||
func = function()
|
||||
Mantle.ui.text_box('Передать деньги', 'Сколько желаете?', function(s)
|
||||
RunConsoleCommand('darkrp', 'give', s)
|
||||
end)
|
||||
end,
|
||||
icon = 'give_money'
|
||||
},
|
||||
{
|
||||
name = 'Сменить ник',
|
||||
func = function()
|
||||
Mantle.ui.text_box('Сменить ник', 'Какой хотите поставить?', function(s)
|
||||
RunConsoleCommand('darkrp', 'rpname', s)
|
||||
end)
|
||||
end,
|
||||
icon = 'nick'
|
||||
},
|
||||
{
|
||||
name = 'Продать все двери',
|
||||
func = function()
|
||||
RunConsoleCommand('darkrp', 'unownalldoors')
|
||||
end,
|
||||
icon = 'doors'
|
||||
},
|
||||
{
|
||||
name = 'Написать объявление',
|
||||
func = function()
|
||||
Mantle.ui.text_box('Написать объявление', 'Что планируете рекламировать?', function(s)
|
||||
RunConsoleCommand('say', '/advert ' .. s)
|
||||
end)
|
||||
end,
|
||||
icon = 'advert'
|
||||
},
|
||||
{
|
||||
name = 'Кинуть ролл',
|
||||
func = function()
|
||||
RunConsoleCommand('say', '/roll')
|
||||
end,
|
||||
icon = 'roll'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
items = {
|
||||
{
|
||||
name = 'Назначить розыск',
|
||||
func = function()
|
||||
Mantle.ui.player_selector(function(pl)
|
||||
Mantle.ui.text_box('Назначить розыск', 'Какова причина?', function(s)
|
||||
RunConsoleCommand('darkrp', 'wanted', pl:Name(), s)
|
||||
end)
|
||||
end)
|
||||
end,
|
||||
icon = 'wanted'
|
||||
},
|
||||
{
|
||||
name = 'Снять розыск',
|
||||
func = function()
|
||||
Mantle.ui.player_selector(function(pl)
|
||||
RunConsoleCommand('darkrp', 'unwanted', pl:Name())
|
||||
end)
|
||||
end,
|
||||
icon = 'unwanted'
|
||||
},
|
||||
{
|
||||
name = 'Получить ордер',
|
||||
func = function()
|
||||
Mantle.ui.player_selector(function(pl)
|
||||
Mantle.ui.text_box('Получить ордер', 'Какова причина?', function(s)
|
||||
RunConsoleCommand('darkrp', 'warrant', pl:Name(), s)
|
||||
end)
|
||||
end)
|
||||
end,
|
||||
icon = 'warrant'
|
||||
},
|
||||
},
|
||||
check = function()
|
||||
return LocalPlayer():getJobTable().adult
|
||||
end
|
||||
},
|
||||
{
|
||||
items = {
|
||||
-- {
|
||||
-- name = 'Настройки 3 лица',
|
||||
-- func = function()
|
||||
-- RunConsoleCommand('say','!third')
|
||||
-- end,
|
||||
-- icon = 'thirdperson_toggle'
|
||||
-- },
|
||||
{
|
||||
name = 'Остановить все звуки',
|
||||
func = function()
|
||||
RunConsoleCommand('stopsound')
|
||||
end,
|
||||
icon = 'sounds'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
--[[
|
||||
* MoonContextmenu *
|
||||
GitHub: https://github.com/darkfated/mooncontextmenu
|
||||
Author's discord: darkfated
|
||||
]]
|
||||
|
||||
local function run_scripts()
|
||||
Mantle.run_cl('config.lua')
|
||||
Mantle.run_cl('menu.lua')
|
||||
end
|
||||
|
||||
local function init()
|
||||
if SERVER then
|
||||
local folderPath = 'materials/mooncontextmenu'
|
||||
local files = file.Find(folderPath .. '/*.png', 'GAME')
|
||||
|
||||
for _, fileName in ipairs(files) do
|
||||
local filePath = folderPath .. '/' .. fileName
|
||||
|
||||
resource.AddFile(filePath)
|
||||
end
|
||||
end
|
||||
|
||||
MoonContextMenu = MoonContextMenu or {}
|
||||
|
||||
run_scripts()
|
||||
end
|
||||
|
||||
init()
|
||||
@@ -0,0 +1,85 @@
|
||||
local scrw, scrh = ScrW(), ScrH()
|
||||
|
||||
local function Create()
|
||||
MoonContextMenu.menu = vgui.Create('DFrame')
|
||||
Mantle.ui.frame(MoonContextMenu.menu, '', 300, 500, false)
|
||||
|
||||
if MoonContextMenu.pos_save then
|
||||
MoonContextMenu.menu:SetPos(MoonContextMenu.pos_save[1], MoonContextMenu.pos_save[2])
|
||||
else
|
||||
MoonContextMenu.menu:SetPos(10, 0)
|
||||
MoonContextMenu.menu:CenterVertical()
|
||||
end
|
||||
|
||||
MoonContextMenu.menu:MakePopup()
|
||||
MoonContextMenu.menu.center_title = 'Список команд'
|
||||
|
||||
MoonContextMenu.menu.sp = vgui.Create('DScrollPanel', MoonContextMenu.menu)
|
||||
Mantle.ui.sp(MoonContextMenu.menu.sp)
|
||||
MoonContextMenu.menu.sp:Dock(FILL)
|
||||
|
||||
for _, cat in ipairs(MoonContextMenu.config_cmds) do
|
||||
if cat.check and !cat.check() then
|
||||
continue
|
||||
end
|
||||
|
||||
for _, cmd in ipairs(cat.items) do
|
||||
local btn_cmd = vgui.Create('DButton', MoonContextMenu.menu.sp)
|
||||
Mantle.ui.btn(btn_cmd)
|
||||
btn_cmd:Dock(TOP)
|
||||
btn_cmd:DockMargin(0, 0, 0, 4)
|
||||
btn_cmd:SetTall(24)
|
||||
btn_cmd:SetText(cmd.name)
|
||||
btn_cmd.DoClick = function()
|
||||
Mantle.func.sound()
|
||||
|
||||
cmd.func()
|
||||
end
|
||||
btn_cmd.DoRightClick = function()
|
||||
local DM = Mantle.ui.derma_menu()
|
||||
DM:AddOption('Сбросить позицию', function()
|
||||
MoonContextMenu.pos_save = nil
|
||||
MoonContextMenu.menu:Remove()
|
||||
end, 'icon16/arrow_out.png')
|
||||
end
|
||||
|
||||
if cmd.icon then
|
||||
btn_cmd.mat = Material('materials/mooncontextmenu/' .. cmd.icon .. '.png')
|
||||
|
||||
btn_cmd.PaintOver = function(self, w, h)
|
||||
surface.SetDrawColor(color_white)
|
||||
surface.SetMaterial(self.mat)
|
||||
surface.DrawTexturedRect(4, 4, 16, 16)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local panel_split = vgui.Create('DPanel', MoonContextMenu.menu.sp)
|
||||
panel_split:Dock(TOP)
|
||||
panel_split:DockMargin(0, 0, 0, 4)
|
||||
panel_split:SetTall(8)
|
||||
panel_split.Paint = function(_, w, h)
|
||||
draw.RoundedBox(4, 0, 0, w, h, Mantle.color.panel_alpha[2])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function Close()
|
||||
if !IsValid(MoonContextMenu.menu) then
|
||||
return
|
||||
end
|
||||
|
||||
MoonContextMenu.pos_save = {}
|
||||
MoonContextMenu.pos_save[1], MoonContextMenu.pos_save[2] = MoonContextMenu.menu:GetPos()
|
||||
MoonContextMenu.menu:Remove()
|
||||
end
|
||||
|
||||
hook.Add('OnContextMenuOpen', 'Mantle.MoonContextMenu', function()
|
||||
if !IsValid(MoonContextMenu.menu) then
|
||||
Create()
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add('OnContextMenuClose', 'Mantle.MoonContextMenu', function()
|
||||
Close()
|
||||
end)
|
||||
Reference in New Issue
Block a user