-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
47 lines (38 loc) · 1.64 KB
/
Copy pathclient.lua
File metadata and controls
47 lines (38 loc) · 1.64 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
RegisterNetEvent("CGC:tpa")
RegisterNetEvent("CGC:tpaccept")
RegisterNetEvent("CGC:tpdeny")
RegisterNetEvent("CGC:teleport")
local requester = nil
TriggerServerEvent("CGC:tpanewplayer")
AddEventHandler("CGC:tpa", function(newRequester, newRequesterName)
requester = newRequester
TriggerEvent("chatMessage", "INFO", {255, 255, 0}, newRequesterName .. " wants to teleport to you.")
TriggerEvent("chatMessage", "INFO", {255, 255, 0}, "/tpaccept or /tpdeny to accept/deny.")
end)
AddEventHandler("CGC:tpaccept", function()
if requester == nil then
TriggerEvent("chatMessage", "ERROR", {255, 0, 0}, "Nobody is requesting to teleport to you at the moment.")
return
end
TriggerServerEvent("CGC:tpastatus", PlayerId(), requester, true)
TriggerEvent("chatMessage", "INFO", {255, 255, 0}, "Accepted teleport.")
requester = nil
end)
AddEventHandler("CGC:tpdeny", function()
if requester == nil then
TriggerEvent("chatMessage", "ERROR", {255, 0, 0}, "Nobody is requesting to teleport to you at the moment.")
return
end
TriggerServerEvent("CGC:tpastatus", PlayerId(), requester, false)
TriggerEvent("chatMessage", "INFO", {255, 255, 0}, "Denied teleport.")
requester = nil
end)
AddEventHandler("CGC:teleport", function(target, accepted)
if not accepted then
TriggerEvent("chatMessage", "INFO", {255, 255, 0}, "Teleport was not accepted.")
return
end
x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(target) , true))
SetEntityCoords(GetPlayerPed(-1), x, y, z, 1, 0, 0, 1)
TriggerEvent("chatMessage", "INFO", {255, 255, 0}, "Teleport was accepted.")
end)