Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(es_extended/server/modules/commands): add /setdim cmd #1526

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions [core]/es_extended/locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ Locales["en"] = {
["commanderror_invalidcommand"] = "Invalid Command - /%s",
["commanderror_invalidplayerid"] = "Specified Player is not online",
["commandgeneric_playerid"] = "Player`s Server Id",
["commandgeneric_dimension"] = "Target Dimension",
["command_giveammo_noweapon_found"] = "%s does not have that weapon",
["command_giveammo_weapon"] = "Weapon name",
["command_giveammo_ammo"] = "Ammo Quantity",
["command_setdim"] = "Set a players dimension",
["tpm_nowaypoint"] = "No Waypoint Set.",
["tpm_success"] = "Successfully Teleported",

Expand Down
4 changes: 2 additions & 2 deletions [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@ function ESX.GetExtendedPlayers(key, val)

local xPlayers = {}
if type(val) == "table" then
for i, xPlayer in pairs(ESX.Players) do
for _, xPlayer in pairs(ESX.Players) do
checkTable(key, val, xPlayer, xPlayers)
end

return xPlayers
end

for i, xPlayer in pairs(ESX.Players) do
for _, xPlayer in pairs(ESX.Players) do
if (key == "job" and xPlayer.job.name == val) or xPlayer[key] == val then
xPlayers[#xPlayers + 1] = xPlayer
end
Expand Down
37 changes: 37 additions & 0 deletions [core]/es_extended/server/modules/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,12 @@ ESX.RegisterCommand(
"admin",
function(xPlayer, args)
local targetCoords = args.playerId.getCoords()
local srcDim = GetPlayerRoutingBucket(xPlayer.source)
local targetDim = GetPlayerRoutingBucket(args.playerId.source)

if srcDim ~= targetDim then
SetPlayerRoutingBucket(xPlayer.source, targetDim)
end
xPlayer.setCoords(targetCoords)
if Config.AdminLogging then
ESX.DiscordLogFields("UserActions", "Admin Teleport /goto Triggered!", "pink", {
Expand All @@ -619,6 +625,12 @@ ESX.RegisterCommand(
function(xPlayer, args)
local targetCoords = args.playerId.getCoords()
local playerCoords = xPlayer.getCoords()
local targetDim = GetPlayerRoutingBucket(args.playerId.source)
local srcDim = GetPlayerRoutingBucket(xPlayer.source)

if targetDim ~= srcDim then
SetPlayerRoutingBucket(args.playerId.source, srcDim)
end
args.playerId.setCoords(playerCoords)
if Config.AdminLogging then
ESX.DiscordLogFields("UserActions", "Admin Teleport /bring Triggered!", "pink", {
Expand Down Expand Up @@ -726,3 +738,28 @@ ESX.RegisterCommand("players", "admin", function()
print(("^1[^2ID: ^5%s^0 | ^2Name : ^5%s^0 | ^2Group : ^5%s^0 | ^2Identifier : ^5%s^1]^0\n"):format(xPlayer.source, xPlayer.getName(), xPlayer.getGroup(), xPlayer.identifier))
end
end, true)

ESX.RegisterCommand(
{"setdim", "setbucket"},
"admin",
function(xPlayer, args)
SetPlayerRoutingBucket(args.playerId.source, args.dimension)
if Config.AdminLogging then
ESX.DiscordLogFields("UserActions", "Admin Set Dim /setdim Triggered!", "pink", {
{ name = "Player", value = xPlayer and xPlayer.name or "Server Console", inline = true },
{ name = "ID", value = xPlayer and xPlayer.source or "Unknown ID", inline = true },
{ name = "Target", value = args.playerId.name, inline = true },
{ name = "Dimension", value = args.dimension, inline = true },
})
end
end,
true,
{
help = TranslateCap("command_setdim"),
validate = true,
arguments = {
{ name = "playerId", help = TranslateCap("commandgeneric_playerid"), type = "player" },
{ name = "dimension", help = TranslateCap("commandgeneric_dimension"), type = "number" },
},
}
)
Loading