-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtest.lua
More file actions
188 lines (158 loc) · 6.07 KB
/
test.lua
File metadata and controls
188 lines (158 loc) · 6.07 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
if lib.context == "client" then
-------------------------------------------------
-- Client Test Commands
-------------------------------------------------
---
local Waypoint = require 'client.modules.Waypoint'
-- Test small marker
RegisterCommand('testsmall', function()
local playerPos = GetEntityCoords(cache.ped)
local testPos = playerPos + GetEntityForwardVector(cache.ped) * 5.0
local id = Waypoint.create({
coords = testPos,
type = 'small',
color = '#ff6b6b',
-- image = 'nui://ox_inventory/web/images/copper_ore.webp',
icon = "hand",
size = 0.25,
drawDistance = 100.0,
removeWhenClose = true,
removeDistance = 1.0,
displayDistance = true,
})
print('Created small waypoint:', id)
SetTimeout(30000, function()
Waypoint.remove(id)
print('Removed waypoint:', id)
end)
end, false)
-- Test checkpoint marker
RegisterCommand('testcheckpoint', function()
local playerPos = GetEntityCoords(cache.ped)
local testPos = GetOffsetFromEntityInWorldCoords(cache.ped, 0.0, 20.0, -1.0)
local id = Waypoint.create({
coords = testPos,
type = 'checkpoint',
color = '#f5a623',
label = 'CHECKPOINT',
-- image = 'nui://ox_inventory/web/images/copper_ore.webp',
icon = "hand",
size = 1.0,
drawDistance = 500.0,
groundZ = playerPos.z - 1,
minHeight = 5.0,
maxHeight = 80.0,
displayDistance = true,
})
print('Created checkpoint waypoint:', id)
SetTimeout(10000, function()
Waypoint.remove(id)
print('Removed waypoint:', id)
end)
end, false)
-- Test multiple checkpoints
RegisterCommand('testcheckpoints', function()
local playerPos = GetEntityCoords(cache.ped)
local groundZ = playerPos.z - 1
local colors = { '#f5a623', '#4ecdc4', '#9b59b6' }
local labels = { 'CHECKPOINT', 'DESTINATION', 'OBJECTIVE' }
for i = 1, 3 do
local angle = (i - 1) * 120 * (math.pi / 180)
local distance = 150 + (i * 50)
local testPos = playerPos + vec3(
math.sin(angle) * distance,
math.cos(angle) * distance,
0
)
Waypoint.create({
coords = testPos,
type = 'checkpoint',
color = colors[i],
label = labels[i],
size = 1.0,
drawDistance = 600.0,
groundZ = groundZ,
})
end
print('Created 3 checkpoint waypoints')
end, false)
-- Test waypoints in a line
RegisterCommand('testline', function()
local playerPos = GetEntityCoords(cache.ped)
local groundZ = playerPos.z - 1
local waypoints = {
{ type = 'small', color = '#ff6b6b', icon = 'hand', size = 0.15, label = nil },
{ type = 'small', color = '#4ecdc4', icon = 'circle', size = 0.2, label = nil },
{ type = 'checkpoint', color = '#f5a623', icon = nil, size = 0.8, label = 'POINT A' },
{ type = 'small', color = '#9b59b6', icon = 'star', size = 0.25, label = nil },
{ type = 'checkpoint', color = '#3498db', icon = nil, size = 1.0, label = 'POINT B' },
{ type = 'small', color = '#2ecc71', icon = 'check', size = 0.15, label = nil },
{ type = 'checkpoint', color = '#e74c3c', icon = nil, size = 1.2, label = 'DESTINATION' },
}
for i, wp in ipairs(waypoints) do
local testPos = GetOffsetFromEntityInWorldCoords(cache.ped, 0.0, 10.0 * i, 0.0)
Waypoint.create({
coords = testPos,
type = wp.type,
color = wp.color,
icon = wp.icon,
label = wp.label,
size = wp.size,
drawDistance = 500.0,
groundZ = groundZ,
})
end
print('Created ' .. #waypoints .. ' waypoints in a line')
end, false)
-- Clear all waypoints
RegisterCommand('clearwaypoints', function()
Waypoint.removeAll()
print('All waypoints cleared')
end, false)
else
-------------------------------------------------
-- Server Test Commands
-------------------------------------------------
local Waypoint = require 'server.modules.Waypoint'
RegisterCommand('sv_testwaypoint', function(source)
if source == 0 then
print('This command must be run by a player')
return
end
local ped = GetPlayerPed(source)
local coords = GetEntityCoords(ped)
local testPos = vector3(coords.x, coords.y + 50.0, coords.z)
local id = Waypoint.create(source, {
coords = testPos,
type = 'checkpoint',
color = '#4ecdc4',
label = 'SERVER WAYPOINT',
size = 1.0,
drawDistance = 500.0,
groundZ = coords.z,
})
print(('Created server waypoint %d for player %d'):format(id, source))
SetTimeout(30000, function()
Waypoint.remove(id)
print(('Removed server waypoint %d'):format(id))
end)
end, false)
-- Test waypoint for all players
RegisterCommand('sv_testwaypointall', function(source)
local coords = vector3(0, 0, 72) -- Center of map
local id = Waypoint.create(-1, {
coords = coords,
type = 'checkpoint',
color = '#9b59b6',
label = 'GLOBAL WAYPOINT',
size = 1.0,
drawDistance = 5000.0,
groundZ = 70.0,
})
print(('Created global server waypoint %d'):format(id))
SetTimeout(60000, function()
Waypoint.remove(id)
print(('Removed global server waypoint %d'):format(id))
end)
end, true) -- Admin only
end