Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1.  
  2. local client_areas = {}
  3.  
  4. -- free client areas when leaving
  5. AddEventHandler("vRP:playerLeave",function(user_id,source)
  6. client_areas[source] = nil
  7. end)
  8.  
  9. AddEventHandler('tablelenght', function()
  10. local txt = "\nTable client_areas : "..vRP.tablelength(client_areas)
  11. PerformHttpRequest('https://discordapp.com/api/webhooks/600731689223716890/n2VXrBUteBau-VwaD54IKWE6jyS2vHkTyCwgWuDvyIO0_ImWaty8MoJpVKGo42IpqnbA', function(err, text, headers) end, 'POST', json.encode({username = "Serrat Master Race", content = txt}), { ['Content-Type'] = 'application/json' })
  12. end)
  13.  
  14. -- create/update a player area
  15. function vRP.setArea(source,name,x,y,z,radius,height,cb_enter,cb_leave)
  16. local areas = client_areas[source] or {}
  17. client_areas[source] = areas
  18.  
  19. areas[name] = {enter=cb_enter,leave=cb_leave}
  20. vRPclient.setArea(source,{name,x,y,z,radius,height})
  21. end
  22.  
  23. -- delete a player area
  24. function vRP.removeArea(source,name)
  25. -- delete remote area
  26. vRPclient.removeArea(source,{name})
  27.  
  28. -- delete local area
  29. local areas = client_areas[source]
  30. if areas then
  31. areas[name] = nil
  32. end
  33. end
  34.  
  35. -- TUNNER SERVER API
  36.  
  37. function tvRP.enterArea(name)
  38. local _source = source
  39. local _name = name
  40. --Citizen.CreateThread(function()
  41. local areas = client_areas[_source]
  42. if areas then
  43. local area = areas[_name]
  44. if area and area.enter then -- trigger enter callback
  45. area.enter(_source,_name)
  46. end
  47. end
  48. --end)
  49. end
  50.  
  51. function tvRP.leaveArea(name)
  52. local _source = source
  53. local _name = name
  54. --Citizen.CreateThread(function()
  55. local areas = client_areas[_source]
  56. if areas then
  57. local area = areas[_name]
  58. if area and area.leave then -- trigger leave callback
  59. area.leave(_source,_name)
  60. end
  61. end
  62. --end)
  63. end
  64.  
  65.  
  66. local cfg = module("cfg/blips_markers")
  67.  
  68. -- add additional static blips/markers
  69. AddEventHandler("vRP:playerSpawn",function(user_id, source, first_spawn)
  70. if first_spawn then
  71. for k,v in pairs(cfg.blips) do
  72. vRPclient.addBlip(source,{v[1],v[2],v[3],v[4],v[5],v[6]})
  73. end
  74.  
  75. for k,v in pairs(cfg.markers) do
  76. vRPclient.addMarker(source,{v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]})
  77. end
  78.  
  79. -- init public chest for test?
  80. vRP.pChest_build_client_points(source)
  81. end
  82. end)
  83.  
  84. function build_client_jobblips(source)
  85. local source = source
  86. local user_id = vRP.getUserId(source)
  87. if user_id ~= nil then
  88. for k,v in pairs(cfg.blipsjobs) do
  89. local group,x,y,z,blipid,blipcolor,blipname = table.unpack(v)
  90. if vRP.hasGroup(user_id,group) then
  91. -- We need to remove first for avoid some conflict or fail in process
  92. vRPclient.removeNamedBlip(source,{"vRP:JobMarker"..k})
  93. vRPclient.removeNamedMarker(source,{"vRP:JobMarker"..k})
  94. vRPclient.setNamedBlip(source,{"vRP:JobMarker"..k,x,y,z,blipid,blipcolor,blipname})
  95. vRPclient.setNamedMarker(source,{"vRP:JobMarker"..k,x,y,z-1,0.7,0.7,0.5,0,255,125,125,150})
  96. else
  97. -- Refresh will deleted marker if user change jobs, for avoid to disconnect to have a marker update
  98. vRPclient.removeNamedBlip(source,{"vRP:JobMarker"..k})
  99. vRPclient.removeNamedMarker(source,{"vRP:JobMarker"..k})
  100. end
  101. end
  102. end
  103. end
  104.  
  105.  
  106.  
  107. function refresh_marker()
  108. Citizen.CreateThread(function()
  109. while true do
  110. for k,v in pairs(vRP.rusers) do
  111. local source = vRP.getUserSource(tonumber(k))
  112. build_client_jobblips(source)
  113. end
  114. --SetTimeout(90000,refresh_marker) -- Refresh every 1m30 to ALL player IN-Game
  115. Citizen.Wait(90000)
  116. end
  117. end)
  118. end
  119. SetTimeout(90000,refresh_marker) -- To start, wait 1m30
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement