forked from Developer-Bear/RNG_FrontDeskPage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient-FrontDeskPage.lua
70 lines (63 loc) · 2.25 KB
/
client-FrontDeskPage.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
----------------------------------------------------------------------------------------------
-- Initialize ESX Data --
----------------------------------------------------------------------------------------------
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
PlayerData = ESX.GetPlayerData()
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
ESX.PlayerData.job = job
end)
-- Draw 3D text when player is close enough and listen for keypress
Citizen.CreateThread(function ()
while true do
Citizen.Wait(0)
local coords = GetEntityCoords(PlayerPedId())
for k,v in pairs(Config.Locations) do
if GetDistanceBetweenCoords(coords, v.Coords.x, v.Coords.y, v.Coords.z, true) < Config.TextDrawDistance then
local location = v
DrawText3D(v.Coords.x, v.Coords.y, v.Coords.z - 1.0, _U('pageFloatingText'))
if IsControlJustReleased(1, 182) then
TriggerServerEvent('RNG_FrontDeskPage:SendPage', location)
end
end
end
end
end)
RegisterNetEvent('RNG_FrontDeskPage:Page')
AddEventHandler('RNG_FrontDeskPage:Page', function(location)
for k,v in pairs(location.JobsToPage) do
if PlayerData.job and PlayerData.job.name == v then
TriggerEvent("chatMessage", "Dispatch: ", {255, 0, 0}, _U('notificationText', location.DisplayName))
PlaySoundFrontend(-1, Config.SoundDirectory, Config.SoundName, 0,0,1)
end
end
end)
function DrawText3D(x,y,z, text)
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
local p = GetGameplayCamCoords()
local distance = GetDistanceBetweenCoords(p.x, p.y, p.z, x, y, z, 1)
local scale = (1 / distance) * 2
local fov = (1 / GetGameplayCamFov()) * 100
local scale = scale * fov
if onScreen then
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
local factor = (string.len(text)) / 370
DrawRect(_x,_y+0.0125, 0.015+ factor, 0.03, 41, 11, 41, 68)
end
end