mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
544ad64779 | ||
|
|
43f690e356 | ||
|
|
e883c4e64f | ||
|
|
5928d89edf | ||
|
|
9b846dc07e | ||
|
|
baac4c75dd | ||
|
|
fb708cc7e7 | ||
|
|
1547d310eb | ||
|
|
9d4708f6d9 | ||
|
|
a7713804f0 | ||
|
|
a9785ce754 | ||
|
|
fe922e1b98 | ||
|
|
b97f42bb0a | ||
|
|
d132c12025 | ||
|
|
119b0034bf | ||
|
|
622b6fa8b0 | ||
|
|
2e6dfa9e5f | ||
|
|
4c4166de94 | ||
|
|
dea7ac6c8f | ||
|
|
120d924cae | ||
|
|
2a263a6c2e | ||
|
|
4ff4f487a1 | ||
|
|
e26821841b | ||
|
|
e9aafe1f2d | ||
|
|
6987bb63ae | ||
|
|
e0c4a8419b | ||
|
|
66f93bde14 | ||
|
|
2460df2f34 | ||
|
|
b79bb6ec7f | ||
|
|
eef1bb60f5 | ||
|
|
1320c4ab7d | ||
|
|
2c7aa5723a | ||
|
|
97a8b991ae | ||
|
|
2a3ac3b63b | ||
|
|
5d3c051149 | ||
|
|
fc82b217e9 | ||
|
|
284411ce66 | ||
|
|
a7257cf68f | ||
|
|
841a5771c5 | ||
|
|
8fd7878ba6 | ||
|
|
60e86d2038 | ||
|
|
626f0ad06f | ||
|
|
d5c3acbd81 | ||
|
|
98cba87bec | ||
|
|
001fc22ef6 | ||
|
|
87420e99e9 | ||
|
|
c5597161d9 | ||
|
|
898b9aefe9 | ||
|
|
5545650dd5 | ||
|
|
f4f01a5b1c | ||
|
|
3252118f93 | ||
|
|
9d4708a1f8 | ||
|
|
d0d04ae282 | ||
|
|
c005c1b28b | ||
|
|
590044b5d6 | ||
|
|
3146172c0c | ||
|
|
2ce47ef8d1 | ||
|
|
6258651d8b | ||
|
|
eecbc8f690 | ||
|
|
1d25b54e0f | ||
|
|
e18389a52a | ||
|
|
539e522373 | ||
|
|
2bacdd2a20 | ||
|
|
6242a44c0b | ||
|
|
74e4ccc2de | ||
|
|
2fda7655b5 | ||
|
|
ade82436a5 | ||
|
|
f512d0ed0c | ||
|
|
0a19fe8a33 | ||
|
|
2882c7c1ae | ||
|
|
6291690bd4 | ||
|
|
af82c447c1 |
@@ -29,14 +29,13 @@ AddEventHandler("gameEventTriggered", function(name, args)
|
|||||||
local victim = args[1]
|
local victim = args[1]
|
||||||
if not IsPedAPlayer(victim) or NetworkGetPlayerIndexFromPed(victim) ~= cache.playerId then return end
|
if not IsPedAPlayer(victim) or NetworkGetPlayerIndexFromPed(victim) ~= cache.playerId then return end
|
||||||
|
|
||||||
if not IsPedDeadOrDying(victim, true) then
|
local hit, bone = GetPedLastDamageBone(victim)
|
||||||
local hit, bone = GetPedLastDamageBone(victim)
|
if hit and usingAmbulance then
|
||||||
if hit and usingAmbulance then
|
local damageWeapon = ambulance:getLastDamagingWeapon(victim)
|
||||||
local damageWeapon = ambulance:getLastDamagingWeapon(victim)
|
ambulance:updateBodyDamage(bone, damageWeapon)
|
||||||
return damageWeapon and ambulance:updateBodyDamage(bone, damageWeapon)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not IsPedDeadOrDying(victim, true) or GetEntityHealth(victim) > 100 then return end
|
||||||
|
|
||||||
local killerEntity, deathCause = GetPedSourceOfDeath(cache.ped), GetPedCauseOfDeath(cache.ped)
|
local killerEntity, deathCause = GetPedSourceOfDeath(cache.ped), GetPedCauseOfDeath(cache.ped)
|
||||||
local killerClientId = NetworkGetPlayerIndexFromPed(killerEntity)
|
local killerClientId = NetworkGetPlayerIndexFromPed(killerEntity)
|
||||||
|
|||||||
@@ -22,5 +22,54 @@ RegisterNetEvent("ND:updateLastLocation", function(location)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("ND:revivePlayer", function()
|
RegisterNetEvent("ND:revivePlayer", function()
|
||||||
NDCore.revivePlayer(true)
|
if source == "" then return end
|
||||||
|
local oldPed = cache.ped
|
||||||
|
local veh = GetVehiclePedIsIn(oldPed)
|
||||||
|
local seat = cache.seat
|
||||||
|
local coords = GetEntityCoords(oldPed)
|
||||||
|
local armor = GetPedArmour(oldPed)
|
||||||
|
|
||||||
|
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, GetEntityHeading(oldPed), true, true, false)
|
||||||
|
|
||||||
|
local ped = PlayerPedId()
|
||||||
|
if oldPed ~= ped then
|
||||||
|
DeleteEntity(oldPed)
|
||||||
|
ClearAreaOfPeds(coords.x, coords.y, coords.z, 0.2, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
SetEntityInvincible(ped, false)
|
||||||
|
FreezeEntityPosition(ped, false)
|
||||||
|
SetEntityVisible(ped, true)
|
||||||
|
SetEveryoneIgnorePlayer(ped, false)
|
||||||
|
SetPedCanBeTargetted(ped, true)
|
||||||
|
SetEntityCanBeDamaged(ped, true)
|
||||||
|
SetBlockingOfNonTemporaryEvents(ped, false)
|
||||||
|
SetPedCanRagdollFromPlayerImpact(ped, true)
|
||||||
|
ClearPedTasksImmediately(ped)
|
||||||
|
SetPedArmour(ped, armor)
|
||||||
|
|
||||||
|
if veh and veh ~= 0 then
|
||||||
|
SetPedIntoVehicle(ped, veh, seat)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
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,
|
||||||
|
faceFeatures = true,
|
||||||
|
headOverlays = true,
|
||||||
|
components = true,
|
||||||
|
props = true,
|
||||||
|
tattoos = true
|
||||||
|
})
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -33,56 +33,8 @@ function NDCore.getConfig(info)
|
|||||||
return Config[info]
|
return Config[info]
|
||||||
end
|
end
|
||||||
|
|
||||||
function NDCore.revivePlayer(reset, keepDead)
|
|
||||||
local usingAmbulance = GetResourceState("ND_Ambulance") == "started"
|
|
||||||
if not keepDead then
|
|
||||||
LocalPlayer.state.dead = false
|
|
||||||
if usingAmbulance then
|
|
||||||
local state = Player(cache.serverId).state
|
|
||||||
state:set("isDead", false, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local veh = GetVehiclePedIsIn(cache.ped)
|
|
||||||
local seat = cache.seat
|
|
||||||
local coords = GetEntityCoords(cache.ped)
|
|
||||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, GetEntityHeading(cache.ped), true, true, false)
|
|
||||||
|
|
||||||
local ped = PlayerPedId()
|
|
||||||
if cache.ped ~= ped then
|
|
||||||
DeleteEntity(cache.ped)
|
|
||||||
ClearAreaOfPeds(coords.x, coords.y, coords.z, 0.2, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
SetEntityInvincible(ped, false)
|
|
||||||
FreezeEntityPosition(ped, false)
|
|
||||||
SetEntityVisible(ped, true)
|
|
||||||
SetEveryoneIgnorePlayer(ped, false)
|
|
||||||
SetPedCanBeTargetted(ped, true)
|
|
||||||
SetEntityCanBeDamaged(ped, true)
|
|
||||||
SetBlockingOfNonTemporaryEvents(ped, false)
|
|
||||||
SetPedCanRagdollFromPlayerImpact(ped, true)
|
|
||||||
ClearPedTasksImmediately(ped)
|
|
||||||
|
|
||||||
if veh and veh ~= 0 then
|
|
||||||
SetPedIntoVehicle(ped, veh, seat)
|
|
||||||
end
|
|
||||||
if reset and GetPedMovementClipset(ped) == `move_m@injured` then
|
|
||||||
ClearEntityLastDamageEntity(ped)
|
|
||||||
SetPedMoveRateOverride(ped, 1.0)
|
|
||||||
ResetPedMovementClipset(ped, 0)
|
|
||||||
end
|
|
||||||
if reset and usingAmbulance then
|
|
||||||
exports["ND_Ambulance"]:resetBodyDamage()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NDCore.notify(...)
|
function NDCore.notify(...)
|
||||||
if GetResourceState("ModernHUD") == "started" then
|
lib.notify(...)
|
||||||
exports["ModernHUD"]:notify(...)
|
|
||||||
elseif GetResourceState("ox_lib") == "started" then
|
|
||||||
lib.notify(...)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, func in pairs(NDCore) do
|
for name, func in pairs(NDCore) do
|
||||||
|
|||||||
@@ -7,14 +7,16 @@ Config = {
|
|||||||
discordAsset = GetConvar("core:discordAsset", "andyyy"),
|
discordAsset = GetConvar("core:discordAsset", "andyyy"),
|
||||||
discordAssetSmall = GetConvar("core:discordAssetSmall", "andyyy"),
|
discordAssetSmall = GetConvar("core:discordAssetSmall", "andyyy"),
|
||||||
discordActionText = GetConvar("core:discordActionText", "DISCORD"),
|
discordActionText = GetConvar("core:discordActionText", "DISCORD"),
|
||||||
discordActionLink = GetConvar("discordActionLink", "https://discord.gg/Z9Mxu72zZ6"),
|
discordActionLink = GetConvar("core:discordActionLink", "https://discord.gg/Z9Mxu72zZ6"),
|
||||||
discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
|
discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
|
||||||
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
|
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
|
||||||
randomUnlockedVehicleChance = GetConvarInt("core:randomUnlockedVehicleChance", 30),
|
|
||||||
disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1,
|
disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1,
|
||||||
|
randomUnlockedVehicleChance = GetConvarInt("core:randomUnlockedVehicleChance", 30),
|
||||||
|
requireKeys = GetConvarInt("core:requireKeys", 1) == 1,
|
||||||
useInventoryForKeys = GetConvarInt("core:useInventoryForKeys", 1) == 1,
|
useInventoryForKeys = GetConvarInt("core:useInventoryForKeys", 1) == 1,
|
||||||
groups = json.decode(GetConvar("core:groups", "[]")),
|
groups = json.decode(GetConvar("core:groups", "[]")),
|
||||||
compatibility = json.decode(GetConvar("core:compatibility", "[]"))
|
compatibility = json.decode(GetConvar("core:compatibility", "[]")),
|
||||||
|
lockpickTries = GetConvarInt("core:lockpickTries", 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Discord rich presence.
|
-- Discord rich presence.
|
||||||
|
|||||||
@@ -218,10 +218,10 @@ end)
|
|||||||
RegisterCommand("getclothing", function(source, args, rawCommand)
|
RegisterCommand("getclothing", function(source, args, rawCommand)
|
||||||
local info = ""
|
local info = ""
|
||||||
for k, v in pairs(clothingComponents) do
|
for k, v in pairs(clothingComponents) do
|
||||||
info = ("%s\n%s = {\n drawable = %s,\n texture = %s\n},"):format(info, k, GetPedDrawableVariation(cache.ped, v), GetPedTextureVariation(cache.ped, v))
|
info = ("%s\n%s = { drawable = %s, texture = %s },"):format(info, k, GetPedDrawableVariation(cache.ped, v), GetPedTextureVariation(cache.ped, v))
|
||||||
end
|
end
|
||||||
for k, v in pairs(clothingProps) do
|
for k, v in pairs(clothingProps) do
|
||||||
info = ("%s\n%s = {\n drawable = %s,\n texture = %s\n},"):format(info, k, GetPedPropIndex(cache.ped, v), GetPedPropTextureIndex(cache.ped, v))
|
info = ("%s\n%s = { drawable = %s, texture = %s },"):format(info, k, GetPedPropIndex(cache.ped, v), GetPedPropTextureIndex(cache.ped, v))
|
||||||
end
|
end
|
||||||
lib.setClipboard(info)
|
lib.setClipboard(info)
|
||||||
end, false)
|
end, false)
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
return {
|
return {
|
||||||
|
{
|
||||||
|
garageType = "land",
|
||||||
|
groups = {"lsfd"},
|
||||||
|
ped = vector4(370.9027, -593.8090, 28.8681, 73.6009),
|
||||||
|
vehicleSpawns = {
|
||||||
|
vec4(366.7840, -591.4883, 28.7261, 339.6823),
|
||||||
|
vec4(365.0753, -582.8641, 28.7156, 135.0064),
|
||||||
|
vec4(357.4239, -604.7719, 28.6767, 177.1355),
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
garageType = "land",
|
garageType = "land",
|
||||||
groups = {"sahp", "lspd", "bcso"},
|
groups = {"sahp", "lspd", "bcso"},
|
||||||
@@ -240,4 +250,52 @@ return {
|
|||||||
vector4(216.56, -801.90, 30.79, 69.39)
|
vector4(216.56, -801.90, 30.79, 69.39)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
garageType = "land",
|
||||||
|
ped = vector4(587.5941, 2744.2844, 42.0691, 181.0514),
|
||||||
|
vehicleSpawns = {
|
||||||
|
vector4(584.3921, 2721.3599, 41.6483, 184.3260),
|
||||||
|
vector4(577.1069, 2736.2322, 41.6097, 184.6912),
|
||||||
|
vector4(577.9459, 2721.0010, 41.6481, 185.1414),
|
||||||
|
vector4(574.1685, 2735.7288, 41.6397, 184.5562)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
garageType = "land",
|
||||||
|
ped = vector4(2746.1726, 3458.7378, 55.8272, 245.1009),
|
||||||
|
vehicleSpawns = {
|
||||||
|
vector4(2768.2136, 3456.2710, 55.2840, 67.7897),
|
||||||
|
vector4(2759.3218, 3451.1448, 55.4786, 248.0150),
|
||||||
|
vector4(2763.6526, 3445.0544, 55.4741, 66.9754),
|
||||||
|
vector4(2787.2947, 3467.1001, 54.9407, 247.4356),
|
||||||
|
vector4(2773.9514, 3471.6238, 55.0407, 246.8264)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
garageType = "land",
|
||||||
|
ped = vector4(120.4042, 6623.5190, 31.9593, 228.8283),
|
||||||
|
vehicleSpawns = {
|
||||||
|
vector4(155.9047, 6593.3252, 31.4343, 359.3789),
|
||||||
|
vector4(155.7900, 6602.6978, 31.4463, 358.8232),
|
||||||
|
vector4(145.8267, 6614.0996, 31.4007, 178.7948),
|
||||||
|
vector4(145.6977, 6602.8950, 31.4397, 181.0616),
|
||||||
|
vector4(132.4042, 6585.2139, 31.5501, 91.0906)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
garageType = "heli",
|
||||||
|
groups = {"lspd"},
|
||||||
|
ped = vector4(465.6194, -985.4730, 43.6918, 0.8591),
|
||||||
|
vehicleSpawns = {
|
||||||
|
vector4(449.3105, -981.1057, 44.0788, 359.6042)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
garageType = "heli",
|
||||||
|
groups = {"lsfd"},
|
||||||
|
ped = vector4(339.6271, -581.0325, 74.1656, 267.8232),
|
||||||
|
vehicleSpawns = {
|
||||||
|
vector4(351.3463, -588.1304, 74.1698, 108.5617)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -293,6 +293,7 @@ AddStateBagChangeHandler("props", nil, function(bagName, key, value, reserved, r
|
|||||||
lib.setVehicleProperties(entity, props)
|
lib.setVehicleProperties(entity, props)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local playingKey = 0
|
||||||
local function playKeyFob(veh)
|
local function playKeyFob(veh)
|
||||||
local keyFob
|
local keyFob
|
||||||
local ped = cache.ped
|
local ped = cache.ped
|
||||||
@@ -300,12 +301,21 @@ local function playKeyFob(veh)
|
|||||||
if #(coords-GetEntityCoords(veh)) > 25.0 then return end
|
if #(coords-GetEntityCoords(veh)) > 25.0 then return end
|
||||||
|
|
||||||
if not playerVehicle then
|
if not playerVehicle then
|
||||||
|
playingKey += 1
|
||||||
|
SetPedCurrentWeaponVisible(ped, false, false)
|
||||||
ClearPedTasks(ped)
|
ClearPedTasks(ped)
|
||||||
lib.requestAnimDict("anim@mp_player_intmenu@key_fob@")
|
lib.requestAnimDict("anim@mp_player_intmenu@key_fob@")
|
||||||
TaskPlayAnim(ped, "anim@mp_player_intmenu@key_fob@", "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false)
|
TaskPlayAnim(ped, "anim@mp_player_intmenu@key_fob@", "fob_click_fp", 8.0, 8.0, -1, 48, 1, false, false, false)
|
||||||
keyFob = CreateObject(`lr_prop_carkey_fob`, 0, 0, 0, true, true, true)
|
keyFob = CreateObject(`lr_prop_carkey_fob`, 0, 0, 0, true, true, true)
|
||||||
AttachEntityToEntity(keyFob, ped, GetPedBoneIndex(ped, 0xDEAD), 0.12, 0.04, -0.025, -100.0, 100.0, 0.0, true, true, false, true, 1, true)
|
AttachEntityToEntity(keyFob, ped, GetPedBoneIndex(ped, 0xDEAD), 0.12, 0.04, -0.025, -100.0, 100.0, 0.0, true, true, false, true, 1, true)
|
||||||
Wait(700)
|
Wait(700)
|
||||||
|
SetTimeout(400, function()
|
||||||
|
playingKey -= 1
|
||||||
|
end)
|
||||||
|
SetTimeout(1200, function()
|
||||||
|
if playingKey > 0 then return end
|
||||||
|
SetPedCurrentWeaponVisible(ped, true, false)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
PlaySoundFromEntity(-1, "Remote_Control_Fob", ped, "PI_Menu_Sounds", true, 0)
|
PlaySoundFromEntity(-1, "Remote_Control_Fob", ped, "PI_Menu_Sounds", true, 0)
|
||||||
@@ -346,8 +356,9 @@ AddStateBagChangeHandler("locked", nil, function(bagName, key, value, reserved,
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
lib.callback.register("ND_Vehicles:getProps", function(netId)
|
local function getProps(veh)
|
||||||
local veh = getVehFromNetId(netId)
|
if not veh or not DoesEntityExist(veh) then return end
|
||||||
|
|
||||||
local props = lib.getVehicleProperties(veh)
|
local props = lib.getVehicleProperties(veh)
|
||||||
local colorPrimary, colorSecondary = GetVehicleColours(veh)
|
local colorPrimary, colorSecondary = GetVehicleColours(veh)
|
||||||
if not props then return end
|
if not props then return end
|
||||||
@@ -358,7 +369,18 @@ lib.callback.register("ND_Vehicles:getProps", function(netId)
|
|||||||
props.className = vehicleClassNames[GetVehicleClass(veh)]
|
props.className = vehicleClassNames[GetVehicleClass(veh)]
|
||||||
props.makeName = GetLabelText(GetMakeNameFromVehicleModel(props.model))
|
props.makeName = GetLabelText(GetMakeNameFromVehicleModel(props.model))
|
||||||
props.modelName = GetLabelText(GetDisplayNameFromVehicleModel(props.model))
|
props.modelName = GetLabelText(GetDisplayNameFromVehicleModel(props.model))
|
||||||
|
|
||||||
return props
|
return props
|
||||||
|
end
|
||||||
|
|
||||||
|
lib.callback.register("ND_Vehicles:getProps", function(netId)
|
||||||
|
local veh = getVehFromNetId(netId)
|
||||||
|
return getProps(veh)
|
||||||
|
end)
|
||||||
|
|
||||||
|
lib.callback.register("ND_Vehicles:getPropsFromCurrentVeh", function()
|
||||||
|
local veh = GetVehiclePedIsIn(cache.ped)
|
||||||
|
return getProps(veh)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
lib.callback.register("ND_Vehicles:getVehicleModelMakeLabel", function(model)
|
lib.callback.register("ND_Vehicles:getVehicleModelMakeLabel", function(model)
|
||||||
@@ -470,22 +492,35 @@ CreateThread(function()
|
|||||||
local wait = 500
|
local wait = 500
|
||||||
while true do
|
while true do
|
||||||
Wait(wait)
|
Wait(wait)
|
||||||
|
|
||||||
|
local reset = true
|
||||||
playerVehicle = cache.seat == -1 and cache.vehicle
|
playerVehicle = cache.seat == -1 and cache.vehicle
|
||||||
if playerVehicle then
|
|
||||||
if Config.disableVehicleAirControl and not vehicleClassNotDisableAirControl[GetVehicleClass(playerVehicle)] and (IsEntityInAir(playerVehicle) or IsEntityUpsidedown(playerVehicle)) then
|
local entering = GetVehiclePedIsEntering(cache.ped)
|
||||||
wait = 0
|
if entering and DoesEntityExist(entering) and IsVehicleNeedsToBeHotwired(entering) then
|
||||||
DisableControlAction(0, 59) -- disable vehicle air control.
|
SetVehicleNeedsToBeHotwired(entering, false)
|
||||||
DisableControlAction(0, 60)
|
end
|
||||||
elseif not GetIsVehicleEngineRunning(playerVehicle) and not hasVehicleKeysCheck(playerVehicle) then
|
|
||||||
wait = 0
|
if not playerVehicle then goto skip end
|
||||||
DisableControlAction(0, 59)
|
|
||||||
if DoesEntityExist(playerVehicle) and IsVehicleEngineStarting(playerVehicle) then
|
if Config.disableVehicleAirControl and not vehicleClassNotDisableAirControl[GetVehicleClass(playerVehicle)] and (IsEntityInAir(playerVehicle) or IsEntityUpsidedown(playerVehicle)) then
|
||||||
SetVehicleEngineOn(playerVehicle, false, true, true) -- don't turn on engine if no keys.
|
wait = 0
|
||||||
end
|
reset = false
|
||||||
else
|
DisableControlAction(0, 59) -- disable vehicle air control.
|
||||||
wait = 500
|
DisableControlAction(0, 60)
|
||||||
|
end
|
||||||
|
if Config.requireKeys and not GetIsVehicleEngineRunning(playerVehicle) and not hasVehicleKeysCheck(playerVehicle) then
|
||||||
|
wait = 0
|
||||||
|
reset = false
|
||||||
|
DisableControlAction(0, 59)
|
||||||
|
DisableControlAction(0, 71)
|
||||||
|
if DoesEntityExist(playerVehicle) and IsVehicleEngineStarting(playerVehicle) then
|
||||||
|
SetVehicleEngineOn(playerVehicle, false, true, true) -- don't turn on engine if no keys.
|
||||||
end
|
end
|
||||||
elseif wait ~= 500 then
|
end
|
||||||
|
|
||||||
|
::skip::
|
||||||
|
if (reset or not playerVehicle) and wait ~= 500 then
|
||||||
wait = 500
|
wait = 500
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -574,7 +609,7 @@ local function lockpickVehicle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
lib.requestAnimDict("veh@break_in@0h@p_m_one@")
|
lib.requestAnimDict("veh@break_in@0h@p_m_one@")
|
||||||
for i=1, 7 do
|
for i=1, Config.lockpickTries do
|
||||||
TaskPlayAnimAdvanced(cache.ped, "veh@break_in@0h@p_m_one@", "std_force_entry_ds", pos.x, pos.y, pos.z+0.025, rot.x, rot.y, rot.z, 8.0, 8.0, 1800, 28, 0.1)
|
TaskPlayAnimAdvanced(cache.ped, "veh@break_in@0h@p_m_one@", "std_force_entry_ds", pos.x, pos.y, pos.z+0.025, rot.x, rot.y, rot.z, 8.0, 8.0, 1800, 28, 0.1)
|
||||||
local dificulty = dificulties[math.random(1, #dificulties)]
|
local dificulty = dificulties[math.random(1, #dificulties)]
|
||||||
local success = lib.skillCheck(dificulty)
|
local success = lib.skillCheck(dificulty)
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
CREATE TABLE IF NOT EXISTS `nd_characters` (
|
CREATE TABLE IF NOT EXISTS `nd_characters` (
|
||||||
`charid` INT(10) NOT NULL AUTO_INCREMENT,
|
`charid` INT(10) NOT NULL AUTO_INCREMENT,
|
||||||
`identifier` VARCHAR(200) NOT NULL DEFAULT '0',
|
`identifier` VARCHAR(200) NOT NULL DEFAULT '0',
|
||||||
`name` VARCHAR(50) DEFAULT NULL,
|
`name` VARCHAR(50) DEFAULT NULL,
|
||||||
`firstname` VARCHAR(50) DEFAULT NULL,
|
`firstname` VARCHAR(50) DEFAULT NULL,
|
||||||
`lastname` VARCHAR(50) DEFAULT NULL,
|
`lastname` VARCHAR(50) DEFAULT NULL,
|
||||||
`dob` VARCHAR(50) DEFAULT NULL,
|
`dob` VARCHAR(50) DEFAULT NULL,
|
||||||
`gender` VARCHAR(50) DEFAULT NULL,
|
`gender` VARCHAR(50) DEFAULT NULL,
|
||||||
`cash` INT(10) DEFAULT '0',
|
`cash` INT(10) DEFAULT '0',
|
||||||
`bank` INT(10) DEFAULT '0',
|
`bank` INT(10) DEFAULT '0',
|
||||||
`groups` LONGTEXT DEFAULT ('[]'),
|
`phonenumber` VARCHAR(20) DEFAULT NULL,
|
||||||
`metadata` LONGTEXT DEFAULT ('[]'),
|
`groups` LONGTEXT DEFAULT ('[]'),
|
||||||
`inventory` LONGTEXT DEFAULT ('[]'),
|
`metadata` LONGTEXT DEFAULT ('[]'),
|
||||||
PRIMARY KEY (`charid`) USING BTREE
|
`inventory` LONGTEXT DEFAULT ('[]'),
|
||||||
|
PRIMARY KEY (`charid`) USING BTREE
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
CREATE TABLE IF NOT EXISTS `nd_vehicles` (
|
CREATE TABLE IF NOT EXISTS `nd_vehicles` (
|
||||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
`owner` INT(11) DEFAULT NULL,
|
`owner` INT(11) DEFAULT NULL,
|
||||||
`plate` VARCHAR(255) DEFAULT NULL,
|
`plate` VARCHAR(255) DEFAULT NULL,
|
||||||
`glovebox` LONGTEXT DEFAULT ('[]'),
|
`glovebox` LONGTEXT DEFAULT ('[]'),
|
||||||
`trunk` LONGTEXT DEFAULT ('[]'),
|
`trunk` LONGTEXT DEFAULT ('[]'),
|
||||||
`properties` LONGTEXT DEFAULT ('[]'),
|
`properties` LONGTEXT DEFAULT ('[]'),
|
||||||
`stored` INT(11) DEFAULT '1',
|
`stored` INT(11) DEFAULT '1',
|
||||||
`impounded` INT(11) DEFAULT '0',
|
`impounded` INT(11) DEFAULT '0',
|
||||||
`stolen` INT(11) DEFAULT '0',
|
`stolen` INT(11) DEFAULT '0',
|
||||||
`metadata` LONGTEXT DEFAULT ('[]'),
|
`metadata` LONGTEXT DEFAULT ('[]'),
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
INDEX `owner` (`owner`) USING BTREE,
|
INDEX `owner` (`owner`) USING BTREE,
|
||||||
CONSTRAINT `vehowner` FOREIGN KEY (`owner`) REFERENCES `nd_characters` (`charid`) ON UPDATE CASCADE ON DELETE CASCADE
|
CONSTRAINT `vehowner` FOREIGN KEY (`owner`) REFERENCES `nd_characters` (`charid`) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
author "Andyyy#7666"
|
author "Andyyy#7666"
|
||||||
description "ND Framework Core"
|
description "ND Framework Core"
|
||||||
version "2.0.2"
|
version "2.3.2"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
@@ -37,7 +37,10 @@ files {
|
|||||||
"compatibility/**/locale.lua"
|
"compatibility/**/locale.lua"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependency "oxmysql"
|
dependencies {
|
||||||
|
"ox_lib",
|
||||||
|
"oxmysql"
|
||||||
|
}
|
||||||
|
|
||||||
-- below were used with backwards compatibility but could interfere with resources checking if the resources are started.
|
-- below were used with backwards compatibility but could interfere with resources checking if the resources are started.
|
||||||
-- provide "es_extended"
|
-- provide "es_extended"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ local moneyActions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lib.addCommand("setmoney", {
|
lib.addCommand("setmoney", {
|
||||||
help = "Admin command, manage player money.",
|
help = "Admin command, set a players money.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
params = {
|
params = {
|
||||||
{
|
{
|
||||||
@@ -54,7 +54,7 @@ lib.addCommand("setmoney", {
|
|||||||
duration = 10000
|
duration = 10000
|
||||||
})
|
})
|
||||||
|
|
||||||
if not source then return end
|
if not source or source == 0 then return end
|
||||||
TriggerClientEvent("chat:addMessage", source, {
|
TriggerClientEvent("chat:addMessage", source, {
|
||||||
color = {50, 100, 235},
|
color = {50, 100, 235},
|
||||||
multiline = true,
|
multiline = true,
|
||||||
@@ -96,7 +96,7 @@ lib.addCommand("setjob", {
|
|||||||
duration = 10000
|
duration = 10000
|
||||||
})
|
})
|
||||||
|
|
||||||
if not source then return end
|
if not source or source == 0 then return end
|
||||||
TriggerClientEvent("chat:addMessage", source, {
|
TriggerClientEvent("chat:addMessage", source, {
|
||||||
color = {50, 100, 235},
|
color = {50, 100, 235},
|
||||||
multiline = true,
|
multiline = true,
|
||||||
@@ -155,7 +155,7 @@ lib.addCommand("setgroup", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not source then return end
|
if not source or source == 0 then return end
|
||||||
TriggerClientEvent("chat:addMessage", source, {
|
TriggerClientEvent("chat:addMessage", source, {
|
||||||
color = {50, 100, 235},
|
color = {50, 100, 235},
|
||||||
multiline = true,
|
multiline = true,
|
||||||
@@ -164,7 +164,7 @@ lib.addCommand("setgroup", {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("skin", {
|
lib.addCommand("skin", {
|
||||||
help = "Admin command, set player into character clothing menu.",
|
help = "Admin command, show character clothing menu for player.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
params = {
|
params = {
|
||||||
{
|
{
|
||||||
@@ -178,7 +178,7 @@ lib.addCommand("skin", {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("character", {
|
lib.addCommand("character", {
|
||||||
help = "Admin command, set player into character selection menu.",
|
help = "Admin command, show character selection menu for player.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
params = {
|
params = {
|
||||||
{
|
{
|
||||||
@@ -206,7 +206,7 @@ lib.addCommand("pay", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, function(source, args, raw)
|
}, function(source, args, raw)
|
||||||
if not source then return end
|
if not source or source == 0 then return end
|
||||||
|
|
||||||
local player = NDCore.getPlayer(source)
|
local player = NDCore.getPlayer(source)
|
||||||
local targetPlayer = NDCore.getPlayer(args.target)
|
local targetPlayer = NDCore.getPlayer(args.target)
|
||||||
@@ -262,38 +262,22 @@ lib.addCommand("pay", {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("unlock", {
|
lib.addCommand("unlock", {
|
||||||
help = "Admin force unlock vehicles",
|
help = "Admin Command, force unlock a vehicle.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
}, function(source, args, raw)
|
}, function(source, args, raw)
|
||||||
local ped = GetPlayerPed(source)
|
local ped = GetPlayerPed(source)
|
||||||
local playerVeh = GetVehiclePedIsIn(ped)
|
|
||||||
local coords = GetEntityCoords(ped)
|
local coords = GetEntityCoords(ped)
|
||||||
local vehicles = GetAllVehicles()
|
local veh = lib.getClosestVehicle(coords, 2.5, true)
|
||||||
local maxDistance = 2.0
|
|
||||||
local closestVehicle
|
|
||||||
|
|
||||||
if not playerVeh or playerVeh == 0 or not DoesEntityExist(playerVeh) then
|
if not veh then return end
|
||||||
for i=1, #vehicles do
|
|
||||||
local vehicle = vehicles[i]
|
local state = Entity(veh).state
|
||||||
local vehicleCoords = GetEntityCoords(vehicle)
|
state.hotwired = true
|
||||||
local distance = #(coords-vehicleCoords)
|
state.locked = false
|
||||||
|
|
||||||
if distance < maxDistance then
|
|
||||||
maxDistance = distance
|
|
||||||
closestVehicle = vehicle
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not closestVehicle or not DoesEntityExist(closestVehicle) then return end
|
|
||||||
local state = Entity(closestVehicle).state
|
|
||||||
state.locked = false
|
|
||||||
else
|
|
||||||
local state = Entity(playerVeh).state
|
|
||||||
state.hotwired = true
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("revive", {
|
lib.addCommand("revive", {
|
||||||
help = "Admin command, revive player.",
|
help = "Admin command, revive a player.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
params = {
|
params = {
|
||||||
{
|
{
|
||||||
@@ -309,60 +293,48 @@ lib.addCommand("revive", {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("dv", {
|
lib.addCommand("dv", {
|
||||||
help = "Admin command, delete vehicles within the range.",
|
help = "Admin command, delete vehicles within the range or the closest.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
params = {
|
params = {
|
||||||
{
|
{
|
||||||
name = "range",
|
name = "range",
|
||||||
type = "number",
|
type = "number",
|
||||||
help = "The range to select vehicles for deleteion from",
|
help = "Range to delete vehicles in",
|
||||||
optional = true
|
optional = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, function(source, args, raw)
|
}, function(source, args, raw)
|
||||||
local ped = GetPlayerPed(source)
|
local ped = GetPlayerPed(source)
|
||||||
local veh = GetVehiclePedIsIn(ped)
|
|
||||||
if veh and veh ~= 0 and DoesEntityExist(veh) then
|
|
||||||
DeleteEntity(veh)
|
|
||||||
return TriggerClientEvent("chat:addMessage", source, {
|
|
||||||
color = {50, 100, 235},
|
|
||||||
multiline = true,
|
|
||||||
args = {"Staff action", "deleted 1 vehicle"}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
local count = 0
|
|
||||||
local coords = GetEntityCoords(ped)
|
local coords = GetEntityCoords(ped)
|
||||||
|
local count = 0
|
||||||
|
local message = nil
|
||||||
|
local veh = lib.getClosestVehicle(coords, 3.0)
|
||||||
|
|
||||||
if args.range then
|
if args.range then
|
||||||
for _, veh in ipairs(GetAllVehicles()) do
|
local vehicles = lib.getNearbyVehicles(coords, args.range)
|
||||||
local vehDist = #(GetEntityCoords(veh) - coords)
|
count = #vehicles
|
||||||
if vehDist < args.range then
|
|
||||||
DeleteEntity(veh)
|
for i=1, count do
|
||||||
count += 1
|
local veh = vehicles[i]
|
||||||
end
|
DeleteEntity(veh.vehicle)
|
||||||
end
|
end
|
||||||
return TriggerClientEvent("chat:addMessage", source, {
|
elseif veh then
|
||||||
color = {50, 100, 235},
|
DeleteEntity(veh)
|
||||||
multiline = true,
|
count = 1
|
||||||
args = {"Staff action", ("deleted %d vehicles"):format(count)}
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local closest, dist
|
if count == 0 then
|
||||||
for _, veh in ipairs(GetAllVehicles()) do
|
message = {"Staff action [dv]", "no vehicles found"}
|
||||||
local vehDist = #(GetEntityCoords(veh) - coords)
|
elseif count == 1 then
|
||||||
if vehDist < 5.0 and not closest or (dist and dist > vehDist) then
|
message = {"Staff action [dv]", "deleted 1 vehicle"}
|
||||||
closest = veh
|
else
|
||||||
dist = vehDist
|
message = {"Staff action [dv]", ("deleted %d vehicles"):format(count)}
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not closest then return "no vehicle found nearby" end
|
|
||||||
DeleteEntity(closest)
|
|
||||||
TriggerClientEvent("chat:addMessage", source, {
|
TriggerClientEvent("chat:addMessage", source, {
|
||||||
color = {50, 100, 235},
|
color = {50, 100, 235},
|
||||||
multiline = true,
|
multiline = true,
|
||||||
args = {"Staff action", "deleted 1 vehicle"}
|
args = message
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -433,7 +405,7 @@ lib.addCommand("unfreeze", {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("vehicle", {
|
lib.addCommand("vehicle", {
|
||||||
help = "Admin command, unfreeze a player.",
|
help = "Admin command, spawn a vehicle.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
params = {
|
params = {
|
||||||
{
|
{
|
||||||
@@ -466,3 +438,45 @@ lib.addCommand("vehicle", {
|
|||||||
Wait(100)
|
Wait(100)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
lib.addCommand("claim-veh", {
|
||||||
|
help = "Admin command, add a copy of the vehicle you're inside to players garage.",
|
||||||
|
restricted = "group.admin",
|
||||||
|
params = {
|
||||||
|
{
|
||||||
|
name = "target",
|
||||||
|
type = "playerId",
|
||||||
|
help = "Target player's server id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function(source, args, raw)
|
||||||
|
local player = NDCore.getPlayer(source)
|
||||||
|
if not player then return end
|
||||||
|
|
||||||
|
local targetPlayer = NDCore.getPlayer(args.target)
|
||||||
|
if not targetPlayer then
|
||||||
|
return player.notify({
|
||||||
|
title = "Player not found!",
|
||||||
|
description = "Target player not found, make sure they select a charcter!",
|
||||||
|
type = "error"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local properties = lib.callback.await("ND_Vehicles:getPropsFromCurrentVeh", source)
|
||||||
|
if not properties then
|
||||||
|
return player.notify({
|
||||||
|
title = "Vehicle data not found!",
|
||||||
|
description = "The vehicle properties data was not found!",
|
||||||
|
type = "error"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
NDCore.setVehicleOwned(targetPlayer.id, properties, true)
|
||||||
|
|
||||||
|
player.notify({
|
||||||
|
title = "Vehicle added!",
|
||||||
|
description = ("The vehicle has now been added to %s's garage!"):format(targetPlayer.name),
|
||||||
|
type = "success"
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
function NDCore.getPlayerIdentifierByType(src, indentifierType)
|
||||||
|
if Config.sv_lan then
|
||||||
|
return ("%s:sv_lan"):format(indentifierType)
|
||||||
|
end
|
||||||
|
return GetPlayerIdentifierByType(src, indentifierType)
|
||||||
|
end
|
||||||
|
|
||||||
---@param src number
|
---@param src number
|
||||||
---@return table
|
---@return table
|
||||||
function NDCore.getPlayer(src)
|
function NDCore.getPlayer(src)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ local tempPlayersInfo = {}
|
|||||||
Config = {
|
Config = {
|
||||||
serverName = GetConvar("core:serverName", "Unconfigured ND-Core Server"),
|
serverName = GetConvar("core:serverName", "Unconfigured ND-Core Server"),
|
||||||
discordInvite = GetConvar("core:discordInvite", "https://discord.gg/Z9Mxu72zZ6"),
|
discordInvite = GetConvar("core:discordInvite", "https://discord.gg/Z9Mxu72zZ6"),
|
||||||
|
discordMemeberRequired = GetConvarInt("core:discordMemeberRequired", 1) == 1,
|
||||||
discordAppId = GetConvar("core:discordAppId", "858146067018416128"),
|
discordAppId = GetConvar("core:discordAppId", "858146067018416128"),
|
||||||
discordAsset = GetConvar("core:discordAsset", "andyyy"),
|
discordAsset = GetConvar("core:discordAsset", "andyyy"),
|
||||||
discordAssetSmall = GetConvar("core:discordAssetSmall", "andyyy"),
|
discordAssetSmall = GetConvar("core:discordAssetSmall", "andyyy"),
|
||||||
@@ -23,8 +24,10 @@ Config = {
|
|||||||
groups = json.decode(GetConvar("core:groups", "[]")),
|
groups = json.decode(GetConvar("core:groups", "[]")),
|
||||||
admins = json.decode(GetConvar("core:admins", "[]")),
|
admins = json.decode(GetConvar("core:admins", "[]")),
|
||||||
adminDiscordRoles = json.decode(GetConvar("core:adminDiscordRoles", "[]")),
|
adminDiscordRoles = json.decode(GetConvar("core:adminDiscordRoles", "[]")),
|
||||||
|
groupRoles = json.decode(GetConvar("core:groupRoles", "[]")),
|
||||||
multiCharacter = false,
|
multiCharacter = false,
|
||||||
compatibility = json.decode(GetConvar("core:compatibility", "[]"))
|
compatibility = json.decode(GetConvar("core:compatibility", "[]")),
|
||||||
|
sv_lan = GetConvar("sv_lan", "false") == "true",
|
||||||
}
|
}
|
||||||
|
|
||||||
SetConvarServerInfo("Discord", Config.discordInvite)
|
SetConvarServerInfo("Discord", Config.discordInvite)
|
||||||
@@ -41,6 +44,11 @@ local function getIdentifierList(src)
|
|||||||
list[identifierType] = identifier
|
list[identifierType] = identifier
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Config.sv_lan then
|
||||||
|
list[Config.characterIdentifier] = NDCore.getPlayerIdentifierByType(src, Config.characterIdentifier)
|
||||||
|
end
|
||||||
|
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -50,6 +58,10 @@ AddEventHandler("playerJoining", function(oldId)
|
|||||||
PlayersInfo[src] = tempPlayersInfo[oldTempId]
|
PlayersInfo[src] = tempPlayersInfo[oldTempId]
|
||||||
tempPlayersInfo[oldTempId] = nil
|
tempPlayersInfo[oldTempId] = nil
|
||||||
|
|
||||||
|
if Config.sv_lan then
|
||||||
|
lib.addPrincipal(("player.%s"):format(src), "group.admin")
|
||||||
|
end
|
||||||
|
|
||||||
if Config.multiCharacter then return end
|
if Config.multiCharacter then return end
|
||||||
Wait(3000)
|
Wait(3000)
|
||||||
|
|
||||||
@@ -101,7 +113,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
|||||||
|
|
||||||
if mainIdentifier and Config.discordBotToken ~= "false" and Config.discordGuildId ~= "false" then
|
if mainIdentifier and Config.discordBotToken ~= "false" and Config.discordGuildId ~= "false" then
|
||||||
discordInfo = checkDiscordIdentifier(identifiers)
|
discordInfo = checkDiscordIdentifier(identifiers)
|
||||||
if not discordInfo then
|
if not discordInfo and Config.discordMemeberRequired and not Config.sv_lan then
|
||||||
deferrals.done(("Your discord was not found, join our discord here: %s."):format(Config.discordInvite))
|
deferrals.done(("Your discord was not found, join our discord here: %s."):format(Config.discordInvite))
|
||||||
Wait(0)
|
Wait(0)
|
||||||
end
|
end
|
||||||
@@ -110,6 +122,17 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
|||||||
deferrals.update("Connecting...")
|
deferrals.update("Connecting...")
|
||||||
Wait(0)
|
Wait(0)
|
||||||
|
|
||||||
|
if Config.sv_lan then
|
||||||
|
tempPlayersInfo[tempSrc] = {
|
||||||
|
identifiers = {
|
||||||
|
[Config.characterIdentifier] = "sv_lan"
|
||||||
|
},
|
||||||
|
discord = discordInfo
|
||||||
|
}
|
||||||
|
deferrals.done()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if mainIdentifier then
|
if mainIdentifier then
|
||||||
tempPlayersInfo[tempSrc] = {
|
tempPlayersInfo[tempSrc] = {
|
||||||
identifiers = identifiers,
|
identifiers = identifiers,
|
||||||
@@ -137,7 +160,7 @@ AddEventHandler("onResourceStop", function(name)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
SetTimeout(500, function()
|
MySQL.ready(function()
|
||||||
NDCore.loadSQL({
|
NDCore.loadSQL({
|
||||||
"database/characters.sql",
|
"database/characters.sql",
|
||||||
"database/vehicles.sql"
|
"database/vehicles.sql"
|
||||||
@@ -153,3 +176,10 @@ RegisterNetEvent("ND:playerEliminated", function(info)
|
|||||||
deathInfo = info
|
deathInfo = info
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:updateClothing", function(clothing)
|
||||||
|
local src = source
|
||||||
|
local player = NDCore.getPlayer(src)
|
||||||
|
if not player or not clothing or type(clothing) ~= "table" then return end
|
||||||
|
player.setMetadata("clothing", clothing)
|
||||||
|
end)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ local function createCharacterTable(info)
|
|||||||
gender = info.gender,
|
gender = info.gender,
|
||||||
cash = info.cash,
|
cash = info.cash,
|
||||||
bank = info.bank,
|
bank = info.bank,
|
||||||
|
phonenumber = info.phonenumber,
|
||||||
groups = info.groups,
|
groups = info.groups,
|
||||||
metadata = info.metadata,
|
metadata = info.metadata,
|
||||||
inventory = info.inventory
|
inventory = info.inventory
|
||||||
@@ -112,7 +113,8 @@ local function createCharacterTable(info)
|
|||||||
TriggerEvent("ND:moneyChange", self.source, key, value, "set", reason)
|
TriggerEvent("ND:moneyChange", self.source, key, value, "set", reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self), key)
|
||||||
|
TriggerEvent("ND:updateCharacter", self, key)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param key string|table
|
---@param key string|table
|
||||||
@@ -126,7 +128,8 @@ local function createCharacterTable(info)
|
|||||||
else
|
else
|
||||||
self.metadata[key] = value
|
self.metadata[key] = value
|
||||||
end
|
end
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self), "metadata")
|
||||||
|
TriggerEvent("ND:updateCharacter", self, "metadata")
|
||||||
return self.metadata
|
return self.metadata
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -164,8 +167,23 @@ local function createCharacterTable(info)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Save character information to database
|
-- Save character information to database
|
||||||
function self.save()
|
function self.save(key)
|
||||||
local affectedRows = MySQL.update.await("UPDATE nd_characters SET name = ?, firstname = ?, lastname = ?, dob = ?, gender = ?, cash = ?, bank = ?, `groups` = ?, metadata = ? WHERE charid = ?", {
|
if key then
|
||||||
|
local charData = self[key]
|
||||||
|
if not charData or type(charData) == "function" then
|
||||||
|
return lib.print.error(key, "Is not valid character data.")
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(charData) == "table" then
|
||||||
|
charData = json.encode(charData)
|
||||||
|
end
|
||||||
|
|
||||||
|
local query = ("UPDATE nd_characters SET `%s` = ? WHERE charid = ?"):format(key)
|
||||||
|
local affectedRows = MySQL.update.await(query, {charData, self.id})
|
||||||
|
return affectedRows > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local affectedRows = MySQL.update.await("UPDATE nd_characters SET name = ?, firstname = ?, lastname = ?, dob = ?, gender = ?, cash = ?, bank = ?, phonenumber = ?, `groups` = ?, metadata = ? WHERE charid = ?", {
|
||||||
self.name,
|
self.name,
|
||||||
self.firstname,
|
self.firstname,
|
||||||
self.lastname,
|
self.lastname,
|
||||||
@@ -173,6 +191,7 @@ local function createCharacterTable(info)
|
|||||||
self.gender,
|
self.gender,
|
||||||
self.cash,
|
self.cash,
|
||||||
self.bank,
|
self.bank,
|
||||||
|
self.phonenumber,
|
||||||
json.encode(self.groups),
|
json.encode(self.groups),
|
||||||
json.encode(self.metadata),
|
json.encode(self.metadata),
|
||||||
self.id
|
self.id
|
||||||
@@ -202,11 +221,24 @@ local function createCharacterTable(info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if licenses then
|
if licenses then
|
||||||
self.metadata.licenses[#licenses+1] = license
|
local found = false
|
||||||
|
|
||||||
|
for i=1, #licenses do
|
||||||
|
if licenses[i].type == licenseType then
|
||||||
|
self.metadata.licenses[i] = license
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not found then
|
||||||
|
self.metadata.licenses[#licenses+1] = license
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self.metadata.licenses = {license}
|
self.metadata.licenses = {license}
|
||||||
end
|
end
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self), "metadata")
|
||||||
|
TriggerEvent("ND:updateCharacter", self, "metadata")
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.getLicense(identifier)
|
function self.getLicense(identifier)
|
||||||
@@ -252,11 +284,7 @@ local function createCharacterTable(info)
|
|||||||
|
|
||||||
function self.notify(...)
|
function self.notify(...)
|
||||||
if not self.source then return end
|
if not self.source then return end
|
||||||
if GetResourceState("ModernHUD") == "started" then
|
TriggerClientEvent("ox_lib:notify", self.source, ...)
|
||||||
TriggerClientEvent("ModernHUD:notify", self.source, ...)
|
|
||||||
elseif GetResourceState("ox_lib") == "started" then
|
|
||||||
TriggerClientEvent("ox_lib:notify", self.source, ...)
|
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -293,6 +321,12 @@ local function createCharacterTable(info)
|
|||||||
self.addGroup("admin")
|
self.addGroup("admin")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for group, role in pairs(Config.groupRoles) do
|
||||||
|
if lib.table.contains(roles, role) then
|
||||||
|
self.addGroup(group)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, _ in pairs(self.groups) do
|
for name, _ in pairs(self.groups) do
|
||||||
@@ -307,12 +341,15 @@ local function createCharacterTable(info)
|
|||||||
---@param rank number
|
---@param rank number
|
||||||
---@param isJob boolean
|
---@param isJob boolean
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function self.addGroup(name, rank, isJob)
|
function self.addGroup(name, rank, customGroup, isJob)
|
||||||
local groupRank = tonumber(rank) or 1
|
local groupRank = tonumber(rank) or 1
|
||||||
local groupInfo = Config.groups?[name]
|
local groupInfo = lib.table.deepclone(Config.groups?[name] or {})
|
||||||
local bossRank = groupInfo and groupInfo.minimumBossRank
|
local bossRank = groupInfo?.minimumBossRank
|
||||||
|
|
||||||
|
for k, v in pairs(customGroup or {}) do
|
||||||
|
groupInfo[k] = v
|
||||||
|
end
|
||||||
|
|
||||||
-- if not groupInfo then return end
|
|
||||||
if isJob then
|
if isJob then
|
||||||
for _, group in pairs(self.groups) do
|
for _, group in pairs(self.groups) do
|
||||||
group.isJob = nil
|
group.isJob = nil
|
||||||
@@ -321,17 +358,21 @@ local function createCharacterTable(info)
|
|||||||
|
|
||||||
self.groups[name] = {
|
self.groups[name] = {
|
||||||
name = name,
|
name = name,
|
||||||
label = groupInfo and groupInfo.label or name,
|
label = groupInfo?.label or name,
|
||||||
rankName = groupInfo and groupInfo.ranks[groupRank] or groupRank,
|
rankName = groupInfo?.ranks?[groupRank] or groupRank,
|
||||||
rank = groupRank,
|
rank = groupRank,
|
||||||
isJob = isJob,
|
isJob = isJob,
|
||||||
isBoss = bossRank and groupRank >= bossRank
|
isBoss = bossRank and groupRank >= bossRank,
|
||||||
|
metadata = groupInfo.metadata or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if not isJob then
|
if not isJob then
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self), "groups")
|
||||||
|
TriggerEvent("ND:updateCharacter", self, "groups")
|
||||||
end
|
end
|
||||||
|
|
||||||
lib.addPrincipal(self.source, ("group.%s"):format(name))
|
lib.addPrincipal(self.source, ("group.%s"):format(name))
|
||||||
|
|
||||||
return self.groups[name]
|
return self.groups[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -352,7 +393,9 @@ local function createCharacterTable(info)
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.groups[name] = nil
|
self.groups[name] = nil
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self), "groups")
|
||||||
|
TriggerEvent("ND:updateCharacter", self, "groups")
|
||||||
|
TriggerEvent("ND:groupRemoved", self, group)
|
||||||
lib.removePrincipal(self.source, ("group.%s"):format(name))
|
lib.removePrincipal(self.source, ("group.%s"):format(name))
|
||||||
return group
|
return group
|
||||||
end
|
end
|
||||||
@@ -362,12 +405,13 @@ local function createCharacterTable(info)
|
|||||||
---@return boolean
|
---@return boolean
|
||||||
function self.setJob(name, rank)
|
function self.setJob(name, rank)
|
||||||
self.removeGroup(self.job)
|
self.removeGroup(self.job)
|
||||||
local job = self.addGroup(name, rank, true)
|
local job = self.addGroup(name, rank, nil, true)
|
||||||
if job then
|
if job then
|
||||||
self.job = job.name
|
self.job = job.name
|
||||||
self.jobInfo = job
|
self.jobInfo = job
|
||||||
end
|
end
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self), "job")
|
||||||
|
TriggerEvent("ND:updateCharacter", self, "job")
|
||||||
return job
|
return job
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -394,7 +438,7 @@ end
|
|||||||
---@param info table
|
---@param info table
|
||||||
---@return table
|
---@return table
|
||||||
function NDCore.newCharacter(src, info)
|
function NDCore.newCharacter(src, info)
|
||||||
local identifier = GetPlayerIdentifierByType(src, Config.characterIdentifier)
|
local identifier = NDCore.getPlayerIdentifierByType(src, Config.characterIdentifier)
|
||||||
if not identifier then return end
|
if not identifier then return end
|
||||||
|
|
||||||
local charInfo = {
|
local charInfo = {
|
||||||
@@ -407,12 +451,13 @@ function NDCore.newCharacter(src, info)
|
|||||||
gender = info.gender or "",
|
gender = info.gender or "",
|
||||||
cash = info.cash or 0,
|
cash = info.cash or 0,
|
||||||
bank = info.bank or 0,
|
bank = info.bank or 0,
|
||||||
|
phonenumber = info.phonenumber,
|
||||||
groups = info.groups or {},
|
groups = info.groups or {},
|
||||||
metadata = info.metadata or {},
|
metadata = info.metadata or {},
|
||||||
inventory = info.inventory or {},
|
inventory = info.inventory or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
charInfo.id = MySQL.insert.await("INSERT INTO nd_characters (identifier, name, firstname, lastname, dob, gender, cash, bank, `groups`, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", {
|
charInfo.id = MySQL.insert.await("INSERT INTO nd_characters (identifier, name, firstname, lastname, dob, gender, cash, bank, phonenumber, `groups`, metadata, inventory) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", {
|
||||||
identifier,
|
identifier,
|
||||||
charInfo.name,
|
charInfo.name,
|
||||||
charInfo.firstname,
|
charInfo.firstname,
|
||||||
@@ -421,8 +466,10 @@ function NDCore.newCharacter(src, info)
|
|||||||
charInfo.gender,
|
charInfo.gender,
|
||||||
charInfo.cash,
|
charInfo.cash,
|
||||||
charInfo.bank,
|
charInfo.bank,
|
||||||
|
charInfo.phonenumber,
|
||||||
json.encode(charInfo.groups),
|
json.encode(charInfo.groups),
|
||||||
json.encode(charInfo.metadata)
|
json.encode(charInfo.metadata),
|
||||||
|
json.encode(charInfo.inventory)
|
||||||
})
|
})
|
||||||
|
|
||||||
return createCharacterTable(charInfo)
|
return createCharacterTable(charInfo)
|
||||||
@@ -433,7 +480,7 @@ end
|
|||||||
function NDCore.fetchCharacter(id, src)
|
function NDCore.fetchCharacter(id, src)
|
||||||
local result
|
local result
|
||||||
if src then
|
if src then
|
||||||
result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ? and identifier = ?", {id, GetPlayerIdentifierByType(src, Config.characterIdentifier)})
|
result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ? and identifier = ?", {id, NDCore.getPlayerIdentifierByType(src, Config.characterIdentifier)})
|
||||||
else
|
else
|
||||||
result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ?", {id})
|
result = MySQL.query.await("SELECT * FROM nd_characters WHERE charid = ?", {id})
|
||||||
end
|
end
|
||||||
@@ -451,6 +498,7 @@ function NDCore.fetchCharacter(id, src)
|
|||||||
gender = info.gender,
|
gender = info.gender,
|
||||||
cash = info.cash,
|
cash = info.cash,
|
||||||
bank = info.bank,
|
bank = info.bank,
|
||||||
|
phonenumber = info.phonenumber,
|
||||||
groups = json.decode(info.groups),
|
groups = json.decode(info.groups),
|
||||||
metadata = json.decode(info.metadata),
|
metadata = json.decode(info.metadata),
|
||||||
inventory = json.decode(info.inventory)
|
inventory = json.decode(info.inventory)
|
||||||
@@ -461,7 +509,7 @@ end
|
|||||||
---@return table
|
---@return table
|
||||||
function NDCore.fetchAllCharacters(src)
|
function NDCore.fetchAllCharacters(src)
|
||||||
local characters = {}
|
local characters = {}
|
||||||
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE identifier = ?", {GetPlayerIdentifierByType(src, Config.characterIdentifier)})
|
local result = MySQL.query.await("SELECT * FROM nd_characters WHERE identifier = ?", {NDCore.getPlayerIdentifierByType(src, Config.characterIdentifier)})
|
||||||
|
|
||||||
for i=1, #result do
|
for i=1, #result do
|
||||||
local info = result[i]
|
local info = result[i]
|
||||||
@@ -476,9 +524,10 @@ function NDCore.fetchAllCharacters(src)
|
|||||||
gender = info.gender,
|
gender = info.gender,
|
||||||
cash = info.cash,
|
cash = info.cash,
|
||||||
bank = info.bank,
|
bank = info.bank,
|
||||||
|
phonenumber = info.phonenumber,
|
||||||
groups = json.decode(info.groups),
|
groups = json.decode(info.groups),
|
||||||
metadata = json.decode(info.metadata),
|
metadata = json.decode(info.metadata),
|
||||||
inventory = json.decode(info.inventory),
|
inventory = json.decode(info.inventory)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
return characters
|
return characters
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local ox_inventory
|
local ox_inventory
|
||||||
local inventoryStarted = false
|
local inventoryStarted = false
|
||||||
local spawnedPlayerVehicles = {}
|
local spawnedPlayerVehicles = {}
|
||||||
|
local vehicleTypes = json.decode(GetResourceKvpString("ND_Core:vehTypes") or "[]")
|
||||||
|
|
||||||
NDCore.isResourceStarted("ox_inventory", function(started)
|
NDCore.isResourceStarted("ox_inventory", function(started)
|
||||||
inventoryStarted = started
|
inventoryStarted = started
|
||||||
@@ -8,16 +9,24 @@ NDCore.isResourceStarted("ox_inventory", function(started)
|
|||||||
ox_inventory = exports.ox_inventory
|
ox_inventory = exports.ox_inventory
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function getVehicleType(model)
|
local function getVehicleType(coords, model)
|
||||||
local tempVehicle = CreateVehicle(model, 0, 0, 0, 0, true, true)
|
if vehicleTypes[model] then
|
||||||
|
return vehicleTypes[model]
|
||||||
|
end
|
||||||
|
|
||||||
|
local tempVehicle = CreateVehicle(model, coords.x, coords.y, coords.z-5.0, coords.w, true, false)
|
||||||
local time = os.time()
|
local time = os.time()
|
||||||
while not DoesEntityExist(tempVehicle) and time-os.time() < 5 do Wait(5) end
|
|
||||||
|
while not DoesEntityExist(tempVehicle) and os.time()-time < 5 do Wait(0) end
|
||||||
if not DoesEntityExist(tempVehicle) then return end
|
if not DoesEntityExist(tempVehicle) then return end
|
||||||
local entityType = GetVehicleType(tempVehicle)
|
|
||||||
|
local vehType = GetVehicleType(tempVehicle)
|
||||||
DeleteEntity(tempVehicle)
|
DeleteEntity(tempVehicle)
|
||||||
return entityType
|
|
||||||
|
vehicleTypes[model] = vehType
|
||||||
|
SetResourceKvp("ND_Core:vehTypes", json.encode(vehicleTypes))
|
||||||
|
|
||||||
|
return vehType
|
||||||
end
|
end
|
||||||
|
|
||||||
local function generatePlate()
|
local function generatePlate()
|
||||||
@@ -90,18 +99,35 @@ function NDCore.getVehicle(entity)
|
|||||||
if saveProperties and self.id and self.owner then
|
if saveProperties and self.id and self.owner then
|
||||||
local properties = lib.callback.await("ND_Vehicles:getProps", NetworkGetEntityOwner(entity), self.netId)
|
local properties = lib.callback.await("ND_Vehicles:getProps", NetworkGetEntityOwner(entity), self.netId)
|
||||||
if properties then
|
if properties then
|
||||||
|
if self.properties?.callsign then
|
||||||
|
properties.callsign = true
|
||||||
|
end
|
||||||
MySQL.query("UPDATE nd_vehicles SET properties = ? WHERE id = ?", {json.encode(properties), self.id})
|
MySQL.query("UPDATE nd_vehicles SET properties = ? WHERE id = ?", {json.encode(properties), self.id})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
DeleteEntity(entity)
|
DeleteEntity(entity)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- remvoe vehicle from db.
|
||||||
|
function self.remove(keepEntity)
|
||||||
|
if not keepEntity and DoesEntityExist(entity) then
|
||||||
|
DeleteEntity(entity)
|
||||||
|
end
|
||||||
|
MySQL.query("DELETE FROM nd_vehicles WHERE id = ?", {self.id})
|
||||||
|
end
|
||||||
|
|
||||||
--- set vehicle properties
|
--- set vehicle properties
|
||||||
---@param props table
|
---@param props table
|
||||||
function self.setProperties(props)
|
function self.setProperties(props)
|
||||||
if not DoesEntityExist(entity) then return end
|
if not DoesEntityExist(entity) then return end
|
||||||
local properties = type(props) == "string" and json.decode(props) or props
|
local properties = type(props) == "string" and json.decode(props) or props
|
||||||
local state = Entity(entity).state
|
local state = Entity(entity).state
|
||||||
|
|
||||||
|
if self.properties?.callsign then
|
||||||
|
properties.callsign = true
|
||||||
|
end
|
||||||
|
|
||||||
state.props = properties
|
state.props = properties
|
||||||
self.properties = properties
|
self.properties = properties
|
||||||
|
|
||||||
@@ -148,13 +174,22 @@ function NDCore.getVehicle(entity)
|
|||||||
|
|
||||||
function self.setMetadata(key, value)
|
function self.setMetadata(key, value)
|
||||||
self.metadata[key] = value
|
self.metadata[key] = value
|
||||||
|
|
||||||
if DoesEntityExist(entity) then
|
if DoesEntityExist(entity) then
|
||||||
local state = Entity(self.entity).state
|
local state = Entity(self.entity).state
|
||||||
local metadata = state.metadata
|
|
||||||
metadata[key] = value
|
if not state.metadata then
|
||||||
state.metadata = metadata
|
state.metadata = self.metadata
|
||||||
|
else
|
||||||
|
state.metadata[key] = value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if not self.id or not self.owner then return end
|
|
||||||
|
if not self.id or not self.owner then
|
||||||
|
lib.print.debug(('Skipped storing metadata for vehicle %s as it does not have an id/owner associated with it.'):format(self.entity))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
MySQL.query("UPDATE nd_vehicles SET metadata = ? WHERE id = ?", {json.encode(self.metadata), self.id})
|
MySQL.query("UPDATE nd_vehicles SET metadata = ? WHERE id = ?", {json.encode(self.metadata), self.id})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -245,14 +280,14 @@ function NDCore.createVehicle(info)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local model = info.model or properties.model
|
local model = info.model or properties.model
|
||||||
local vehType = getVehicleType(model)
|
local vehType = getVehicleType(spawnCoords, model)
|
||||||
if not vehType then
|
if not vehType then
|
||||||
return Citizen.Trace("NDCore.createVehicle", "vehType not found")
|
return Citizen.Trace("NDCore.createVehicle", "vehType not found")
|
||||||
end
|
end
|
||||||
|
|
||||||
local veh = CreateVehicleServerSetter(model, vehType, spawnCoords.x, spawnCoords.y, spawnCoords.z, spawnCoords.w)
|
local veh = CreateVehicleServerSetter(model, vehType, spawnCoords.x, spawnCoords.y, spawnCoords.z, spawnCoords.w)
|
||||||
local time = os.time()
|
local time = os.time()
|
||||||
while not DoesEntityExist(veh) and time-os.time() < 5 do Wait(5) end
|
while not DoesEntityExist(veh) and os.time()-time < 5 do Wait(5) end
|
||||||
if not veh or not DoesEntityExist(veh) then
|
if not veh or not DoesEntityExist(veh) then
|
||||||
return Citizen.Trace("NDCore.createVehicle", "vehicle entity doesn't exist")
|
return Citizen.Trace("NDCore.createVehicle", "vehicle entity doesn't exist")
|
||||||
end
|
end
|
||||||
@@ -403,14 +438,31 @@ function NDCore.spawnOwnedVehicle(source, vehicleId, coords, heading)
|
|||||||
if not player then return end
|
if not player then return end
|
||||||
|
|
||||||
local vehicle = NDCore.getVehicleById(vehicleId)
|
local vehicle = NDCore.getVehicleById(vehicleId)
|
||||||
if not vehicle or not vehicle.available or vehicle.owner ~= player.id then return end
|
if not vehicle or vehicle.owner ~= player.id then return end
|
||||||
|
if not vehicle.available and not vehicle.impounded then return end
|
||||||
|
|
||||||
MySQL.query.await("UPDATE nd_vehicles SET stored = ? WHERE id = ?", {0, vehicleId})
|
MySQL.query.await("UPDATE nd_vehicles SET stored = ? WHERE id = ?", {0, vehicleId})
|
||||||
|
|
||||||
|
local properties = vehicle.properties
|
||||||
|
if properties.callsign then
|
||||||
|
local callsign = player.getMetadata("callsign")
|
||||||
|
if not callsign or callsign == "" then goto skip end
|
||||||
|
|
||||||
|
callsign = tostring(callsign)
|
||||||
|
if not callsign or callsign:len() ~= 3 then goto skip end
|
||||||
|
|
||||||
|
properties.modFender = tonumber(callsign:sub(1, 1))
|
||||||
|
properties.modRightFender = tonumber(callsign:sub(2, 2))
|
||||||
|
properties.modRoof = tonumber(callsign:sub(3, 3))
|
||||||
|
end
|
||||||
|
|
||||||
|
::skip::
|
||||||
|
|
||||||
return NDCore.createVehicle({
|
return NDCore.createVehicle({
|
||||||
owner = player.id,
|
owner = player.id,
|
||||||
model = vehicle.properties.model,
|
model = properties.model,
|
||||||
coords = vec4(coords.x, coords.y, coords.z, coords.w or coords.heading or heading),
|
coords = vec4(coords.x, coords.y, coords.z, coords.w or coords.heading or heading),
|
||||||
properties = vehicle.properties,
|
properties = properties,
|
||||||
vehicleId = vehicleId,
|
vehicleId = vehicleId,
|
||||||
source = source
|
source = source
|
||||||
})
|
})
|
||||||
@@ -677,6 +729,11 @@ RegisterNetEvent("ND_Vehicles:takeVehicle", function(vehId, locations)
|
|||||||
local vehicle = NDCore.getVehicleById(vehId)
|
local vehicle = NDCore.getVehicleById(vehId)
|
||||||
local player = NDCore.getPlayer(src)
|
local player = NDCore.getPlayer(src)
|
||||||
if not player or not vehicle or vehicle.owner ~= player.id then return end
|
if not player or not vehicle or vehicle.owner ~= player.id then return end
|
||||||
|
|
||||||
|
local info = NDCore.spawnOwnedVehicle(src, vehicle.id, isParkingAvailable(locations))
|
||||||
|
if not info then return end
|
||||||
|
TriggerClientEvent("ND_Vehicles:blip", src, info.netId, true)
|
||||||
|
|
||||||
if vehicle.impounded then
|
if vehicle.impounded then
|
||||||
local reclaimPrice = vehicle.metadata.impoundReclaimPrice or 200
|
local reclaimPrice = vehicle.metadata.impoundReclaimPrice or 200
|
||||||
if not player.deductMoney("bank", reclaimPrice, "Vehicle impound reclaim") then
|
if not player.deductMoney("bank", reclaimPrice, "Vehicle impound reclaim") then
|
||||||
@@ -695,10 +752,6 @@ RegisterNetEvent("ND_Vehicles:takeVehicle", function(vehId, locations)
|
|||||||
})
|
})
|
||||||
MySQL.query.await("UPDATE nd_vehicles SET impounded = ? WHERE id = ?", {0, vehicle.id})
|
MySQL.query.await("UPDATE nd_vehicles SET impounded = ? WHERE id = ?", {0, vehicle.id})
|
||||||
end
|
end
|
||||||
|
|
||||||
local info = NDCore.spawnOwnedVehicle(src, vehicle.id, isParkingAvailable(locations))
|
|
||||||
if not info then return end
|
|
||||||
TriggerClientEvent("ND_Vehicles:blip", src, info.netId, true)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
lib.callback.register("ND_Vehicles:getOwnedVehicles", function(src)
|
lib.callback.register("ND_Vehicles:getOwnedVehicles", function(src)
|
||||||
@@ -706,3 +759,30 @@ lib.callback.register("ND_Vehicles:getOwnedVehicles", function(src)
|
|||||||
if not player then return end
|
if not player then return end
|
||||||
return NDCore.getVehicles(player.id)
|
return NDCore.getVehicles(player.id)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
AddEventHandler("ND:characterLoaded", function(player)
|
||||||
|
local ownedExistingVehicles = {}
|
||||||
|
local ownedVehicles = NDCore.getVehicles(player.id)
|
||||||
|
local vehicles = GetAllVehicles()
|
||||||
|
local vehiclesToImpound = {}
|
||||||
|
|
||||||
|
for i=1, #vehicles do
|
||||||
|
local veh = vehicles[i]
|
||||||
|
local state = Entity(veh).state
|
||||||
|
if state.owner == player.id then
|
||||||
|
ownedExistingVehicles[#ownedExistingVehicles+1] = state.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1, #ownedVehicles do
|
||||||
|
local veh = ownedVehicles[i]
|
||||||
|
if veh and not veh.stored and not veh.impounded and not lib.table.contains(ownedExistingVehicles, veh.id) then
|
||||||
|
vehiclesToImpound[#vehiclesToImpound+1] = veh.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #vehiclesToImpound == 0 then return end
|
||||||
|
|
||||||
|
local query = ("UPDATE nd_vehicles SET impounded = ? WHERE owner = ? AND id IN (%s)"):format(table.concat(vehiclesToImpound, ", "))
|
||||||
|
MySQL.rawExecute(query, {1, player.id})
|
||||||
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user