-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.lua
More file actions
228 lines (199 loc) · 7.98 KB
/
Copy pathclient.lua
File metadata and controls
228 lines (199 loc) · 7.98 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
function roundValue(number, decimals)
local power = 10^decimals
return math.floor(number * power) / power
end
local blips = {}
local PedsCreateds = {}
--
-- [[ BLIPS ]]
---
if Config.BlipsMap then
Citizen.CreateThread(function()
for _, info in pairs(Config.Stores) do
local blipR = N_0x554d9d53f696d002(1664425300, info.x, info.y, info.z)
SetBlipSprite(blipR, info.sprite, 1)
SetBlipScale(blipR, 0.2)
Citizen.InvokeNative(0x9CB1A1623062F402, blipR, info.Name)
table.insert(blips, blipR)
end
end)
end
--
-- [[ NPC CREATOR ]]
---
PedID = {}
Citizen.CreateThread(function()
for _, v in pairs(Config.Peds) do
addNPC(v[1], v[2], v[3], v[4], v[5], v[6])
end
end)
function addNPC(x, y, z, heading, model, pedBase)
hashe = GetHashKey(model)
RequestModel(hashe)
if not HasModelLoaded(hashe) then
Wait(15)
end
while not HasModelLoaded(hashe) do
Wait(1)
end
ped = CreatePed(
hashe,
x,
y,
z -1,
heading,
false,
true
)
Citizen.InvokeNative(0x283978A15512B2FE, ped, false)
FreezeEntityPosition(ped, true)
SetEntityInvincible(ped, true)
SetEntityAsMissionEntity(ped, 1, 1)
SetBlockingOfNonTemporaryEvents(ped, true)
table.insert(PedID,{
IDPED = ped,
pedBase = pedBase
})
table.insert(PedsCreateds, ped)
PedsList = json.encode(PedID)
end
---
-- [[ INTERACT ]]
---
local HasAlreadyEnteredMarker = false
local Timer = 1800
local notificationSend = false
Citizen.CreateThread(function()
_InfinitySource = GetPlayerServerId(PlayerId())
while true do
Citizen.Wait(Timer)
-- click = false
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local TypeZone = nil
local IsInMarker = false
for _, store in pairs(Config.Stores) do
if GetDistanceBetweenCoords(coords, store.x, store.y, store.z, true) <= Config.Distance and not click then
IsInMarker = true
Timer = 10
if not notificationSend then
PlaySoundFrontend("Player_Enter_Line", "RDRO_ATL_Sounds", true, 0)
exports.infinity_core:notification(_InfinitySource, store.Name, '<small style="font-size:20px;">Press Enter Key <br> Taxs '..store.tax..'$</small>', 'center_left', 'infinitycore', 2500)
notificationSend = true
end
if IsControlJustPressed(2, Config.KeyOpenMenu) and not click then
click = true
Timer = 1800
TaskStartScenarioInPlace(
PlayerPedId() --[[ Ped ]],
GetHashKey('WORLD_HUMAN_SMOKE') --[[ Hash ]],
-1 --[[ integer ]],
true --[[ boolean ]],
GetHashKey('') --[[ Hash ]],
-1.0 --[[ number ]],
false --[[ boolean ]]
)
if store.pedid ~= 0 then
extract = json.decode(PedsList)
if extract ~= nil then
for i, json in pairs(extract) do
if json.pedBase == store.pedid then
if store.pedSound ~= nil then
NetworkRequestControlOfNetworkId(store.pedid)
play_ambient_speech_from_entity(json.IDPED, store.pedSound, store.dialog,"speech_params_force",0)
end
break
end
end
end
end
TriggerEvent('infinity_stores:openmenu', store.Name, store.DescName, store.type, store.tax)
end
end
end
if IsInMarker and not HasAlreadyEnteredMarker then
HasAlreadyEnteredMarker = true
end
if not IsInMarker and HasAlreadyEnteredMarker then
Timer = 1800
HasAlreadyEnteredMarker = false
notificationSend = false
end
end
end)
---- NUI ----
RegisterNetEvent('infinity_stores:openmenu')
AddEventHandler('infinity_stores:openmenu', function(StoreName, DescName, StoreType, StoreTax)
DisplayActions(not displaymenu, StoreName, DescName, StoreType, StoreTax)
end)
function DisplayActions(bool, StoreName, DescName, StoreType, StoreTax)
displaymenu = bool
SetNuiFocus(bool, bool)
SendNUIMessage({
type = "nui_content",
status = displaymenu,
StoreName = StoreName,
DescName = DescName,
StoreType = StoreType,
StoreTax = StoreTax
})
end
RegisterNUICallback("buy", function(data)
local PlayerLevel = exports.infinity_core:XpReturn()
local PlayerDatas = exports.infinity_core:GetPlayerSession(_InfinitySource)
if tonumber(data.lvl) <= tonumber(PlayerLevel) then
PlaySoundFrontend("PURCHASE", "Ledger_Sounds", true, 0)
TriggerServerEvent('infinity_stores:buy', _InfinitySource, data.itemdb, data.price, data.quantity, PlayerDatas)
else
exports.infinity_core:notification(_InfinitySource, "You dont have level", "", "center_right", "infinitycore", 1500)
end
end)
RegisterNUICallback("sell", function(data)
local PlayerLevel = exports.infinity_core:XpReturn()
if tonumber(data.lvl) <= tonumber(PlayerLevel) then
PlaySoundFrontend("PURCHASE", "Ledger_Sounds", true, 0)
TriggerServerEvent('infinity_stores:sell', _InfinitySource, data.itemdb, data.price, data.quantity, data.xp)
else
exports.infinity_core:notification(_InfinitySource, "You dont have level for sell this", "", "center_right", "infinitycore", 1500)
end
end)
RegisterNUICallback("exit", function(data)
ClearPedTasks(PlayerPedId(), true, true)
DisplayActions(false)
click = false
end)
function play_ambient_speech_from_entity(entity_id,sound_ref_string,sound_name_string,speech_params_string,speech_line)
local struct = DataView.ArrayBuffer(128)
local sound_name = Citizen.InvokeNative(0xFA925AC00EB830B9, 10, "LITERAL_STRING", sound_name_string,Citizen.ResultAsLong())
local sound_ref = Citizen.InvokeNative(0xFA925AC00EB830B9, 10, "LITERAL_STRING",sound_ref_string,Citizen.ResultAsLong())
local speech_params = GetHashKey(speech_params_string)
local sound_name_BigInt = DataView.ArrayBuffer(16)
sound_name_BigInt:SetInt64(0,sound_name)
local sound_ref_BigInt = DataView.ArrayBuffer(16)
sound_ref_BigInt:SetInt64(0,sound_ref)
local speech_params_BigInt = DataView.ArrayBuffer(16)
speech_params_BigInt:SetInt64(0,speech_params)
struct:SetInt64(0,sound_name_BigInt:GetInt64(0))
struct:SetInt64(8,sound_ref_BigInt:GetInt64(0))
struct:SetInt32(16,speech_line)
struct:SetInt64(24,speech_params_BigInt:GetInt64(0))
struct:SetInt32(32, 0)
struct:SetInt32(40, 1)
struct:SetInt32(48, 1)
struct:SetInt32(56, 1)
Citizen.InvokeNative(0x8E04FEDD28D42462, entity_id, struct:Buffer());
end
----
-- [[ DELETER FUNCTION ]]
----
AddEventHandler("onResourceStop",function(resourceName)
if GetCurrentResourceName() == resourceName then
print("^6 ["..GetCurrentResourceName().." are stop by dev, all blips/npc are removed for performances]")
for _, blipR in pairs(blips) do
RemoveBlip(blipR)
end
for _, ped in pairs(PedsCreateds) do
DeleteEntity(ped)
end
end
end)