Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local client_areas = {}
- -- free client areas when leaving
- AddEventHandler("vRP:playerLeave",function(user_id,source)
- client_areas[source] = nil
- end)
- AddEventHandler('tablelenght', function()
- local txt = "\nTable client_areas : "..vRP.tablelength(client_areas)
- 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' })
- end)
- -- create/update a player area
- function vRP.setArea(source,name,x,y,z,radius,height,cb_enter,cb_leave)
- local areas = client_areas[source] or {}
- client_areas[source] = areas
- areas[name] = {enter=cb_enter,leave=cb_leave}
- vRPclient.setArea(source,{name,x,y,z,radius,height})
- end
- -- delete a player area
- function vRP.removeArea(source,name)
- -- delete remote area
- vRPclient.removeArea(source,{name})
- -- delete local area
- local areas = client_areas[source]
- if areas then
- areas[name] = nil
- end
- end
- -- TUNNER SERVER API
- function tvRP.enterArea(name)
- local _source = source
- local _name = name
- --Citizen.CreateThread(function()
- local areas = client_areas[_source]
- if areas then
- local area = areas[_name]
- if area and area.enter then -- trigger enter callback
- area.enter(_source,_name)
- end
- end
- --end)
- end
- function tvRP.leaveArea(name)
- local _source = source
- local _name = name
- --Citizen.CreateThread(function()
- local areas = client_areas[_source]
- if areas then
- local area = areas[_name]
- if area and area.leave then -- trigger leave callback
- area.leave(_source,_name)
- end
- end
- --end)
- end
- local cfg = module("cfg/blips_markers")
- -- add additional static blips/markers
- AddEventHandler("vRP:playerSpawn",function(user_id, source, first_spawn)
- if first_spawn then
- for k,v in pairs(cfg.blips) do
- vRPclient.addBlip(source,{v[1],v[2],v[3],v[4],v[5],v[6]})
- end
- for k,v in pairs(cfg.markers) do
- 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]})
- end
- -- init public chest for test?
- vRP.pChest_build_client_points(source)
- end
- end)
- function build_client_jobblips(source)
- local source = source
- local user_id = vRP.getUserId(source)
- if user_id ~= nil then
- for k,v in pairs(cfg.blipsjobs) do
- local group,x,y,z,blipid,blipcolor,blipname = table.unpack(v)
- if vRP.hasGroup(user_id,group) then
- -- We need to remove first for avoid some conflict or fail in process
- vRPclient.removeNamedBlip(source,{"vRP:JobMarker"..k})
- vRPclient.removeNamedMarker(source,{"vRP:JobMarker"..k})
- vRPclient.setNamedBlip(source,{"vRP:JobMarker"..k,x,y,z,blipid,blipcolor,blipname})
- vRPclient.setNamedMarker(source,{"vRP:JobMarker"..k,x,y,z-1,0.7,0.7,0.5,0,255,125,125,150})
- else
- -- Refresh will deleted marker if user change jobs, for avoid to disconnect to have a marker update
- vRPclient.removeNamedBlip(source,{"vRP:JobMarker"..k})
- vRPclient.removeNamedMarker(source,{"vRP:JobMarker"..k})
- end
- end
- end
- end
- function refresh_marker()
- Citizen.CreateThread(function()
- while true do
- for k,v in pairs(vRP.rusers) do
- local source = vRP.getUserSource(tonumber(k))
- build_client_jobblips(source)
- end
- --SetTimeout(90000,refresh_marker) -- Refresh every 1m30 to ALL player IN-Game
- Citizen.Wait(90000)
- end
- end)
- end
- SetTimeout(90000,refresh_marker) -- To start, wait 1m30
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement