Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.94 KB | None | 0 0
  1. AddEventHandler('es:playerLoaded', function(source, _player)
  2. local _source = source
  3. local tasks = {}
  4.  
  5. local userData = {
  6. accounts = {},
  7. inventory = {},
  8. job = {},
  9. loadout = {},
  10. playerName = GetPlayerName(_source),
  11. lastPosition = nil,
  12. tracker = nil
  13. }
  14.  
  15. TriggerEvent('es:getPlayerFromId', _source, function(player)
  16.  
  17. -- Update user name in DB
  18. table.insert(tasks, function(cb)
  19. MySQL.Async.execute('UPDATE `users` SET `name` = @name WHERE `identifier` = @identifier',
  20. {
  21. ['@identifier'] = player.getIdentifier(),
  22. ['@name'] = userData.playerName
  23. }, function(rowsChanged)
  24. cb()
  25. end)
  26. end)
  27.  
  28. -- Get accounts
  29. table.insert(tasks, function(cb)
  30. MySQL.Async.fetchAll('SELECT * FROM `user_accounts` WHERE `identifier` = @identifier', {
  31. ['@identifier'] = player.getIdentifier()
  32. }, function(accounts)
  33.  
  34. for i=1, #Config.Accounts, 1 do
  35. for j=1, #accounts, 1 do
  36. if accounts[j].name == Config.Accounts[i] then
  37. table.insert(userData.accounts, {
  38. name = accounts[j].name,
  39. money = accounts[j].money,
  40. label = Config.AccountLabels[accounts[j].name]
  41. })
  42. end
  43. end
  44. end
  45.  
  46. cb()
  47. end)
  48. end)
  49.  
  50. -- Get inventory
  51. table.insert(tasks, function(cb)
  52.  
  53. MySQL.Async.fetchAll('SELECT * FROM `user_inventory` WHERE `identifier` = @identifier', {
  54. ['@identifier'] = player.getIdentifier()
  55. }, function(inventory)
  56.  
  57. local tasks2 = {}
  58.  
  59. for i=1, #inventory, 1 do
  60. table.insert(userData.inventory, {
  61. name = inventory[i].item,
  62. count = inventory[i].count,
  63. label = ESX.Items[inventory[i].item].label,
  64. limit = ESX.Items[inventory[i].item].limit,
  65. usable = ESX.UsableItemsCallbacks[inventory[i].item] ~= nil,
  66. rare = ESX.Items[inventory[i].item].rare,
  67. canRemove = ESX.Items[inventory[i].item].canRemove
  68. })
  69. end
  70.  
  71. for k,v in pairs(ESX.Items) do
  72. local found = false
  73.  
  74. for j=1, #userData.inventory, 1 do
  75. if userData.inventory[j].name == k then
  76. found = true
  77. break
  78. end
  79. end
  80.  
  81. if not found then
  82.  
  83. table.insert(userData.inventory, {
  84. name = k,
  85. count = 0,
  86. label = ESX.Items[k].label,
  87. limit = ESX.Items[k].limit,
  88. usable = ESX.UsableItemsCallbacks[k] ~= nil,
  89. rare = ESX.Items[k].rare,
  90. canRemove = ESX.Items[k].canRemove
  91. })
  92.  
  93. local scope = function(item, identifier)
  94.  
  95. table.insert(tasks2, function(cb2)
  96. MySQL.Async.execute('INSERT INTO user_inventory (identifier, item, count) VALUES (@identifier, @item, @count)',
  97. {
  98. ['@identifier'] = identifier,
  99. ['@item'] = item,
  100. ['@count'] = 0
  101. }, function(rowsChanged)
  102. cb2()
  103. end)
  104. end)
  105.  
  106. end
  107.  
  108. scope(k, player.getIdentifier())
  109.  
  110. end
  111.  
  112. end
  113.  
  114. Async.parallelLimit(tasks2, 5, function(results) end)
  115.  
  116. table.sort(userData.inventory, function(a,b)
  117. return a.label < b.label
  118. end)
  119.  
  120. cb()
  121. end)
  122.  
  123. end)
  124.  
  125. -- Get job and loadout
  126. table.insert(tasks, function(cb)
  127.  
  128. local tasks2 = {}
  129.  
  130. -- Get job name, grade and last position
  131. table.insert(tasks2, function(cb2)
  132.  
  133. MySQL.Async.fetchAll('SELECT * FROM `users` WHERE `identifier` = @identifier', {
  134. ['@identifier'] = player.getIdentifier()
  135. }, function(result)
  136. userData.job['name'] = result[1].job
  137. userData.job['grade'] = result[1].job_grade
  138. userData.tracker = result[1].tracker
  139. userData.donatorTier = result[1].donator
  140.  
  141. if userData.tracker == 0 then
  142. userData.tracker = false
  143. elseif userData.tracker == 1 then
  144. userData.tracker = true
  145. end
  146.  
  147. if result[1].loadout ~= nil then
  148. userData.loadout = json.decode(result[1].loadout)
  149. end
  150.  
  151. if result[1].position ~= nil then
  152. userData.lastPosition = json.decode(result[1].position)
  153. end
  154.  
  155. cb2()
  156. end)
  157.  
  158. end)
  159.  
  160. -- Get job label
  161. table.insert(tasks2, function(cb2)
  162. MySQL.Async.fetchAll('SELECT * FROM `jobs` WHERE `name` = @name', {
  163. ['@name'] = userData.job.name
  164. }, function(result)
  165. userData.job['label'] = result[1].label
  166. cb2()
  167. end)
  168. end)
  169.  
  170. -- Get job grade data
  171. table.insert(tasks2, function(cb2)
  172.  
  173. MySQL.Async.fetchAll('SELECT * FROM `job_grades` WHERE `job_name` = @job_name AND `grade` = @grade',
  174. {
  175. ['@job_name'] = userData.job.name,
  176. ['@grade'] = userData.job.grade
  177. }, function(result)
  178.  
  179. userData.job['grade_name'] = result[1].name
  180. userData.job['grade_label'] = result[1].label
  181. userData.job['grade_salary'] = result[1].salary
  182.  
  183. userData.job['skin_male'] = {}
  184. userData.job['skin_female'] = {}
  185.  
  186. if result[1].skin_male ~= nil then
  187. userData.job['skin_male'] = json.decode(result[1].skin_male)
  188. end
  189.  
  190. if result[1].skin_female ~= nil then
  191. userData.job['skin_female'] = json.decode(result[1].skin_female)
  192. end
  193.  
  194. cb2()
  195. end)
  196.  
  197. end)
  198.  
  199. Async.series(tasks2, cb)
  200.  
  201. end)
  202.  
  203. -- Run Tasks
  204. Async.parallel(tasks, function(results)
  205.  
  206. local xPlayer = CreateExtendedPlayer(player, userData.accounts, userData.inventory, userData.job, userData.loadout, userData.playerName, userData.lastPosition, userData.tracker, userData.donatorTier)
  207.  
  208. xPlayer.getMissingAccounts(function(missingAccounts)
  209.  
  210. if #missingAccounts > 0 then
  211.  
  212. for i=1, #missingAccounts, 1 do
  213. table.insert(xPlayer.accounts, {
  214. name = missingAccounts[i],
  215. money = 0,
  216. label = Config.AccountLabels[missingAccounts[i]]
  217. })
  218. end
  219.  
  220. xPlayer.createAccounts(missingAccounts)
  221. end
  222.  
  223. ESX.Players[_source] = xPlayer
  224.  
  225. TriggerEvent('esx:playerLoaded', _source)
  226.  
  227. TriggerClientEvent('esx:playerLoaded', _source, {
  228. identifier = xPlayer.identifier,
  229. accounts = xPlayer.getAccounts(),
  230. inventory = xPlayer.getInventory(),
  231. job = xPlayer.getJob(),
  232. loadout = xPlayer.getLoadout(),
  233. lastPosition = xPlayer.getLastPosition(),
  234. money = xPlayer.get('money')
  235. })
  236.  
  237. xPlayer.player.displayMoney(xPlayer.get('money'))
  238.  
  239. end)
  240.  
  241. end)
  242.  
  243. end)
  244.  
  245. end)
  246.  
  247. function dump(o)
  248. if type(o) == 'table' then
  249. local s = '{ '
  250. for k,v in pairs(o) do
  251. if type(k) ~= 'number' then k = '"'..k..'"' end
  252. s = s .. '['..k..'] = ' .. dump(v) .. ','
  253. end
  254. return s .. '} '
  255. else
  256. return tostring(o)
  257. end
  258. end
  259.  
  260. RegisterServerEvent('esx:debug')
  261. AddEventHandler('esx:debug', function(value)
  262. print(dump(value))
  263. end)
  264.  
  265. AddEventHandler('playerDropped', function(reason)
  266. local _source = source
  267. local xPlayer = ESX.GetPlayerFromId(_source)
  268.  
  269. if xPlayer ~= nil then
  270. TriggerEvent('esx:playerDropped', _source, reason)
  271.  
  272. ESX.SavePlayer(xPlayer, function()
  273. ESX.Players[_source] = nil
  274. ESX.LastPlayerData[_source] = nil
  275. end)
  276. end
  277. end)
  278.  
  279. RegisterServerEvent('esx:updateLoadout')
  280. AddEventHandler('esx:updateLoadout', function(loadout)
  281. local xPlayer = ESX.GetPlayerFromId(source)
  282. xPlayer.loadout = loadout
  283. end)
  284.  
  285. RegisterServerEvent('esx:updateLastPosition')
  286. AddEventHandler('esx:updateLastPosition', function(position)
  287. local xPlayer = ESX.GetPlayerFromId(source)
  288. xPlayer.lastPosition = position
  289. end)
  290.  
  291. RegisterServerEvent('esx:giveInventoryItem')
  292. AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCount)
  293. local _source = source
  294.  
  295. local sourceXPlayer = ESX.GetPlayerFromId(_source)
  296. local targetXPlayer = ESX.GetPlayerFromId(target)
  297.  
  298. if type == 'item_standard' then
  299.  
  300. local sourceItem = sourceXPlayer.getInventoryItem(itemName)
  301. local targetItem = targetXPlayer.getInventoryItem(itemName)
  302.  
  303. if itemCount > 0 and sourceItem.count >= itemCount then
  304.  
  305. if targetItem.limit ~= -1 and (targetItem.count + itemCount) > targetItem.limit then
  306. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('ex_inv_lim', targetXPlayer.name) })
  307. -- TriggerClientEvent('esx:showNotification', _source, _U('ex_inv_lim', targetXPlayer.name))
  308. else
  309. sourceXPlayer.removeInventoryItem(itemName, itemCount)
  310. targetXPlayer.addInventoryItem (itemName, itemCount)
  311. TriggerEvent("esx:giveitemalert",sourceXPlayer.name,targetXPlayer.name,ESX.Items[itemName].label,itemCount)
  312. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('gave_item', itemCount, ESX.Items[itemName].label, targetXPlayer.name) })
  313. -- TriggerClientEvent('esx:showNotification', _source, _U('gave_item', itemCount, ESX.Items[itemName].label, targetXPlayer.name))
  314. TriggerClientEvent('mythic_notify:client:SendAlert', target, { type = 'inform', text = _U('received_item', itemCount, ESX.Items[itemName].label, sourceXPlayer.name) })
  315. -- TriggerClientEvent('esx:showNotification', target, _U('received_item', itemCount, ESX.Items[itemName].label, sourceXPlayer.name))
  316. end
  317.  
  318. else
  319. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_quantity') })
  320. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_quantity'))
  321. end
  322.  
  323. elseif type == 'item_money' then
  324.  
  325. if itemCount > 0 and sourceXPlayer.player.get('money') >= itemCount then
  326.  
  327. sourceXPlayer.removeMoney(itemCount)
  328. targetXPlayer.addMoney (itemCount)
  329.  
  330. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('gave_money', itemCount, targetXPlayer.name) })
  331. -- TriggerClientEvent('esx:showNotification', _source, _U('gave_money', itemCount, targetXPlayer.name))
  332. TriggerClientEvent('mythic_notify:client:SendAlert', target, { type = 'inform', text = _U('received_money', itemCount, sourceXPlayer.name) })
  333. -- TriggerClientEvent('esx:showNotification', target, _U('received_money', itemCount, sourceXPlayer.name))
  334. TriggerEvent("esx:givemoneyalert",sourceXPlayer.name,targetXPlayer.name,itemCount)
  335. TriggerEvent("log:getmoney", targetXPlayer.identifier, itemCount, "cash", sourceXPlayer.identifier)
  336. TriggerEvent("log:usemoney", sourceXPlayer.identifier, itemCount, "cash", targetXPlayer.identifier)
  337. else
  338. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_amount') })
  339. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
  340. end
  341.  
  342. elseif type == 'item_account' then
  343.  
  344. if itemCount > 0 and sourceXPlayer.getAccount(itemName).money >= itemCount then
  345.  
  346. sourceXPlayer.removeAccountMoney(itemName, itemCount)
  347. targetXPlayer.addAccountMoney (itemName, itemCount)
  348.  
  349. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('gave_account_money', itemCount, Config.AccountLabels[itemName], targetXPlayer.name) })
  350. -- TriggerClientEvent('esx:showNotification', _source, _U('gave_account_money', itemCount, Config.AccountLabels[itemName], targetXPlayer.name))
  351. TriggerClientEvent('mythic_notify:client:SendAlert', target, { type = 'inform', text = _U('received_account_money', itemCount, Config.AccountLabels[itemName], sourceXPlayer.name) })
  352. -- TriggerClientEvent('esx:showNotification', target, _U('received_account_money', itemCount, Config.AccountLabels[itemName], sourceXPlayer.name))
  353. TriggerEvent("esx:givemoneyalert",sourceXPlayer.name,targetXPlayer.name,itemCount)
  354. TriggerEvent("log:getmoney", targetXPlayer.identifier, itemCount, itemName, sourceXPlayer.identifier)
  355. TriggerEvent("log:usemoney", sourceXPlayer.identifier, itemCount, itemName, targetXPlayer.identifier)
  356. else
  357. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_amount') })
  358. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
  359. end
  360.  
  361. elseif type == 'item_weapon' then
  362.  
  363. sourceXPlayer.removeWeapon(itemName)
  364. targetXPlayer.addWeapon(itemName, itemCount)
  365.  
  366. local weaponLabel = ESX.GetWeaponLabel(itemName)
  367. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('gave_weapon', weaponLabel, itemCount, targetXPlayer.name) })
  368. TriggerClientEvent('mythic_notify:client:SendAlert', target, { type = 'inform', text = _U('received_weapon', weaponLabel, itemCount, sourceXPlayer.name) })
  369. -- TriggerClientEvent('esx:showNotification', _source, _U('gave_weapon', weaponLabel, itemCount, targetXPlayer.name))
  370. -- TriggerClientEvent('esx:showNotification', target, _U('received_weapon', weaponLabel, itemCount, sourceXPlayer.name))
  371. TriggerEvent("esx:giveweaponalert",sourceXPlayer.name,targetXPlayer.name,weaponLabel)
  372. end
  373.  
  374. end)
  375.  
  376. RegisterServerEvent('esx:removeInventoryItem')
  377. AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
  378. local _source = source
  379.  
  380. if type == 'item_standard' then
  381.  
  382. if itemCount == nil or itemCount <= 0 then
  383. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_quantity') })
  384. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_quantity'))
  385. else
  386.  
  387. local xPlayer = ESX.GetPlayerFromId(source)
  388. local foundItem = nil
  389.  
  390. for i=1, #xPlayer.inventory, 1 do
  391. if xPlayer.inventory[i].name == itemName then
  392. foundItem = xPlayer.inventory[i]
  393. end
  394. end
  395.  
  396. if itemCount > foundItem.count then
  397. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_quantity') })
  398. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_quantity'))
  399. else
  400. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('delete_five_min') })
  401. -- TriggerClientEvent('esx:showNotification', _source, _U('delete_five_min'))
  402.  
  403. SetTimeout(Config.RemoveInventoryItemDelay, function()
  404. local remainingCount = xPlayer.getInventoryItem(itemName).count
  405. local total = itemCount
  406.  
  407. if remainingCount < itemCount then
  408. total = remainingCount
  409. end
  410.  
  411. if total > 0 then
  412. xPlayer.removeInventoryItem(itemName, total)
  413. ESX.CreatePickup('item_standard', itemName, total, foundItem.label .. ' [' .. itemCount .. ']', _source)
  414. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('threw') .. ' ' .. foundItem.label .. ' x' .. total })
  415. -- TriggerClientEvent('esx:showNotification', _source, _U('threw') .. ' ' .. foundItem.label .. ' x' .. total)
  416. TriggerClientEvent('esx:playdropAnim', _source)
  417. end
  418. end)
  419. end
  420.  
  421. end
  422.  
  423. elseif type == 'item_money' then
  424.  
  425. if itemCount == nil or itemCount <= 0 then
  426. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_amount') })
  427. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
  428. else
  429.  
  430. local xPlayer = ESX.GetPlayerFromId(source)
  431.  
  432. if itemCount > xPlayer.player.get('money') then
  433. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_amount') })
  434. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
  435. else
  436.  
  437. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('delete_five_min') })
  438. -- TriggerClientEvent('esx:showNotification', _source, _U('delete_five_min'))
  439.  
  440. SetTimeout(Config.RemoveInventoryItemDelay, function()
  441. local remainingCount = xPlayer.player.get('money')
  442. local total = itemCount
  443.  
  444. if remainingCount < itemCount then
  445. total = remainingCount
  446. end
  447.  
  448. if total > 0 then
  449. xPlayer.removeMoney(total)
  450. ESX.CreatePickup('item_money', 'money', total, 'Cash' .. ' [' .. itemCount .. ']', _source)
  451. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('threw') .. ' [Cash] £' .. total })
  452. -- TriggerClientEvent('esx:showNotification', _source, _U('threw') .. ' [Cash] £' .. total)
  453. TriggerClientEvent('esx:playdropAnim', _source)
  454. TriggerEvent("log:usemoney", xPlayer.identifier, total, "cash", "Threw Money")
  455. end
  456. end)
  457. end
  458.  
  459. end
  460.  
  461. elseif type == 'item_account' then
  462.  
  463. if itemCount == nil or itemCount <= 0 then
  464. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_amount') })
  465. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
  466. else
  467.  
  468. local xPlayer = ESX.GetPlayerFromId(source)
  469.  
  470. if itemCount > xPlayer.getAccount(itemName).money then
  471. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('imp_invalid_amount') })
  472. -- TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
  473. else
  474.  
  475. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('delete_five_min') })
  476. -- TriggerClientEvent('esx:showNotification', _source, _U('delete_five_min'))
  477.  
  478. SetTimeout(Config.RemoveInventoryItemDelay, function()
  479. local remainingCount = xPlayer.getAccount(itemName).money
  480. local total = itemCount
  481.  
  482. if remainingCount < itemCount then
  483. total = remainingCount
  484. end
  485.  
  486. if total > 0 then
  487. xPlayer.removeAccountMoney(itemName, total)
  488. ESX.CreatePickup('item_account', itemName, total, Config.AccountLabels[itemName] .. ' [' .. itemCount .. ']', _source)
  489. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('threw') .. ' [Cash] £' .. total })
  490. -- TriggerClientEvent('esx:showNotification', _source, _U('threw') .. ' [Cash] £' .. total)
  491. TriggerClientEvent('esx:playdropAnim', _source)
  492. TriggerEvent("log:usemoney", xPlayer.identifier, total, itemName, "Threw Money")
  493. end
  494. end)
  495. end
  496.  
  497. end
  498.  
  499. elseif type == 'item_weapon' then
  500.  
  501. local xPlayer = ESX.GetPlayerFromId(source)
  502. local weaponName = itemName
  503. local weaponLabel = ESX.GetWeaponLabel(weaponName)
  504. local weaponPickup = 'PICKUP_' .. weaponName
  505.  
  506. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('delete_five_min') })
  507.  
  508. SetTimeout(Config.RemoveInventoryItemDelay, function()
  509. xPlayer.removeWeapon(itemName)
  510. if Config.EnableWeaponPickup then
  511. TriggerClientEvent('esx:pickupWeapon', _source, weaponPickup, weaponName, itemCount)
  512. end
  513. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('threw_weapon', weaponLabel, itemCount) })
  514. -- TriggerClientEvent('esx:showNotification', _source, _U('threw_weapon', weaponLabel, itemCount))
  515. end)
  516. end
  517.  
  518. end)
  519.  
  520. RegisterServerEvent('esx:useItem')
  521. AddEventHandler('esx:useItem', function(itemName)
  522. local xPlayer = ESX.GetPlayerFromId(source)
  523. local count = xPlayer.getInventoryItem(itemName).count
  524.  
  525. if count > 0 then
  526. ESX.UseItem(source, itemName)
  527. else
  528. TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('act_imp') })
  529. -- TriggerClientEvent('esx:showNotification', xPlayer.source, _U('act_imp'))
  530. end
  531. end)
  532.  
  533. RegisterServerEvent('esx:onPickup')
  534. AddEventHandler('esx:onPickup', function(id)
  535. local _source = source
  536. local pickup = ESX.Pickups[id]
  537. local xPlayer = ESX.GetPlayerFromId(_source)
  538.  
  539. if pickup.type == 'item_standard' then
  540.  
  541. local item = xPlayer.getInventoryItem(pickup.name)
  542. local canTake = ((item.limit == -1) and (pickup.count)) or ((item.limit - item.count > 0) and (item.limit - item.count)) or 0
  543. local total = pickup.count < canTake and pickup.count or canTake
  544. local remaining = pickup.count - total
  545.  
  546. TriggerClientEvent('esx:removePickup', -1, id)
  547.  
  548. if total > 0 then
  549. xPlayer.addInventoryItem(pickup.name, total)
  550. end
  551.  
  552. if remaining > 0 then
  553. TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', _U('cannot_pickup_room', item.label) })
  554. -- TriggerClientEvent('esx:showNotification', _source, _U('cannot_pickup_room', item.label))
  555. ESX.CreatePickup('item_standard', pickup.name, remaining, item.label .. ' [' .. remaining .. ']', _source)
  556. end
  557.  
  558. elseif pickup.type == 'item_money' then
  559. TriggerClientEvent('esx:removePickup', -1, id)
  560. xPlayer.addMoney(pickup.count)
  561. TriggerEvent("log:getmoney", xPlayer.identifier, pickup.count, "cash", "Pickup")
  562. elseif pickup.type == 'item_account' then
  563. TriggerClientEvent('esx:removePickup', -1, id)
  564. xPlayer.addAccountMoney(pickup.name, pickup.count)
  565. TriggerEvent("log:getmoney", xPlayer.identifier, pickup.count, pickup.name, "Pickup")
  566. end
  567. end)
  568.  
  569. ESX.RegisterServerCallback('esx:getPlayerData', function(source, cb)
  570. local xPlayer = ESX.GetPlayerFromId(source)
  571.  
  572. cb({
  573. identifier = xPlayer.identifier,
  574. accounts = xPlayer.getAccounts(),
  575. inventory = xPlayer.getInventory(),
  576. job = xPlayer.getJob(),
  577. loadout = xPlayer.getLoadout(),
  578. lastPosition = xPlayer.getLastPosition(),
  579. money = xPlayer.get('money')
  580. })
  581. end)
  582.  
  583. ESX.RegisterServerCallback('esx:getOtherPlayerData', function(source, cb, target)
  584. local xPlayer = ESX.GetPlayerFromId(target)
  585.  
  586. cb({
  587. identifier = xPlayer.identifier,
  588. accounts = xPlayer.getAccounts(),
  589. inventory = xPlayer.getInventory(),
  590. job = xPlayer.getJob(),
  591. loadout = xPlayer.getLoadout(),
  592. lastPosition = xPlayer.getLastPosition(),
  593. money = xPlayer.get('money')
  594. })
  595. end)
  596.  
  597. ESX.RegisterServerCallback('esx:getTrackerState', function(source, cb)
  598. local _source = source
  599. MySQL.Async.fetchAll('SELECT * FROM `users` WHERE `identifier` = @identifier', {
  600. ['@identifier'] = GetPlayerIdentifier(_source, 0)
  601. }, function(result)
  602. tracker = result[1].tracker
  603.  
  604. if tracker == 0 then
  605. tracker = false
  606. elseif tracker == 1 then
  607. tracker = true
  608. end
  609. cb(tracker)
  610. end)
  611. end)
  612.  
  613. TriggerEvent("es:addGroup", "jobmaster", "user", function(group) end)
  614.  
  615. ESX.StartDBSync()
  616. ESX.StartPayCheck()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement