Advertisement
Guest User

Untitled

a guest
May 26th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. function OpenBossMenu(society, close, options)
  2. local isBoss = nil
  3. local options = options or {}
  4. local elements = {}
  5.  
  6. ESX.TriggerServerCallback('esx_society:isBoss', function(result)
  7. isBoss = result
  8. end, society)
  9.  
  10. while isBoss == nil do
  11. Citizen.Wait(100)
  12. end
  13.  
  14. if not isBoss then
  15. return
  16. end
  17.  
  18. local defaultOptions = {
  19. withdraw = true,
  20. deposit = true,
  21. wash = true,
  22. employees = true,
  23. grades = true
  24. }
  25.  
  26. for k,v in pairs(defaultOptions) do
  27. if options[k] == nil then
  28. options[k] = v
  29. end
  30. end
  31.  
  32. if options.withdraw then
  33. table.insert(elements, {label = _U('withdraw_society_money'), value = 'withdraw_society_money'})
  34. end
  35.  
  36. if options.deposit then
  37. table.insert(elements, {label = _U('deposit_society_money'), value = 'deposit_money'})
  38. end
  39.  
  40. if options.wash then
  41. table.insert(elements, {label = _U('wash_money'), value = 'wash_money'})
  42. end
  43.  
  44. if options.employees then
  45. table.insert(elements, {label = _U('employee_management'), value = 'manage_employees'})
  46. end
  47.  
  48. if options.grades then
  49. table.insert(elements, {label = _U('salary_management'), value = 'manage_grades'})
  50. end
  51.  
  52. ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'boss_actions_' .. society, {
  53. title = _U('boss_menu'),
  54. align = 'top-left',
  55. elements = elements
  56. }, function(data, menu)
  57.  
  58. if data.current.value == 'withdraw_society_money' then
  59.  
  60. ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'withdraw_society_money_amount_' .. society, {
  61. title = _U('withdraw_amount')
  62. }, function(data, menu)
  63.  
  64. local amount = tonumber(data.value)
  65.  
  66. if amount == nil then
  67. ESX.ShowNotification(_U('invalid_amount'))
  68. else
  69. menu.close()
  70. TriggerServerEvent('esx_society:withdrawMoney', society, amount)
  71. end
  72.  
  73. end, function(data, menu)
  74. menu.close()
  75. end)
  76.  
  77. elseif data.current.value == 'deposit_money' then
  78.  
  79. ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'deposit_money_amount_' .. society, {
  80. title = _U('deposit_amount')
  81. }, function(data, menu)
  82.  
  83. local amount = tonumber(data.value)
  84.  
  85. if amount == nil then
  86. ESX.ShowNotification(_U('invalid_amount'))
  87. else
  88. menu.close()
  89. TriggerServerEvent('esx_society:depositMoney', society, amount)
  90. end
  91.  
  92. end, function(data, menu)
  93. menu.close()
  94. end)
  95.  
  96. elseif data.current.value == 'wash_money' then
  97.  
  98. ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'wash_money_amount_' .. society, {
  99. title = _U('wash_money_amount')
  100. }, function(data, menu)
  101.  
  102. local amount = tonumber(data.value)
  103.  
  104. if amount == nil then
  105. ESX.ShowNotification(_U('invalid_amount'))
  106. else
  107. menu.close()
  108. TriggerServerEvent('esx_society:washMoney', society, amount)
  109. end
  110.  
  111. end, function(data, menu)
  112. menu.close()
  113. end)
  114.  
  115. elseif data.current.value == 'manage_employees' then
  116. OpenManageEmployeesMenu(society)
  117. elseif data.current.value == 'manage_grades' then
  118. OpenManageGradesMenu(society)
  119. end
  120.  
  121. end, function(data, menu)
  122. if close then
  123. close(data, menu)
  124. end
  125. end)
  126.  
  127. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement