This repository was archived by the owner on May 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_main.lua
93 lines (72 loc) · 2.22 KB
/
server_main.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
root = getRootElement()
resourceRoot = getRootElement(getThisResource())
local trails = {}
function createTrailObject(player, x, y, z, x2, y2, z2)
local centerX, centerY, centerZ = calculateMidpoint3D(x, y, z, x2, y2, z2)
local lowestZ = lowestZ(z, z2) - 1
local distZ = math.abs(z - z2) + 2
local cylCol = createColTube(centerX, centerY, lowestZ, getDistanceBetweenPoints2D(x, y, x2, y2), distZ)
trails[cylCol] = {x, y, z, x2, y2, z2, centerX, centerY, centerZ}
triggerClientEvent(player, "createTrail", root, cylCol, trails[cylCol])
end
function enteredVehicle()
end
function exitedVehicle()
end
function removeTrailObject()
end
function collideCheck()
--this should be called on
end
function serverTick()
triggerEvent("onServerTick", root)
end
function resourceStart()
setDevelopmentMode(true)
end
function resourceStop()
end
function enterColSphere()
triggerClientEvent(player, "startRayChecks", resourceRoot, cylCol)
end
function calculateMidpoint2D(x, y, x2, y2)
return (x+x2)/2, (y+y2)/2
end
function calculateMidpoint3D(x, y, z, x2, y2, z2)
return (x+x2)/2, (y+y2)/2, (z+z2)/2
end
function lowestZ(z, z2)
if z > z2 then
return z2
else
return z
end
end
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
function tableFind(table, element)
for index, value in pairs(table) do
if value == element then
return index
end
end
end
addEventHandler("onResourceStart", resourceRoot, resourceStart)
addEventHandler("onResourceStop", resourceRoot, resourceStop)
addCommandHandler("trailTest", function(player, command)
local x, y, z = getElementPosition(player)
createTrailObject(player, x, y, z, x + 1, y, z + 1)
createTrailObject(player, x + 1, y, z + 1, x + 2, y, z + 1.5)
createTrailObject(player, x + 2, y, z + 1.5, x + 2.5, y + 2, z + 2)
end)
addCommandHandler("devmode", function()setDevelopmentMode(true)end)