Infinity Compatible TP

This commit is contained in:
LoveFistRP
2021-04-23 15:08:50 -07:00
parent e5be45c140
commit c80bd0331b
2 changed files with 12 additions and 15 deletions
+3 -8
View File
@@ -1,13 +1,8 @@
-- QBCore Command Events
RegisterNetEvent('QBCore:Command:TeleportToPlayer')
AddEventHandler('QBCore:Command:TeleportToPlayer', function(othersource)
local coords = QBCore.Functions.GetCoords(GetPlayerPed(GetPlayerFromServerId(othersource)))
local entity = PlayerPedId()
if IsPedInAnyVehicle(entity, false) then
entity = GetVehiclePedIsUsing(entity)
end
SetEntityCoords(entity, coords.x, coords.y, coords.z)
SetEntityHeading(entity, coords.a)
AddEventHandler('QBCore:Command:TeleportToPlayer', function(coords)
local ped = PlayerPedId()
SetPedCoordsKeepVehicle(ped, coords.x, coords.y, coords.z)
end)
RegisterNetEvent('QBCore:Command:TeleportToCoords')
+9 -7
View File
@@ -25,15 +25,17 @@ end
QBCore.Commands.Add("tp", "TP To Player or Coords (Admin Only)", {{name="id/x", help="ID of player or X position"}, {name="y", help="Y position"}, {name="z", help="Z position"}}, false, function(source, args)
if (args[1] ~= nil and (args[2] == nil and args[3] == nil)) then
-- tp to player
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
if Player ~= nil then
TriggerClientEvent('QBCore:Command:TeleportToPlayer', source, Player.PlayerData.source)
else
TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error")
for k,v in ipairs(GetPlayers()) do
local id = args[1]
if v == id then
local target = GetPlayerPed(v)
local coords = GetEntityCoords(target)
TriggerClientEvent('QBCore:Command:TeleportToPlayer', source, coords)
else
TriggerClientEvent('QBCore:Notify', source, "Player is not online!", "error")
end
end
else
-- tp to location
if args[1] ~= nil and args[2] ~= nil and args[3] ~= nil then
local x = tonumber(args[1])
local y = tonumber(args[2])