-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
493 lines (346 loc) · 14.8 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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
ESX = nil
Citizen.CreateThread(function()
while true do
Wait(5)
if ESX ~= nil then
else
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
end
end
end)
local locations = {}
local primeraaparicion = true
local Keys = {
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}
local spawned = false
Citizen.CreateThread( function()
Citizen.Wait(10000)
while true do
Citizen.Wait(1000)
if GetDistanceBetweenCoords(Config.PickupBlip.x,Config.PickupBlip.y,Config.PickupBlip.z, GetEntityCoords(GetPlayerPed(-1))) <= 200 then
if spawned == false then
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
TriggerEvent('Farmcyc:comienzo')
end
spawned = true
else
if spawned then
locations = {}
end
spawned = false
end
end
end)
local displayed = false
local menuOpen = false
local blipPickup = AddBlipForCoord(Config.PickupBlip.x,Config.PickupBlip.y,Config.PickupBlip.z)
SetBlipSprite (blipPickup, 266)
SetBlipDisplay(blipPickup, 4)
SetBlipScale (blipPickup, 1.1)
SetBlipColour (blipPickup, 47)
SetBlipAsShortRange(blipPickup, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(Config.nombrerecoBlip)
EndTextCommandSetBlipName(blipPickup)
local blipProcess = AddBlipForCoord(Config.Processing.x, Config.Processing.y, Config.Processing.z)
SetBlipSprite (blipProcess, 266)
SetBlipDisplay(blipProcess, 4)
SetBlipScale (blipProcess, 1.1)
SetBlipColour (blipProcess, 47)
SetBlipAsShortRange(blipProcess, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(Config.nombreproceBlip)
EndTextCommandSetBlipName(blipProcess)
local process = true
local blipcamarones = AddBlipForCoord(Config.camarones.x, Config.camarones.y, Config.camarones.z)
SetBlipSprite (blipcamarones, 266)
SetBlipDisplay(blipcamarones, 4)
SetBlipScale (blipcamarones, 1.1)
SetBlipColour (blipcamarones, 47)
SetBlipAsShortRange(blipcamarones, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(Config.nombrecamaBlip)
EndTextCommandSetBlipName(blipcamarones)
local camarones = true
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
for k in pairs(locations) do
if GetDistanceBetweenCoords(locations[k].x, locations[k].y, locations[k].z, GetEntityCoords(GetPlayerPed(-1))) < 150 then
DrawMarker(2, locations[k].x, locations[k].y, locations[k].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 228, 71, 12, 110, 1, 1, 0, 1)
if GetDistanceBetweenCoords(locations[k].x, locations[k].y, locations[k].z, GetEntityCoords(GetPlayerPed(-1)), false) < 2 then
ESX.ShowHelpNotification('Press ~ INPUT_PICKUP ~ to catch Crabs / Shrimp')
if IsControlJustReleased(0, Keys['E']) then
--TriggerServerEvent('Farmcyc:recoleccion')
----TriggerEvent('Farmcyc:nuevo', k)
Animacion()
TriggerEvent('Farmcyc:nuevo', k)
end
end
end
end
-------------------------------------------------------------------------------------------------------------------------------------
if GetDistanceBetweenCoords(Config.Processing.x, Config.Processing.y, Config.Processing.z, GetEntityCoords(GetPlayerPed(-1))) < 150 then
DrawMarker(2, Config.Processing.x, Config.Processing.y, Config.Processing.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.3, 1.3, 1.0, 228, 71, 12, 110, 1, 1, 0, 1)
if GetDistanceBetweenCoords(Config.Processing.x, Config.Processing.y, Config.Processing.z, GetEntityCoords(GetPlayerPed(-1)), true) < 2 then
---Draw3DText( Config.Processing.x, Config.Processing.y, Config.Processing.z , "~w~Produccion of crabs~y~\nPresiona [~b~E~y~] para comenzar el empaquetado",4,0.15,0.1)
DrawText3Ds(vector3(Config.Processing.x,Config.Processing.y,Config.Processing.z), "Press [E] to pack Crabs ", 0.35)
if IsControlJustReleased(0, Keys['E']) then
Citizen.CreateThread(function()
Process()
end)
end
end
if GetDistanceBetweenCoords(Config.Processing.x, Config.Processing.y, Config.Processing.z, GetEntityCoords(GetPlayerPed(-1)), true) < 5 and GetDistanceBetweenCoords(Config.Processing.x, Config.Processing.y, Config.Processing.z, GetEntityCoords(GetPlayerPed(-1)), true) > 3 then
process = false
end
end
------------------------------------------------------------------------------------------------------------------------------------------------------
if GetDistanceBetweenCoords(Config.camarones.x, Config.camarones.y, Config.camarones.z, GetEntityCoords(GetPlayerPed(-1))) < 150 then
DrawMarker(2, Config.camarones.x, Config.camarones.y, Config.camarones.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.3, 1.3, 1.0, 228, 71, 12, 110, 1, 1, 0, 1)
if GetDistanceBetweenCoords(Config.camarones.x, Config.camarones.y, Config.camarones.z, GetEntityCoords(GetPlayerPed(-1)), true) < 2 then
---Draw3DText( Config.Processing.x, Config.Processing.y, Config.Processing.z , "~w~Produccion of crabs~y~\nPresiona [~b~E~y~] para comenzar el empaquetado",4,0.15,0.1)
DrawText3Ds(vector3(Config.camarones.x,Config.camarones.y,Config.camarones.z), "Press [E] to pack Shrimp ", 0.35)
if IsControlJustReleased(0, Keys['E']) then
Citizen.CreateThread(function()
Camarones()
end)
end
end
if GetDistanceBetweenCoords(Config.camarones.x, Config.camarones.y, Config.camarones.z, GetEntityCoords(GetPlayerPed(-1)), true) < 5 and GetDistanceBetweenCoords(Config.Processing.x, Config.Processing.y, Config.Processing.z, GetEntityCoords(GetPlayerPed(-1)), true) > 3 then
camarones = false
end
end
end
end)
function Draw3DText(x,y,z,textInput,fontId,scaleX,scaleY)
local px,py,pz=table.unpack(GetGameplayCamCoords())
local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
local scale = (1/dist)*20
local fov = (1/GetGameplayCamFov())*100
local scale = scale*fov
SetTextScale(scaleX*scale, scaleY*scale)
SetTextFont(fontId)
SetTextProportional(1)
if inDist then
SetTextColour(0, 190, 0, 220) -- You can change the text color here
else
SetTextColour(220, 0, 0, 220) -- You can change the text color here
end
SetTextDropshadow(1, 1, 1, 1, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(textInput)
SetDrawOrigin(x,y,z+2, 0)
DrawText(0.0, 0.0)
ClearDrawOrigin()
end
function Animacion()
local ped = PlayerPedId()
RequestAnimDict("amb@world_human_gardener_plant@male@idle_a")
Citizen.Wait(100)
FreezeEntityPosition(ped,true)
TaskPlayAnim(ped,'amb@world_human_gardener_plant@male@idle_a', 'idle_b', 8.0, 8.0, -1, 0, 0, 0, 0, 0)
exports['progressBars']:startUI(1500, "Buscando")
Citizen.Wait(1500)
TriggerServerEvent('Farmcyc:recoleccion')
ClearPedTasks(ped)
FreezeEntityPosition(ped,false)
end
function Process()
process = true
local making = true
while making and process do
TriggerEvent('esx:showNotification', '~g~Starting ~w~the production ~g~of crabs')
Citizen.Wait(5000)
ESX.TriggerServerCallback('Farmcyc:empaquetado:cangrejos', function(output)
making = output
end)
end
end
function Camarones()
camarones = true
local makingcamarones = true
while makingcamarones and camarones do
TriggerEvent('esx:showNotification', '~g~Starting ~w~the production ~g~shrimp')
Citizen.Wait(5000)
ESX.TriggerServerCallback('Farmcyc:empaquetado:camarones', function(output)
makingcamarones = output
end)
end
end
RegisterNetEvent('Farmcyc:comienzo')
AddEventHandler('Farmcyc:comienzo', function()
local set = false
Citizen.Wait(10)
local rnX = Config.PickupBlip.x + math.random(-35, 35)
local rnY = Config.PickupBlip.y + math.random(-35, 35)
local u, Z = GetGroundZFor_3dCoord(rnX ,rnY ,300.0,0)
table.insert(locations,{x=rnX, y=rnY, z=Z + 0.3});
end)
RegisterNetEvent('Farmcyc:nuevo')
AddEventHandler('Farmcyc:nuevo', function(id)
local set = false
Citizen.Wait(10)
local rnX = Config.PickupBlip.x + math.random(-35, 35)
local rnY = Config.PickupBlip.y + math.random(-35, 35)
local u, Z = GetGroundZFor_3dCoord(rnX ,rnY ,300.0,0)
locations[id].x = rnX
locations[id].y = rnY
locations[id].z = Z + 0.3
end)
RegisterNetEvent('Farmcyc:mensaje')
AddEventHandler('Farmcyc:mensaje', function(message)
ESX.ShowNotification(message)
end)
function DisplayHelpText(str)
SetTextComponentFormat("STRING")
AddTextComponentString(str)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
DrawText3Ds = function(coords, text, scale)
local x,y,z = coords.x, coords.y, coords.z
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
local pX, pY, pZ = table.unpack(GetGameplayCamCoords())
SetTextScale(scale, scale)
SetTextFont(4)
SetTextProportional(1)
SetTextEntry("STRING")
SetTextCentre(1)
SetTextColour(255, 255, 255, 215)
AddTextComponentString(text)
DrawText(_x, _y)
local factor = (string.len(text)) / 280
DrawRect(_x, _y + 0.0115, 0.032 + factor, 0.033, 41, 11, 41, 100)
end
Citizen.CreateThread(function()
Blipventacamaronesycangrejos = AddBlipForCoord(Config.ventacyc.x, Config.ventacyc.y, Config.ventacyc.z)
SetBlipSprite(Blipventacamaronesycangrejos, 266)
SetBlipColour(Blipventacamaronesycangrejos, 47)
SetBlipScale(Blipventacamaronesycangrejos, 1.5)
AddTextComponentString(Config.Blipnombrecyc)
EndTextCommandSetBlipName(Blipventacamaronesycangrejos)
end)
Citizen.CreateThread(function()
while true do
local ped = PlayerPedId()
Citizen.Wait(1)
if GetDistanceBetweenCoords(GetEntityCoords(ped), Config.ventacyc.x, Config.ventacyc.y, Config.ventacyc.z, true) < 25 then
DrawMarker(29, Config.ventacyc.x, Config.ventacyc.y, Config.ventacyc.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5, 1.5, 1.0, 228, 71, 12, 100, true, false, 2, false, nil, nil, false)
if GetDistanceBetweenCoords(GetEntityCoords(ped), Config.ventacyc.x, Config.ventacyc.y, Config.ventacyc.z, true) < 2 then
DrawText3Ds(vector3(Config.ventacyc.x,Config.ventacyc.y,Config.ventacyc.z), "Press [E] to open the store menu ", 0.35)
--ESX.ShowHelplNotification("Presiona ~INPUT_CONTEXT~ para abrir el menu de venta")
if IsControlJustReleased(0, Keys['E']) then
tiendacyc()
end
end
end
end
end)
function tiendacyc()
local elements ={
{ label = 'Sell Shrimp <span style = "color:#65D754;">' ..Config.PCamaron .. '$</span>', value = 'Camarones1'},
{ label = 'Sell Crabs <span style = "color:#65D754;">' ..Config.PCangrejo .. '$</span>', value = 'Cangrejos1'},
{ label = 'Leave <span style = "color:#DA2020;">Cerrar ventana</span>', value = 'salir'},
}
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(),'ventacyc',{
title = 'ventacyc',
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.value == 'Camarones1' then
TriggerServerEvent("Ventadecamarones")
elseif data.current.value == 'Cangrejos1' then
TriggerServerEvent("Ventadecangrejos")
elseif data.current.value == 'salir' then
menu.close()
end
end)
end
Citizen.CreateThread(function()
local hash = GetHashKey("s_m_y_chef_01")
if not HasModelLoaded(hash) then
RequestModel(hash)
Citizen.Wait(100)
end
while not HasModelLoaded(hash) do
Citizen.Wait(0)
end
if primeraaparicion == true then
local npc = CreatePed(6,hash, Config.pedventa.x, Config.pedventa.y, Config.pedventa.z, Config.pedventa.h, false, false)
FreezeEntityPosition(npc, true)
SetEntityInvincible(npc, true)
SetBlockingOfNonTemporaryEvents(npc, true)
while not TaskStartScenarioInPlace(npc,"WORLD_HUMAN_CLIPBOARD", 1, true) do
Citizen.Wait(200)
end
Citizen.Wait(200)
end
end)
Citizen.CreateThread(function()
local hash = GetHashKey("s_f_y_factory_01")
if not HasModelLoaded(hash) then
RequestModel(hash)
Citizen.Wait(100)
end
while not HasModelLoaded(hash) do
Citizen.Wait(0)
end
if primeraaparicion == true then
local npc = CreatePed(6,hash, Config.pedemp1.x, Config.pedemp1.y, Config.pedemp1.z, Config.pedemp1.h, false, false)
FreezeEntityPosition(npc, true)
SetEntityInvincible(npc, true)
SetBlockingOfNonTemporaryEvents(npc, true)
while not TaskStartScenarioInPlace(npc,"WORLD_HUMAN_CLIPBOARD", 2, true) do
Citizen.Wait(200)
end
Citizen.Wait(200)
end
end)
Citizen.CreateThread(function()
local hash = GetHashKey("s_m_y_factory_01")
if not HasModelLoaded(hash) then
RequestModel(hash)
Citizen.Wait(100)
end
while not HasModelLoaded(hash) do
Citizen.Wait(0)
end
if primeraaparicion == true then
local npc = CreatePed(6,hash, Config.pedemp2.x, Config.pedemp2.y, Config.pedemp2.z, Config.pedemp2.h, false, false)
FreezeEntityPosition(npc, true)
SetEntityInvincible(npc, true)
SetBlockingOfNonTemporaryEvents(npc, true)
while not TaskStartScenarioInPlace(npc,"WORLD_HUMAN_CLIPBOARD", 1, true) do
Citizen.Wait(200)
end
Citizen.Wait(200)
end
end)