RageUI.IsVisible(subMenuListesJoueurs, function()
for k,v in pairs(listejoueur) do
RageUI.Button(v[1], description, {RightLabel = "ID : "..v[2]}, true, {onSelected = function()
nameUser = v[1]
idUser = v[2]
end}, subMenuListeCommandes);
end
end, function() end)
RageUI.IsVisible(subMenuListeCommandes, function()
RageUI.Button("Teleporter au joueur", "Se téléporter au joueur", {}, true, {onSelected = function()
local playerPed = GetPlayerPed(-1)
local targetPed = GetPlayerPed(idUser)
NetworkSetInSpectatorMode(false, playerPed) -- turn off spectator mode just in case
if PlayerId() == idUser then
sendNotification("~r~This player is you !")
elseif not NetworkIsPlayerActive(idUser) then
sendNotification("~r~This player is not in game.")
else
local targetCoords = GetEntityCoords(targetPed)
local targetVeh = GetVehiclePedIsIn(targetPed, False)
local seat = -1
sendNotification("~g~Teleporting to " .. nameUser .. " (Player id " .. idUser .. ").")
if targetVeh then
local numSeats = GetVehicleModelNumberOfSeats(GetEntityModel(targetVeh))
if numSeats > 1 then
for i=0, numSeats do
if seat == -1 and IsVehicleSeatFree(targetveh, i) then
seat = 1
end
end
end
end
if seat == -1 then
SetEntityCoords(playerPed, targetCoords, 1, 0, 0, 1)
else
SetPedIntoVehicle(playerPed, targetVeh, seat)
end
end
end});
end, function() end)