SHARE
TWEET

Untitled

a guest Jun 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --------------------CLIENT-----------------------
  2.  
  3.  
  4. ESX               = nil
  5.  
  6.  
  7.  
  8. Citizen.CreateThread(function()
  9.     while ESX == nil do
  10.         TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  11.         Citizen.Wait(0)
  12.     end
  13. end)
  14. RegisterCommand("test", function()
  15.  
  16.  local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer(gracz)
  17.             if closestPlayer == -1 or closestDistance > 3.0 then
  18.                 ESX.ShowNotification("Brak graczy")
  19.             else
  20.                 TriggerServerEvent('bron_wydaj', gracz)
  21.                
  22.             end
  23. end)
  24.  
  25.  function GetClosestPlayer()
  26.     local players = GetPlayers()
  27.     local closestDistance = -1
  28.     local closestPlayer = -1
  29.     local ply = GetPlayerPed(-1)
  30.     local plyCoords = GetEntityCoords(ply, 0)
  31.  
  32.     for index,value in ipairs(players) do
  33.         local target = GetPlayerPed(value)
  34.         if(target ~= ply) then
  35.             local targetCoords = GetEntityCoords(GetPlayerPed(value), 0)
  36.             local distance = GetDistanceBetweenCoords(targetCoords['x'], targetCoords['y'], targetCoords['z'], plyCoords['x'], plyCoords['y'], plyCoords['z'], true)
  37.             if(closestDistance == -1 or closestDistance > distance) then
  38.                 closestPlayer = value
  39.                 closestDistance = distance
  40.             end
  41.         end
  42.     end
  43.     return closestPlayer, closestDistance
  44. end
  45.  
  46.  
  47. -----------------SERVER----------------------
  48. ESX = nil
  49.  
  50. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  51.  
  52. function LoadLicenses (source)
  53.   TriggerEvent('esx_license:getLicenses', source, function (licenses)
  54.     TriggerClientEvent('esx_weashop:loadLicenses', source, licenses)
  55.   end)
  56. end
  57.  
  58. RegisterServerEvent('bron_wydaj')
  59. AddEventHandler('bron_wydaj', function()
  60.  
  61.     TriggerEvent('esx_license:addLicense', gracz, 'weapon', function ()
  62.       LoadLicenses(gracz)
  63.     end)
  64.  
  65. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top