-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
54 lines (45 loc) · 2.07 KB
/
server.lua
File metadata and controls
54 lines (45 loc) · 2.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
--------------------------------------------------------------------------------------------------
heartbeat = {}
function getElementGroundPosition ( element, px, py, pz, height, callBack )
if not heartbeat.getGround then heartbeat.getGround = {} end
if heartbeat.getGround[ element ] then return false end
local x, y, z = px, py, pz
heartbeat.getGround[ element ] = assetify.thread:createHeartbeat(
function ( )
x, y, z = assetify.thread:getThread():await(
assetify.network:emitCallback("getGroundPositionFromServer", true, false, element, px, py, pz, height)
)
return false
end,
function ( ... )
if callBack then
local getType = type( callBack )
if getType == "function" then -- ใช้สำหรับภายใน resource นี้ / use for this resource
callBack( x, y, z, height )
elseif getType == "string" then -- ใช้สำหรับ resource อื่น / use for other resource
triggerEvent( callBack, element, x, y, z, height )
end
end
heartbeat.getGround[ element ] = nil
end,
1000 * 1
)
end
-- ใช้จาก resource นี้
local tx, ty, ty = 0, 0, 3
local height = 0.5
getElementGroundPosition ( player, tx, ty, ty, height, function ( x, y, z, height )
outputChatBox( "Ground Position: " .. x .. ", " .. y .. ", " .. z .. ", Height: " .. height, player )
end
)
-- ใช้จาก resource นี้และอื่นๆ
local tx, ty, ty = 0, 0, 3
local height = 0.5
getElementGroundPosition ( player, tx, ty, ty, height, "callBackEvent:getGroundPosition" )
addEvent( "callBackEvent:getGroundPosition", true )
addEventHandler( "callBackEvent:getGroundPosition", root,
function ( x, y, z, height )
outputChatBox( "Ground Position: " .. x .. ", " .. y .. ", " .. z .. ", Height: " .. height, source )
end
)
--------------------------------------------------------------------------------------------------