-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.lua
87 lines (68 loc) · 2.37 KB
/
client.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
local QBCore = exports['qb-core']:GetCoreObject()
local defaultScale = 0.5 -- Text scale
local color = { r = 230, g = 230, b = 230, a = 255 } -- Text color
local font = 0 -- Text font
local displayTime = 5000 -- Duration to display the text (in ms)
local distToDraw = 5 -- Max. distance to draw
local pedDisplaying = {}
local function DrawText3D(coords, msg)
local camCoords = GetGameplayCamCoord()
local dist = #(coords - camCoords)
-- Experimental math to scale the text down
local scale = 200 / (GetGameplayCamFov() * dist)
--if onScreen then
-- Format the text
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(true)
AddTextComponentString(msg)
SetDrawOrigin(coords.x, coords.y, coords.z, 0)
DrawText(0.0, 0.0)
local factor = (string.len(msg)) / 370
DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
ClearDrawOrigin()
--end
end
local function ShowText(ped, text)
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local pedCoords = GetEntityCoords(ped)
local dist = #(playerCoords - pedCoords)
if dist <= distToDraw then
pedDisplaying[ped] = (pedDisplaying[ped] or 1) + 1
-- Timer
local display = true
Citizen.CreateThread(function()
Wait(displayTime)
display = false
end)
-- Display
local offset = 0.1 + pedDisplaying[ped] * 0.1
while display do
if HasEntityClearLosToEntity(playerPed, ped, 17 ) then
local x, y, z = table.unpack(GetEntityCoords(ped))
z = z + offset
DrawText3D(vector3(x, y, z), text)
end
Wait(0)
end
pedDisplaying[ped] = pedDisplaying[ped] - 1
end
end
-- CHAT
RegisterNetEvent('chq_com:ooc')
AddEventHandler('chq_com:ooc', function(player, id, firstname, lastname, msg)
TriggerEvent("chat:addMessage", {
color = {255,255,255},
multiline = true,
args = {"~r~OOC | " ..firstname.. " " ..lastname.. "~w~", msg}
})
end)
RegisterNetEvent('chq_com:me')
AddEventHandler('chq_com:me', function(source, msg)
local ped = GetPlayerPed(GetPlayerFromServerId(source))
ShowText(ped, msg)
end)