-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathclient.lua
119 lines (98 loc) · 3.33 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
function GetOffsetFromCoordsAndHeading(coords, heading, offsetX, offsetY, offsetZ)
local headingRad = math.rad(heading)
local x = offsetX * math.cos(headingRad) - offsetY * math.sin(headingRad)
local y = offsetX * math.sin(headingRad) + offsetY * math.cos(headingRad)
local z = offsetZ
local worldCoords = vector4(
coords.x + x,
coords.y + y,
coords.z + z,
heading
)
return worldCoords
end
function CamCreate(npc)
cam = CreateCam('DEFAULT_SCRIPTED_CAMERA')
local coordsCam = GetOffsetFromCoordsAndHeading(npc, npc.w, 0.0, 0.6, 1.60)
print(coordsCam)
local coordsPly = npc
SetCamCoord(cam, coordsCam)
PointCamAtCoord(cam, coordsPly['x'], coordsPly['y'], coordsPly['z']+1.60)
SetCamActive(cam, true)
RenderScriptCams(true, true, 500, true, true)
end
function DestroyCamera()
RenderScriptCams(false, true, 500, 1, 0)
DestroyCam(cam, false)
end
-- NPC'leri spawn et
CreateThread(function()
for _, npc in ipairs(Config.npcs) do
RequestModel(GetHashKey(npc.ped))
print(npc.ped)
print(npc.coords)
while not HasModelLoaded(GetHashKey(npc.ped)) do
Wait(500)
end
local npcPed = CreatePed(4, GetHashKey(npc.ped), npc.coords.x, npc.coords.y, npc.coords.z, npc.coords.w, false, false)
FreezeEntityPosition(npcPed, true)
SetEntityInvincible(npcPed, true)
SetBlockingOfNonTemporaryEvents(npcPed, true)
end
end)
RegisterNetEvent("yazdir", function(text)
if not text == nil then
print(text)
else
print("bos")
end
end)
RegisterNetEvent("npc-menu:showMenu", function(npc)
SendNUIMessage({
type = "dialog",
options = npc.options,
name = npc.name,
text = npc.text,
job = npc.job
})
CamCreate(npc.coords)
end)
RegisterNUICallback("npc-menu:hideMenu", function()
SetNuiFocus(false, false)
DestroyCamera()
end)
RegisterNUICallback("npc-menu:islem", function(data)
SetNuiFocus(false, false)
print(data.event, json.encode(data.args), data.type)
print(data.type)
if data.type == 'client' then
TriggerEvent(data.event, json.encode(data.args))
elseif data.type == 'server' then
TriggerServerEvent(data.event, json.encode(data.args))
elseif data.type == 'command' then
ExecuteCommand(data.event, json.encode(data.args))
end
DestroyCamera()
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
for _, npc in ipairs(Config.npcs) do
local coords = GetEntityCoords(playerPed, false)
local distance = GetDistanceBetweenCoords(coords, npc.coords.x, npc.coords.y, npc.coords.z, true)
if distance < 1.5 then
DisplayHelpText("E tuşuna basarak etkileşime geç")
if IsControlJustPressed(0, 38) then -- E tuşuna basıldığında
TriggerEvent("npc-menu:showMenu", npc)
SetNuiFocus(true, true)
end
end
end
end
end)
function DisplayHelpText(text)
SetTextComponentFormat("STRING")
AddTextComponentString(text)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end