This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.lua
61 lines (53 loc) · 1.84 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
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/try', 'Attempts an actions', {{name = 'Action', help = '50/50 chance it will succeed.'}})
end)
local nbrDisplaying = 1
RegisterCommand('try', function(source, args, raw)
local text = string.sub(raw, 4)
TriggerServerEvent('daily_Try:serverDisplay', text)
end)
RegisterNetEvent('daily_Try:display')
AddEventHandler('daily_Try:display', function(text, source)
local offset = 1 + (nbrDisplaying*0.15)
Display(GetPlayerFromServerId(source), text, offset)
end)
function Display(mePlayer, text, offset)
local displaying = true
Citizen.CreateThread(function()
Wait(5000)
displaying = false
end)
Citizen.CreateThread(function()
nbrDisplaying = nbrDisplaying + 1
while displaying do
Wait(0)
local coordsMe = GetEntityCoords(GetPlayerPed(mePlayer), false)
local coords = GetEntityCoords(PlayerPedId(), false)
local dist = Vdist2(coordsMe, coords)
if dist < 500 then
DrawText3D(coordsMe['x'], coordsMe['y'], coordsMe['z']+offset, text)
end
end
nbrDisplaying = nbrDisplaying - 1
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