Skip to content
Open
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
75 changes: 73 additions & 2 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ RegisterNetEvent("ND:characterUnloaded")

RegisterNetEvent("ND:clothingMenu", function()
if GetResourceState("fivem-appearance") ~= "started" then return end

local function customize(appearance)
if not appearance then return end
TriggerServerEvent("ND:updateClothing", appearance)
end

exports["fivem-appearance"]:startPlayerCustomization(customize, {
ped = false,
headBlend = true,
Expand All @@ -73,3 +73,74 @@ RegisterNetEvent("ND:clothingMenu", function()
tattoos = true
})
end)

RegisterNetEvent("ND:teleportToMarker", function()
local waypoint = GetFirstBlipInfoId(8)
if not DoesBlipExist(waypoint) then
NDCore.notify({
title = "Error",
description = "There is no waypoint set!",
type = "error"
})
return
end

-- Fade out the screen for teleporting
DoScreenFadeOut(500)
Wait(600) -- Wait a bit longer than the fade out time to ensure it's fully faded

local ped = PlayerPedId()
local coords = GetBlipInfoIdCoord(waypoint)
local x, y, z = coords.x, coords.y, 0
local ground
local groundFound = false
local groundCheckHeight = 1000.0

for i = 0, 1000 do
SetPedCoordsKeepVehicle(ped, x, y, groundCheckHeight, false, false, false, false)
ground, z = GetGroundZFor_3dCoord(x, y, groundCheckHeight, false)

if ground then
z = z + 1.0
groundFound = true
break
end

groundCheckHeight = groundCheckHeight - 5.0
if groundCheckHeight < 0 then break end

Wait(0)
end

if not groundFound then
return NDCore.notify({
title = "Error",
description = "Could not find ground, please try again!",
type = "error"
})
end

local pedHeading = GetEntityHeading(ped)
SetPedCoordsKeepVehicle(ped, x, y, z, false, false, false, false)
SetEntityHeading(ped, pedHeading)

-- Fade the screen back in after teleportation
Wait(200) -- Small wait to ensure entity is positioned properly
DoScreenFadeIn(800)

NDCore.notify({
title = "Success",
description = "Successfully teleported to waypoint!",
type = "success"
})
end)

RegisterNetEvent("ND:changeWeather", function(weather)
SetWeatherTypeOverTime(weather, 2.0)
Wait(2000)
SetWeatherTypeNowPersist(weather)
end)

RegisterNetEvent("ND:changeTime", function(hours, minutes)
NetworkOverrideClockTime(hours, minutes, 0)
end)
1 change: 1 addition & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ server_scripts {
"@oxmysql/lib/MySQL.lua",
"server/main.lua",
"shared/functions.lua",
"shared/items.lua",
"server/player.lua",
"server/vehicle.lua",
"server/functions.lua",
Expand Down
149 changes: 145 additions & 4 deletions server/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ local moneyActions = {
return ("Set %s's (%s) to $%d"):format(player.name, account, amount), ("set %s to $%d"):format(account, amount)
end
}
local validWeather = {
"clear", "extrasunny", "clouds", "overcast", "rain", "clearing", "thunder", "smog", "foggy", "xmas", "snow", "snowlight", "blizzard", "halloween", "neutral"
}

lib.addCommand("setmoney", {
help = "Admin command, set a players money.",
Expand Down Expand Up @@ -85,7 +88,7 @@ lib.addCommand("setjob", {
}, function(source, args, raw)
local player = NDCore.getPlayer(args.target)
if not player then return end

local job = args.job:lower()
local jobInfo = player.setJob(job, args.rank)
if not player or not jobInfo then return end
Expand Down Expand Up @@ -245,14 +248,14 @@ lib.addCommand("pay", {
duration = 5000
})
end

targetPlayer.notify({
title = "Money received",
description = ("Received $%d in cash"):format(args.amount),
type = "inform",
duration = 5000
})

player.notify({
title = "Money given",
description = ("You gave $%d in cash"):format(args.amount),
Expand Down Expand Up @@ -471,7 +474,7 @@ lib.addCommand("claim-veh", {
type = "error"
})
end

NDCore.setVehicleOwned(targetPlayer.id, properties, true)

player.notify({
Expand All @@ -480,3 +483,141 @@ lib.addCommand("claim-veh", {
type = "success"
})
end)

lib.addCommand("tpm", {
help = "Admin command, teleport to marked location.",
restricted = "group.admin"
}, function(source, args, raw)
TriggerClientEvent("ND:teleportToMarker", source)
end)

lib.addCommand("tp", {
help = "Admin command, teleport to coordinates.",
restricted = "group.admin",
params = {
{
name = "x",
type = "number",
help = "X coordinate"
},
{
name = "y",
type = "number",
help = "Y coordinate"
},
{
name = "z",
type = "number",
help = "Z coordinate"
}
}
}, function(source, args, raw)
if not args or not args.x or not args.y or not args.z then
local player = NDCore.getPlayer(source)
return player.notify({
title = "Error",
description = "No coordinates provided! /tp <x> <y> <z>",
type = "error"
})
end
local ped = GetPlayerPed(source)
SetEntityCoords(ped, tonumber(args.x) + 0.0, tonumber(args.y) + 0.0, tonumber(args.z) + 0.0)
end)

lib.addCommand("weather", {
help = "Admin command, change the weather.",
restricted = "group.admin",
params = {
{
name = "weather",
type = "string",
help = ("Weather Type (%s)"):format(table.concat(validWeather, ", "))
}
}
}, function(source, args, raw)
if not args or not args.weather then
local player = NDCore.getPlayer(source)
return player.notify({
title = "Error",
description = "No weather type provided! /weather <type>",
type = "error"
})
end
local weather = args.weather:lower()

if not lib.table.contains(validWeather, weather) then
local player = NDCore.getPlayer(source)
return player.notify({
title = "Invalid Weather",
description = ("Format: %s"):format(table.concat(validWeather, ", ")),
type = "error"
})
end

TriggerClientEvent("ND:changeWeather", -1, weather)
end)

lib.addCommand("time", {
help = "Admin command, change the time.",
restricted = "group.admin",
params = {
{
name = "hours",
type = "number",
help = "Hours"
},
{
name = "minutes",
type = "number",
help = "Minutes"
},
{
name = "seconds",
type = "number",
help = "Seconds",
optional = true
}
}
}, function(source, args, raw)
if not args or not args.hours or not args.minutes then
local player = NDCore.getPlayer(source)
return player.notify({
title = "Error",
description = "No time provided! /time <hour> <minute>",
type = "error"
})
else
local hours = tonumber(args.hours)
local minutes = tonumber(args.minutes)
local seconds = args.seconds and tonumber(args.seconds) or 0

if not hours or hours < 0 or hours > 23 or
not minutes or minutes < 0 or minutes > 59 or
seconds < 0 or seconds > 59 then
local player = NDCore.getPlayer(source)
return player.notify({
title = "Invalid Time",
description = "Format: /time <hour 0-23> <minute 0-59>",
type = "error"
})
end

TriggerClientEvent("ND:changeTime", -1, hours, minutes, seconds)
end
end)

lib.addCommand("coords", {
help = "Admin command, get your current coordinates.",
restricted = "group.admin"
}, function(source, args, raw)
local ped = GetPlayerPed(source)
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local message = ("Your current coordinates are: x: %.2f, y: %.2f, z: %.2f, w: %.2f"):format(coords.x, coords.y, coords.z, heading)

TriggerClientEvent("chat:addMessage", source, {
color = {65, 105, 225},
multiline = true,
args = {"Coordinates", message}
})
end)
Loading