-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.lua
executable file
·66 lines (60 loc) · 2.36 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
Citizen.CreateThread(function ()
local playerserverid = GetPlayerServerId(PlayerId())
while true do
local playerped = GetPlayerPed(-1)
if playerserverid == nil then
playerserverid = GetPlayerServerId(PlayerId())
end
Citizen.Wait(250)
-- 获得玩家坐标
local crood = GetEntityCoords(playerped)
local croodx = crood.x
local croody = crood.y
local croodz = crood.z
-- print (croodx, croody, croodz)
-- local retval , speedx, speedy =GetPedCurrentMovementSpeed(playerped)
-- -- 仅计算水平速度
-- print (speedx, speedy)
-- local speed = math.sqrt(speedx*speedx + speedy*speedy)
-- print (speed)
local speed = GetEntitySpeed(playerped)
local speedinknot = math.floor(speed * 1.9438444924574) or 0
-- 如果玩家在飞机上
local inplane = IsPedInAnyPlane(playerped)
local playername = GetPlayerName(PlayerId())
-- 获得玩家航向
local heading = GetEntityHeading(playerped)
--获得玩家载具的model
local vehicle = GetVehiclePedIsIn(playerped, false)
--获得载具名字
local vehiclemodel = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
-- print (vehiclemodel)
-- 检查数据,必须都不是nil
-- print("name" .. playername)
if not (playerserverid == nil or playername == nil) then
TriggerServerEvent('webmap:senddata', croodx, croody, croodz, speedinknot, inplane, playerserverid, playername, heading, vehiclemodel)
end
end
end)
-- RegisterNUICallback('checkplayer', function(data, cb)
-- -- print (json.encode(data))
-- if GetPlayerFromServerId(data) ~= -1 then
-- -- print ("player exists")
-- cb(true)
-- else
-- -- print ("player not exists")
-- cb(false)
-- end
-- end)
-- 给webmap发送数据
RegisterCommand('ATC', function(source, args, rawCommand)
-- for ipairs, v in ipairs(args) do
-- print (v)
-- end
local playerserverid = GetPlayerServerId(PlayerId())
TriggerServerEvent('webmap:ATC', args,playerserverid)
end, false)
RegisterCommand ('ident', function(source, args, rawCommand)
local playerserverid = GetPlayerServerId(PlayerId())
TriggerServerEvent('webmap:ident', playerserverid)
end, false)