davedorm

esx_basicneeds/server/main.lua

Sep 22nd, 2021 (edited)
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ESX = nil
  2.  
  3. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  4.  
  5. ESX.RegisterUsableItem('bread', function(source)
  6.     local xPlayer = ESX.GetPlayerFromId(source)
  7.  
  8.     xPlayer.removeInventoryItem('bread', 1)
  9.  
  10.     TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
  11.     TriggerClientEvent('esx_basicneeds:onEat', source)
  12.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_bread')})
  13. end)
  14.  
  15. ESX.RegisterUsableItem('water', function(source)
  16.     local xPlayer = ESX.GetPlayerFromId(source)
  17.  
  18.     xPlayer.removeInventoryItem('water', 1)
  19.  
  20.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  21.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  22.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  23. end)
  24.  
  25. ESX.RegisterUsableItem('donut', function(source)
  26.     local xPlayer = ESX.GetPlayerFromId(source)
  27.  
  28.     xPlayer.removeInventoryItem('donut', 1)
  29.  
  30.     TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
  31.     TriggerClientEvent('esx_basicneeds:onEat', source)
  32.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_bread')})
  33. end)
  34.  
  35. ESX.RegisterUsableItem('redgull', function(source)
  36.     local xPlayer = ESX.GetPlayerFromId(source)
  37.  
  38.     xPlayer.removeInventoryItem('redgull', 1)
  39.  
  40.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  41.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  42.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  43. end)
  44.  
  45. ESX.RegisterUsableItem('sandwich', function(source)
  46.     local xPlayer = ESX.GetPlayerFromId(source)
  47.  
  48.     xPlayer.removeInventoryItem('sandwich', 1)
  49.  
  50.     TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
  51.     TriggerClientEvent('esx_basicneeds:onEat', source)
  52.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_bread')})
  53. end)
  54.  
  55. ESX.RegisterUsableItem('beer', function(source)
  56.     local xPlayer = ESX.GetPlayerFromId(source)
  57.  
  58.     xPlayer.removeInventoryItem('beer', 1)
  59.  
  60.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  61.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  62.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  63. end)
  64.  
  65. ESX.RegisterUsableItem('champagne', function(source)
  66.     local xPlayer = ESX.GetPlayerFromId(source)
  67.  
  68.     xPlayer.removeInventoryItem('champagne', 1)
  69.  
  70.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  71.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  72.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  73. end)
  74.  
  75. ESX.RegisterUsableItem('chips', function(source)
  76.     local xPlayer = ESX.GetPlayerFromId(source)
  77.  
  78.     xPlayer.removeInventoryItem('chips', 1)
  79.  
  80.     TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
  81.     TriggerClientEvent('esx_basicneeds:onEat', source)
  82.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_bread')})
  83. end)
  84.  
  85. ESX.RegisterUsableItem('chocolate', function(source)
  86.     local xPlayer = ESX.GetPlayerFromId(source)
  87.  
  88.     xPlayer.removeInventoryItem('chocolate', 1)
  89.  
  90.     TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
  91.     TriggerClientEvent('esx_basicneeds:onEat', source)
  92.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_bread')})
  93. end)
  94.  
  95. ESX.RegisterUsableItem('cocacola', function(source)
  96.     local xPlayer = ESX.GetPlayerFromId(source)
  97.  
  98.     xPlayer.removeInventoryItem('cocacola', 1)
  99.  
  100.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  101.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  102.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  103. end)
  104.  
  105. ESX.RegisterUsableItem('coffe', function(source)
  106.     local xPlayer = ESX.GetPlayerFromId(source)
  107.  
  108.     xPlayer.removeInventoryItem('coffe', 1)
  109.  
  110.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  111.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  112.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  113. end)
  114.  
  115. ESX.RegisterUsableItem('cupcake', function(source)
  116.     local xPlayer = ESX.GetPlayerFromId(source)
  117.  
  118.     xPlayer.removeInventoryItem('cupcake', 1)
  119.  
  120.     TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
  121.     TriggerClientEvent('esx_basicneeds:onEat', source)
  122.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_bread')})
  123. end)
  124.  
  125. ESX.RegisterUsableItem('gintonic', function(source)
  126.     local xPlayer = ESX.GetPlayerFromId(source)
  127.  
  128.     xPlayer.removeInventoryItem('gintonic', 1)
  129.  
  130.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  131.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  132.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  133. end)
  134.  
  135. ESX.RegisterUsableItem('hamburger', function(source)
  136.     local xPlayer = ESX.GetPlayerFromId(source)
  137.  
  138.     xPlayer.removeInventoryItem('hamburger', 1)
  139.  
  140.     TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
  141.     TriggerClientEvent('esx_basicneeds:onEat', source)
  142.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_bread')})
  143. end)
  144.  
  145. ESX.RegisterUsableItem('icetea', function(source)
  146.     local xPlayer = ESX.GetPlayerFromId(source)
  147.  
  148.     xPlayer.removeInventoryItem('icetea', 1)
  149.  
  150.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  151.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  152.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  153. end)
  154.  
  155. ESX.RegisterUsableItem('milk', function(source)
  156.     local xPlayer = ESX.GetPlayerFromId(source)
  157.  
  158.     xPlayer.removeInventoryItem('milk', 1)
  159.  
  160.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  161.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  162.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  163. end)
  164.  
  165. ESX.RegisterUsableItem('tequila', function(source)
  166.     local xPlayer = ESX.GetPlayerFromId(source)
  167.  
  168.     xPlayer.removeInventoryItem('tequila', 1)
  169.  
  170.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  171.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  172.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  173. end)
  174.  
  175. ESX.RegisterUsableItem('vodka', function(source)
  176.     local xPlayer = ESX.GetPlayerFromId(source)
  177.  
  178.     xPlayer.removeInventoryItem('vodka', 1)
  179.  
  180.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  181.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  182.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  183. end)
  184.  
  185. ESX.RegisterUsableItem('whisky', function(source)
  186.     local xPlayer = ESX.GetPlayerFromId(source)
  187.  
  188.     xPlayer.removeInventoryItem('whisky', 1)
  189.  
  190.     TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
  191.     TriggerClientEvent('esx_status:add', source, 'stress', 1000000) -- DENEMEK İÇİN 10000000 YAPTIM.
  192.     TriggerClientEvent('esx_basicneeds:onDrink', source)
  193.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = _U('used_water')})
  194. end)
  195.  
  196. TriggerEvent('es:addGroupCommand', 'heal', 'admin', function(source, args, user)
  197.     -- heal another player - don't heal source
  198.     if args[1] then
  199.         local playerId = tonumber(args[1])
  200.  
  201.         -- is the argument a number?
  202.         if playerId then
  203.             -- is the number a valid player?
  204.             if GetPlayerName(playerId) then
  205.                 print(('esx_basicneeds: %s healed %s'):format(GetPlayerIdentifier(source, 0), GetPlayerIdentifier(playerId, 0)))
  206.                 TriggerClientEvent('esx_basicneeds:healPlayer', playerId)
  207.                 TriggerClientEvent('chat:addMessage', source, { args = { '^5LIVE', 'Iyilestirildin.' } })
  208.             else
  209.                 TriggerClientEvent('chat:addMessage', source, { args = { '^5LIVE', 'Oyuncu acik deil.' } })
  210.             end
  211.         else
  212.             TriggerClientEvent('chat:addMessage', source, { args = { '^5LIVE', 'Boyle bir id yok.' } })
  213.         end
  214.     else
  215.         print(('esx_basicneeds: %s kendini canlandirdin'):format(GetPlayerIdentifier(source, 0)))
  216.         TriggerClientEvent('esx_basicneeds:healPlayer', source)
  217.     end
  218. end, function(source, args, user)
  219.     TriggerClientEvent('chat:addMessage', source, { args = { '^5LIVE', 'Bunun icin yetkin yok!.' } })
  220. end, {help = 'Açlığı, susuzluğu ve canını doldurur.', params = {{name = 'playerId', help = '(optional) player id'}}})
  221.  
  222. --SIGARA OZEL
  223. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  224.  
  225. ESX.RegisterUsableItem('cigarett', function(source)
  226.     local xPlayer = ESX.GetPlayerFromId(source)
  227.  
  228.     xPlayer.removeInventoryItem('cigarett', 1)
  229.  
  230.     TriggerClientEvent('esx_basicneeds:OnSmokeCigarett', source)
  231.     Citizen.Wait(8000)
  232.     TriggerClientEvent('esx_status:remove', source, 'stress', 1000000) --DENEMEK İÇİN 100000 YAPTIM.
  233.     TriggerClientEvent('mythic_notify:client:SendAlert', source, { type = 'inform', text = 'Sigara kullandığından stresin azalıyor.'})
  234. end)
RAW Paste Data