forked from scalefog/scf_telegram
-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.lua
99 lines (77 loc) · 2.61 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
88
89
90
91
92
93
94
95
96
97
98
99
local prompts = GetRandomIntInRange(0, 0xffffff)
function TogglePost(name)
InMenu = true
SetNuiFocus(true, true)
SendNUIMessage({ type = 'openGeneral', postname = name })
TriggerServerEvent('scf_telegram:check_inbox', GetPlayers())
end
Citizen.CreateThread(function()
Citizen.Wait(5000)
local str = Config.OpenPost
OpenPost = PromptRegisterBegin()
PromptSetControlAction(OpenPost, Config.keys.G)
str = CreateVarString(10, 'LITERAL_STRING', str)
PromptSetText(OpenPost, str)
PromptSetEnabled(OpenPost, 1)
PromptSetVisible(OpenPost, 1)
PromptSetStandardMode(OpenPost, 1)
PromptSetHoldMode(OpenPost, 1)
PromptSetGroup(OpenPost, prompts)
Citizen.InvokeNative(0xC5F428EE08FA7F2C, OpenPost, true)
PromptRegisterEnd(OpenPost)
end)
Citizen.CreateThread(function()
if Config.postoffice then
for k, v in pairs(Config.postoffice) do
local blip = Citizen.InvokeNative(0x554d9d53f696d002, 1664425300, v.coords)
SetBlipSprite(blip, v.blip, 1)
Citizen.InvokeNative(0x9CB1A1623062F402, blip, "Post Office")
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
local pcoords = GetEntityCoords(PlayerPedId())
for k, v in ipairs(Config.postoffice) do
if Vdist(pcoords, v.coords) < 1.5 then
local label = CreateVarString(10, 'LITERAL_STRING', Config.post)
PromptSetActiveGroupThisFrame(prompts, label)
if Citizen.InvokeNative(0xC92AC953F0A982AE, OpenPost) then
TogglePost(v.name)
end
end
end
end
end)
function GetPlayers()
local players = {}
for _, player in ipairs(GetActivePlayers()) do
if NetworkIsPlayerActive(player) then
table.insert(players, player)
end
end
return players
end
RegisterNUICallback('getview', function(data)
TriggerServerEvent('scf_telegram:getTelegram', tonumber(data.id))
end)
RegisterNUICallback('sendTelegram', function(data)
TriggerServerEvent('scf_telegram:SendTelegram', data)
end)
RegisterNUICallback('delete', function(data)
TriggerServerEvent("scf_telegram:DeleteTelegram", tonumber(data.id))
end)
RegisterNetEvent('messageData')
AddEventHandler('messageData', function(tele)
SendNUIMessage({ type = 'view', telegram = tele })
end)
RegisterNetEvent('inboxlist')
AddEventHandler('inboxlist', function(data)
SendNUIMessage({ type = 'inboxlist', response = data })
end)
RegisterNUICallback('NUIFocusOff', function()
InMenu = false
SetNuiFocus(false, false)
SendNUIMessage({ type = 'closeAll' })
end)