mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46f4bdbd64 | ||
|
|
4870d639d4 | ||
|
|
ed895b4e6d | ||
|
|
5d2925d0c3 | ||
|
|
0500cef32f | ||
|
|
0e1fb43cd2 | ||
|
|
3260aa01f2 | ||
|
|
71a54be704 | ||
|
|
d939607d64 | ||
|
|
5cb038819c | ||
|
|
9f5bb34bdd | ||
|
|
29006870c3 | ||
|
|
a60e1b9e32 | ||
|
|
7fe7901a13 | ||
|
|
ca8f4369f6 | ||
|
|
e1d4b2fcff | ||
|
|
8b0f2b010d | ||
|
|
24e8874050 | ||
|
|
289d040b5c | ||
|
|
3f0c47c2d0 | ||
|
|
543b23a644 | ||
|
|
4b106d3688 | ||
|
|
db5c54f2d8 | ||
|
|
a1150bb821 | ||
|
|
8f7c52130a | ||
|
|
6e71142970 | ||
|
|
d9df135abb | ||
|
|
72fb153cfc |
16
README.md
16
README.md
@@ -16,9 +16,13 @@
|
|||||||
* [oxmysql](https://github.com/overextended/oxmysql/releases)
|
* [oxmysql](https://github.com/overextended/oxmysql/releases)
|
||||||
* [ox_lib](https://github.com/overextended/ox_lib/releases)
|
* [ox_lib](https://github.com/overextended/ox_lib/releases)
|
||||||
|
|
||||||
## v2 Addons
|
## Addons
|
||||||
* [Character selection](https://github.com/ND-Framework/ND_Characters/tree/wip-v2)
|
* [Character selection](https://github.com/ND-Framework/ND_Characters/releases)
|
||||||
* [Banking](https://github.com/ND-Framework/ND_Banking/tree/wip-v2)
|
* [Banking](https://github.com/ND-Framework/ND_Banking/releases)
|
||||||
* [Appearance shops](https://github.com/ND-Framework/ND_AppearanceShops/tree/wip-v2)
|
* [Appearance shops](https://github.com/ND-Framework/ND_AppearanceShops/releases)
|
||||||
* [Dealership](https://github.com/ND-Framework/ND_Dealership/tree/v2)
|
* [Dealership](https://github.com/ND-Framework/ND_Dealership/releases)
|
||||||
* [Inventory](https://github.com/overextended/ox_inventory/pull/1403)
|
* [Inventory](https://github.com/overextended/ox_inventory/releases)
|
||||||
|
* [Ambulance job](https://github.com/ND-Framework/ND_Ambulance/releases)
|
||||||
|
* [Casino](https://github.com/ND-Framework/ND_Casino/releases)
|
||||||
|
* [Blackjack](https://github.com/ND-Framework/ND_Blackjack/releases)
|
||||||
|
* [Nitro](https://github.com/ND-Framework/ND_Nitro/releases)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ 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) and GetEntityHealth(victim) > 0 then
|
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)
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ function NDCore.getPlayersFromCoords(distance, coords)
|
|||||||
return closePlayers
|
return closePlayers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function NDCore.getConfig(info)
|
||||||
|
if not info then
|
||||||
|
return Config
|
||||||
|
end
|
||||||
|
return Config[info]
|
||||||
|
end
|
||||||
|
|
||||||
function NDCore.revivePlayer(reset, keepDead)
|
function NDCore.revivePlayer(reset, keepDead)
|
||||||
local usingAmbulance = GetResourceState("ND_Ambulance") == "started"
|
local usingAmbulance = GetResourceState("ND_Ambulance") == "started"
|
||||||
if not keepDead then
|
if not keepDead then
|
||||||
|
|||||||
@@ -697,9 +697,14 @@ lib.addKeybind({
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
if not playerVehicle then return end
|
if not playerVehicle then return end
|
||||||
|
|
||||||
|
local speed = math.floor(GetEntitySpeed(playerVehicle) * 2.236936)
|
||||||
|
if speed < 10 then return end
|
||||||
|
|
||||||
cruiseControlEnabled = true
|
cruiseControlEnabled = true
|
||||||
cruiseSpeedVehicle = math.floor(GetEntitySpeed(playerVehicle) * 2.236936)
|
cruiseSpeedVehicle = speed
|
||||||
cruiseSpeedSet = cruiseSpeedVehicle
|
cruiseSpeedSet = cruiseSpeedVehicle
|
||||||
|
|
||||||
lib.notify({
|
lib.notify({
|
||||||
title = "Cruise control",
|
title = "Cruise control",
|
||||||
description = ("Set to %d mph."):format(math.floor(cruiseSpeedSet)),
|
description = ("Set to %d mph."):format(math.floor(cruiseSpeedSet)),
|
||||||
|
|||||||
@@ -5,13 +5,32 @@ exports("GetCoreObject", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
NDCore.Functions = {}
|
NDCore.Functions = {}
|
||||||
NDCore.Functions.GetPlayer = NDCore.getPlayer
|
|
||||||
NDCore.Functions.GetPlayers = NDCore.getPlayers
|
NDCore.Functions.GetPlayers = NDCore.getPlayers
|
||||||
NDCore.Functions.GetUserDiscordInfo = NDCore.getDiscordInfo
|
NDCore.Functions.GetUserDiscordInfo = NDCore.getDiscordInfo
|
||||||
NDCore.Functions.SetActiveCharacter = NDCore.setActiveCharacter
|
NDCore.Functions.SetActiveCharacter = NDCore.setActiveCharacter
|
||||||
NDCore.Functions.GetPlayerCharacters = NDCore.fetchAllCharacters
|
NDCore.Functions.GetPlayerCharacters = NDCore.fetchAllCharacters
|
||||||
NDCore.Functions.GetPlayerByCharacterId = NDCore.fetchCharacter
|
NDCore.Functions.GetPlayerByCharacterId = NDCore.fetchCharacter
|
||||||
|
|
||||||
|
function NDCore.Functions.GetPlayer(src)
|
||||||
|
local player = NDCore.getPlayer(src)
|
||||||
|
return {
|
||||||
|
source = player.source,
|
||||||
|
id = player.id,
|
||||||
|
firstName = player.firstname,
|
||||||
|
lastName = player.lastname,
|
||||||
|
dob = player.dob,
|
||||||
|
gender = player.gender,
|
||||||
|
cash = player.cash,
|
||||||
|
bank = player.bank,
|
||||||
|
phoneNumber = player.metadata.phone,
|
||||||
|
lastLocation = player.metadata.lastLocation,
|
||||||
|
inventory = player.inventory,
|
||||||
|
discordInfo = player.discordInfo,
|
||||||
|
data = player.metadata,
|
||||||
|
job = player.job
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
function NDCore.Functions.GetPlayerIdentifierFromType(identifierType, src)
|
function NDCore.Functions.GetPlayerIdentifierFromType(identifierType, src)
|
||||||
return GetPlayerIdentifierByType(src, identifierType)
|
return GetPlayerIdentifierByType(src, identifierType)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function NDCore.GetPlayerData()
|
|||||||
|
|
||||||
player.coords = GetEntityCoords(cache.ped)
|
player.coords = GetEntityCoords(cache.ped)
|
||||||
player.loadout = {}
|
player.loadout = {}
|
||||||
player.maxWeight = exports.ox_inventory:GetPlayerMaxWeight()
|
player.maxWeight = GetResourceState("ox_inventory") == "started" and exports.ox_inventory:GetPlayerMaxWeight() or 0
|
||||||
player.money = player.Accounts.Money
|
player.money = player.Accounts.Money
|
||||||
player.sex = player.gender
|
player.sex = player.gender
|
||||||
player.firstName = player.firstname
|
player.firstName = player.firstname
|
||||||
@@ -112,7 +112,7 @@ function NDCore.Progressbar(message, lenght, options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function NDCore.SearchInventory(item, count)
|
function NDCore.SearchInventory(item, count)
|
||||||
local itemCount = exports.ox_inventory:Search(item)
|
local itemCount = GetResourceState("ox_inventory") == "started" and exports.ox_inventory:Search(item) or 0
|
||||||
return itemCount >= count and itemCount
|
return itemCount >= count and itemCount
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ function NDCore.ShowHelpNotification()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function NDCore.ShowInventory()
|
function NDCore.ShowInventory()
|
||||||
exports.ox_inventory:openInventory("player", cache.serverId)
|
return GetResourceState("ox_inventory") == "started" and exports.ox_inventory:openInventory("player", cache.serverId)
|
||||||
end
|
end
|
||||||
|
|
||||||
function NDCore.ShowNotification(msg, type, time)
|
function NDCore.ShowNotification(msg, type, time)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ local registeredItems = {}
|
|||||||
|
|
||||||
local function getAmmoFromWeapon(weapon)
|
local function getAmmoFromWeapon(weapon)
|
||||||
if not weapon then return end
|
if not weapon then return end
|
||||||
for item, data in pairs(exports.ox_inventory:Items()) do
|
local items = GetResourceState("ox_inventory") == "started" and exports.ox_inventory:Items() or {}
|
||||||
|
for item, data in pairs(items) do
|
||||||
if data.weapon and data.model and data.model:lower() == weapon:lower() then
|
if data.weapon and data.model and data.model:lower() == weapon:lower() then
|
||||||
return data.ammoname
|
return data.ammoname
|
||||||
end
|
end
|
||||||
@@ -60,7 +61,7 @@ local function createPlayerFunctions(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self.addInventoryItem(item, count)
|
function self.addInventoryItem(item, count)
|
||||||
exports.ox_inventory:AddItem(self.source, item, count)
|
return GetResourceState("ox_inventory") == "started" and exports.ox_inventory:AddItem(self.source, item, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.addMoney(amount)
|
function self.addMoney(amount)
|
||||||
@@ -100,11 +101,11 @@ local function createPlayerFunctions(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self.canCarryItem(item, count)
|
function self.canCarryItem(item, count)
|
||||||
return exports.ox_inventory:CanCarryItem(self.source, item, count)
|
return GetResourceState("ox_inventory") == "started" and exports.ox_inventory:CanCarryItem(self.source, item, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.canSwapItem(firstItem, firstItemCount, testItem, testItemCount)
|
function self.canSwapItem(firstItem, firstItemCount, testItem, testItemCount)
|
||||||
exports.ox_inventory:CanSwapItem(self.source, firstItem, firstItemCount, testItem, testItemCount)
|
return GetResourceState("ox_inventory") == "started" and exports.ox_inventory:CanSwapItem(self.source, firstItem, firstItemCount, testItem, testItemCount)
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.clearMeta(index)
|
function self.clearMeta(index)
|
||||||
@@ -137,7 +138,7 @@ local function createPlayerFunctions(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self.getInventory(minimal)
|
function self.getInventory(minimal)
|
||||||
local playerItems = exports.ox_inventory:GetInventoryItems(self.source)
|
local playerItems = GetResourceState("ox_inventory") == "started" and exports.ox_inventory:GetInventoryItems(self.source) or {}
|
||||||
if not minimal then
|
if not minimal then
|
||||||
return playerItems
|
return playerItems
|
||||||
end
|
end
|
||||||
@@ -145,7 +146,7 @@ local function createPlayerFunctions(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self.getInventoryItem(item)
|
function self.getInventoryItem(item)
|
||||||
local playerItems = exports.ox_inventory:GetInventoryItems(self.source)
|
local playerItems = GetResourceState("ox_inventory") == "started" and exports.ox_inventory:GetInventoryItems(self.source) or {}
|
||||||
for name, data in pairs(playerItems) do
|
for name, data in pairs(playerItems) do
|
||||||
if name == item then
|
if name == item then
|
||||||
return data
|
return data
|
||||||
@@ -162,11 +163,11 @@ local function createPlayerFunctions(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self.hasItem(item, metadata)
|
function self.hasItem(item, metadata)
|
||||||
return exports.ox_inventory:GetItem(self.source, item, metadata)
|
return GetResourceState("ox_inventory") == "started" and exports.ox_inventory:GetItem(self.source, item, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.removeInventoryItem(item, count)
|
function self.removeInventoryItem(item, count)
|
||||||
exports.ox_inventory:RemoveItem(self.source, item, count)
|
return GetResourceState("ox_inventory") == "started" and exports.ox_inventory:RemoveItem(self.source, item, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.removeMoney(amount)
|
function self.removeMoney(amount)
|
||||||
@@ -304,7 +305,8 @@ end
|
|||||||
function NDCore.GetItemLabel(item)
|
function NDCore.GetItemLabel(item)
|
||||||
if not itemNames then
|
if not itemNames then
|
||||||
itemNames = {}
|
itemNames = {}
|
||||||
for item, data in pairs(exports.ox_inventory:Items()) do
|
local items = GetResourceState("ox_inventory") == "started" and exports.ox_inventory:Items() or {}
|
||||||
|
for item, data in pairs(items) do
|
||||||
itemNames[item] = data.label
|
itemNames[item] = data.label
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
|
||||||
|
|
||||||
config = {
|
|
||||||
serverName = "Andy's Development",
|
|
||||||
characterLimit = 15, -- How many characters can a player create.
|
|
||||||
customPauseMenu = true, -- A custom pause menu will display your money, characters name and the server name in the pause menu.
|
|
||||||
enablePVP = true, -- pvp allows doing damage to other players.
|
|
||||||
|
|
||||||
-- Money related
|
|
||||||
startingCash = 2500, -- default cash the character will start with if the character creator doesn't specify it.
|
|
||||||
startingBank = 8000,-- default money in the bank account the character will start with if the character creator doesn't specify it.
|
|
||||||
|
|
||||||
-- If you'd like to whitelist certain roles on discord then set this to true and add role ids.
|
|
||||||
enableDiscordWhitelist = false,
|
|
||||||
notWhitelistedMessage = "You're not allowlisted in this server please join our discord to apply for a allowlist: https://discord.gg/Z9Mxu72zZ6",
|
|
||||||
whitelistRoles = {
|
|
||||||
"872921520719142932"
|
|
||||||
},
|
|
||||||
|
|
||||||
-- These are admins roles that will give a user permission to admin commands and more.
|
|
||||||
adminRoles = {
|
|
||||||
"872921520719142932"
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Discord Rich presence
|
|
||||||
enableRichPresence = true,
|
|
||||||
updateIntervall = 60, -- how many seconds of delay until it updates status.
|
|
||||||
appId = 858146067018416128,
|
|
||||||
largeLogo = "andyyy",
|
|
||||||
smallLogo = "andyyy",
|
|
||||||
firstButtonName = "DISCORD",
|
|
||||||
firstButtonLink = "https://discord.gg/Z9Mxu72zZ6",
|
|
||||||
secondButtonName = "TEBEX",
|
|
||||||
secondButtonLink = "https://andyyy.tebex.io/category/fivem-scripts",
|
|
||||||
|
|
||||||
|
|
||||||
-- Groups can be gangs, jobs, subdivisions, etc.
|
|
||||||
groups = {
|
|
||||||
["Ballas"] = {
|
|
||||||
"Member", -- rank 1
|
|
||||||
"Boss" -- rank 2
|
|
||||||
},
|
|
||||||
["SWAT"] = {
|
|
||||||
"Member", -- rank 1
|
|
||||||
"Sniper", -- rank 2
|
|
||||||
"Team lead", -- rank 3
|
|
||||||
"Commander" -- rank 4
|
|
||||||
},
|
|
||||||
["SAHP"] = {
|
|
||||||
"Trooper",
|
|
||||||
"Senior Trooper",
|
|
||||||
"Corporal",
|
|
||||||
"Sergeant",
|
|
||||||
"Lieutenant",
|
|
||||||
"Cheif"
|
|
||||||
},
|
|
||||||
["LSPD"] = {
|
|
||||||
"Officer",
|
|
||||||
"Senior officer",
|
|
||||||
"Corporal",
|
|
||||||
"Sergeant",
|
|
||||||
"Lieutenant",
|
|
||||||
"Cheif"
|
|
||||||
},
|
|
||||||
["BCSO"] = {
|
|
||||||
"Deputy",
|
|
||||||
"Senior Deputy",
|
|
||||||
"Corporal",
|
|
||||||
"Sergeant",
|
|
||||||
"Lieutenant",
|
|
||||||
"Cheif"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
|
||||||
|
|
||||||
server_config = {
|
|
||||||
discordServerToken = "OTAwODg1MDMxMDQ2Nzc0ODQ1.GU1TSC.Ed8D2_wcU-UQ1vZhe1khahgV8J3hLahOp4N1D8", -- discord bot token for permissions
|
|
||||||
guildId = "872496972454592523", -- discord guild id
|
|
||||||
}
|
|
||||||
@@ -8,8 +8,8 @@ CREATE TABLE IF NOT EXISTS `nd_characters` (
|
|||||||
`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 '[]',
|
`groups` LONGTEXT DEFAULT ('[]'),
|
||||||
`metadata` LONGTEXT DEFAULT '[]',
|
`metadata` LONGTEXT DEFAULT ('[]'),
|
||||||
`inventory` LONGTEXT DEFAULT '[]',
|
`inventory` LONGTEXT DEFAULT ('[]'),
|
||||||
PRIMARY KEY (`charid`) USING BTREE
|
PRIMARY KEY (`charid`) USING BTREE
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ 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.0"
|
version "2.0.2"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
@@ -38,5 +38,7 @@ files {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependency "oxmysql"
|
dependency "oxmysql"
|
||||||
|
|
||||||
|
-- below were used with backwards compatibility but could interfere with resources checking if the resources are started.
|
||||||
-- provide "es_extended"
|
-- provide "es_extended"
|
||||||
-- provide "qb-Core"
|
-- provide "qb-Core"
|
||||||
|
|||||||
@@ -194,27 +194,50 @@ end)
|
|||||||
lib.addCommand("pay", {
|
lib.addCommand("pay", {
|
||||||
help = "give money to nearby player.",
|
help = "give money to nearby player.",
|
||||||
params = {
|
params = {
|
||||||
|
{
|
||||||
|
name = "target",
|
||||||
|
type = "playerId",
|
||||||
|
help = "Target player's server id"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name = "amount",
|
name = "amount",
|
||||||
type = "number"
|
type = "number",
|
||||||
|
help = "Amount of cash to give"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, function(source, args, raw)
|
}, function(source, args, raw)
|
||||||
if not source then return end
|
if not source then return end
|
||||||
local targetPlayer
|
|
||||||
local pedCoords = GetEntityCoords(GetPlayerPed(source))
|
|
||||||
for targetId, targetInfo in pairs(NDCore.players) do
|
|
||||||
local targetCoords = GetEntityCoords(GetPlayerPed(targetId))
|
|
||||||
if #(pedCoords-targetCoords) < 2.0 and targetId ~= source then
|
|
||||||
targetPlayer = targetInfo
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local player = NDCore.getPlayer(source)
|
local player = NDCore.getPlayer(source)
|
||||||
if not player then return end
|
local targetPlayer = NDCore.getPlayer(args.target)
|
||||||
local success = player.deductMoney("cash", args.amount)
|
|
||||||
|
|
||||||
|
if not player or not targetPlayer then
|
||||||
|
return player.notify({
|
||||||
|
title = "Error",
|
||||||
|
description = "No player found",
|
||||||
|
type = "error"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if player.cash < args.amount then
|
||||||
|
return player.notify({
|
||||||
|
title = "Error",
|
||||||
|
description = "You don't have enough cash",
|
||||||
|
type = "error"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local playerCoords = GetEntityCoords(GetPlayerPed(player.source))
|
||||||
|
local targetCoords = GetEntityCoords(GetPlayerPed(targetPlayer.source))
|
||||||
|
if #(playerCoords-targetCoords) > 2.0 then
|
||||||
|
return player.notify({
|
||||||
|
title = "Error",
|
||||||
|
description = "Player is not nearby",
|
||||||
|
type = "error"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local success = player.deductMoney("cash", args.amount) and targetPlayer.addMoney("cash", args.amount)
|
||||||
if not success then
|
if not success then
|
||||||
return player.notify({
|
return player.notify({
|
||||||
title = "Couldn't give money",
|
title = "Couldn't give money",
|
||||||
@@ -223,19 +246,18 @@ lib.addCommand("pay", {
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if not targetPlayer or not targetPlayer.addMoney("cash", args.amount) then return end
|
|
||||||
targetPlayer.notify({
|
targetPlayer.notify({
|
||||||
title = "Money received",
|
title = "Money received",
|
||||||
description = ("Received $%d in cash"):format(args.amount),
|
description = ("Received $%d in cash"):format(args.amount),
|
||||||
type = "inform",
|
type = "inform",
|
||||||
duration = 10000
|
duration = 5000
|
||||||
})
|
})
|
||||||
|
|
||||||
player.notify({
|
player.notify({
|
||||||
title = "Money given",
|
title = "Money given",
|
||||||
description = ("You gave someone $%d in cash"):format(args.amount),
|
description = ("You gave $%d in cash"):format(args.amount),
|
||||||
type = "inform",
|
type = "inform",
|
||||||
duration = 10000
|
duration = 5000
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
|
||||||
|
|
||||||
-- Check if discord is connected, and if whitelist is enabled then it will only allow you to join if you have the roles.
|
|
||||||
AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
|
||||||
local player = source
|
|
||||||
local discordIdentifier = NDCore.Functions.GetPlayerIdentifierFromType("discord", player)
|
|
||||||
|
|
||||||
deferrals.defer()
|
|
||||||
Wait(0)
|
|
||||||
deferrals.update("Connecting to discord.")
|
|
||||||
Wait(0)
|
|
||||||
|
|
||||||
if not discordIdentifier then
|
|
||||||
deferrals.done("Your discord isn't connected to FiveM, make sure discord is open and restart FiveM.")
|
|
||||||
else
|
|
||||||
if config.enableDiscordWhitelist then
|
|
||||||
local discordUserId = discordIdentifier:gsub("discord:", "")
|
|
||||||
local discordInfo = NDCore.Functions.GetUserDiscordInfo(discordUserId)
|
|
||||||
for _, whitelistRole in pairs(config.whitelistRoles) do
|
|
||||||
if whitelistRole == 0 or whitelistRole == "0" or (discordInfo and discordInfo.roles[whitelistRole]) then
|
|
||||||
deferrals.done()
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
deferrals.done(config.notWhitelistedMessage)
|
|
||||||
else
|
|
||||||
deferrals.done()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Getting all the characters the player has and returning them to the client.
|
|
||||||
RegisterNetEvent("ND:GetCharacters", function()
|
|
||||||
local player = source
|
|
||||||
TriggerClientEvent("ND:returnCharacters", player, NDCore.Functions.GetPlayerCharacters(player))
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Creating a new character.
|
|
||||||
RegisterNetEvent("ND:newCharacter", function(newCharacter)
|
|
||||||
local player = source
|
|
||||||
NDCore.Functions.CreateCharacter(player, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.cash, newCharacter.bank)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Update the character info when edited.
|
|
||||||
RegisterNetEvent("ND:editCharacter", function(newCharacter)
|
|
||||||
local player = source
|
|
||||||
local characters = NDCore.Functions.GetPlayerCharacters(player)
|
|
||||||
if not characters[newCharacter.id] then return end
|
|
||||||
NDCore.Functions.UpdateCharacterData(newCharacter.id, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Delete character from database.
|
|
||||||
RegisterNetEvent("ND:deleteCharacter", function(characterId)
|
|
||||||
local player = source
|
|
||||||
local characters = NDCore.Functions.GetPlayerCharacters(player)
|
|
||||||
if not characters[characterId] then return end
|
|
||||||
NDCore.Functions.DeleteCharacter(characterId)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- add a player to the table.
|
|
||||||
RegisterNetEvent("ND:setCharacterOnline", function(id)
|
|
||||||
local player = source
|
|
||||||
local characters = NDCore.Functions.GetPlayerCharacters(player)
|
|
||||||
if not characters[id] then return end
|
|
||||||
NDCore.Functions.SetActiveCharacter(player, id)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Update the characters clothes.
|
|
||||||
RegisterNetEvent("ND:updateClothes", function(clothing)
|
|
||||||
local player = source
|
|
||||||
local character = NDCore.Players[player]
|
|
||||||
NDCore.Functions.SetPlayerData(character.id, "clothing", clothing)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Disconnecting a player
|
|
||||||
RegisterNetEvent("ND:exitGame", function()
|
|
||||||
local player = source
|
|
||||||
DropPlayer(player, "Disconnected.")
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Remove player from NDCore.Players table when they leave.
|
|
||||||
AddEventHandler("playerDropped", function()
|
|
||||||
local player = source
|
|
||||||
local character = NDCore.Players[player]
|
|
||||||
if character then
|
|
||||||
local ped = GetPlayerPed(player)
|
|
||||||
local lastLocation = GetEntityCoords(ped)
|
|
||||||
NDCore.Functions.UpdateLastLocation(character.id, {x = lastLocation.x, y = lastLocation.y, z = lastLocation.z})
|
|
||||||
end
|
|
||||||
TriggerEvent("ND:characterUnloaded", player, character)
|
|
||||||
character = nil
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Get player discord info on join.
|
|
||||||
AddEventHandler("playerJoining", function()
|
|
||||||
local src = source
|
|
||||||
|
|
||||||
local discordUserId = NDCore.Functions.GetPlayerIdentifierFromType("discord", src):gsub("discord:", "")
|
|
||||||
local discordInfo = NDCore.Functions.GetUserDiscordInfo(discordUserId)
|
|
||||||
|
|
||||||
NDCore.PlayersDiscordInfo[src] = discordInfo
|
|
||||||
end)
|
|
||||||
|
|
||||||
AddEventHandler("onResourceStart", function(resourceName)
|
|
||||||
if (GetCurrentResourceName() ~= resourceName) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
Wait(1000)
|
|
||||||
|
|
||||||
if not next(NDCore.PlayersDiscordInfo) then
|
|
||||||
for _, playerId in ipairs(GetPlayers()) do
|
|
||||||
local discordUserId = NDCore.Functions.GetPlayerIdentifierFromType("discord", playerId):gsub("discord:", "")
|
|
||||||
local discordInfo = NDCore.Functions.GetUserDiscordInfo(discordUserId)
|
|
||||||
NDCore.PlayersDiscordInfo[tonumber(playerId)] = discordInfo
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
@@ -34,6 +34,13 @@ function NDCore.getPlayerServerInfo(source)
|
|||||||
return PlayersInfo[source]
|
return PlayersInfo[source]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function NDCore.getConfig(info)
|
||||||
|
if not info then
|
||||||
|
return Config
|
||||||
|
end
|
||||||
|
return Config[info]
|
||||||
|
end
|
||||||
|
|
||||||
---@param fileLocation string|tabale
|
---@param fileLocation string|tabale
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function NDCore.loadSQL(fileLocation, resource)
|
function NDCore.loadSQL(fileLocation, resource)
|
||||||
|
|||||||
@@ -46,8 +46,9 @@ end
|
|||||||
|
|
||||||
AddEventHandler("playerJoining", function(oldId)
|
AddEventHandler("playerJoining", function(oldId)
|
||||||
local src = source
|
local src = source
|
||||||
PlayersInfo[src] = tempPlayersInfo[oldId]
|
local oldTempId = tonumber(oldId)
|
||||||
tempPlayersInfo[oldId] = nil
|
PlayersInfo[src] = tempPlayersInfo[oldTempId]
|
||||||
|
tempPlayersInfo[oldTempId] = nil
|
||||||
|
|
||||||
if Config.multiCharacter then return end
|
if Config.multiCharacter then return end
|
||||||
Wait(3000)
|
Wait(3000)
|
||||||
@@ -93,12 +94,12 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
|||||||
local tempSrc = source
|
local tempSrc = source
|
||||||
local identifiers = getIdentifierList(tempSrc)
|
local identifiers = getIdentifierList(tempSrc)
|
||||||
local mainIdentifier = identifiers[Config.characterIdentifier]
|
local mainIdentifier = identifiers[Config.characterIdentifier]
|
||||||
local discordInfo = {}
|
local discordInfo = nil
|
||||||
|
|
||||||
deferrals.defer()
|
deferrals.defer()
|
||||||
Wait(0)
|
Wait(0)
|
||||||
|
|
||||||
if mainIdentifier and Config.discordBotToken ~= "false" and Config.discordGuildId ~= "false" and not discordInfo 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 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))
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ local function createCharacterTable(info)
|
|||||||
|
|
||||||
-- Save character information to database
|
-- Save character information to database
|
||||||
function self.save()
|
function self.save()
|
||||||
local affectedRows = MySQL.update.await("UPDATE nd_characters SET name = ?, firstname = ?, lastname = ?, dob = ?, gender = ?, cash = ?, bank = ?, groups = ?, metadata = ? WHERE charid = ?", {
|
local affectedRows = MySQL.update.await("UPDATE nd_characters SET name = ?, firstname = ?, lastname = ?, dob = ?, gender = ?, cash = ?, bank = ?, `groups` = ?, metadata = ? WHERE charid = ?", {
|
||||||
self.name,
|
self.name,
|
||||||
self.firstname,
|
self.firstname,
|
||||||
self.lastname,
|
self.lastname,
|
||||||
@@ -309,20 +309,28 @@ local function createCharacterTable(info)
|
|||||||
---@return boolean
|
---@return boolean
|
||||||
function self.addGroup(name, rank, isJob)
|
function self.addGroup(name, rank, isJob)
|
||||||
local groupRank = tonumber(rank) or 1
|
local groupRank = tonumber(rank) or 1
|
||||||
local groupInfo = Config.groups[name]
|
local groupInfo = Config.groups?[name]
|
||||||
|
local bossRank = groupInfo and groupInfo.minimumBossRank
|
||||||
|
|
||||||
-- if not groupInfo then return 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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.groups[name] = {
|
self.groups[name] = {
|
||||||
|
name = name,
|
||||||
label = groupInfo and groupInfo.label or name,
|
label = groupInfo and groupInfo.label or name,
|
||||||
rankName = groupInfo and groupInfo.ranks[groupRank] or groupRank,
|
rankName = groupInfo and groupInfo.ranks[groupRank] or groupRank,
|
||||||
rank = groupRank,
|
rank = groupRank,
|
||||||
isJob = isJob
|
isJob = isJob,
|
||||||
|
isBoss = bossRank and groupRank >= bossRank
|
||||||
}
|
}
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
|
||||||
|
if not isJob then
|
||||||
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
|
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
|
||||||
@@ -337,6 +345,12 @@ local function createCharacterTable(info)
|
|||||||
function self.removeGroup(name)
|
function self.removeGroup(name)
|
||||||
local group = self.groups[name]
|
local group = self.groups[name]
|
||||||
if not group then return end
|
if not group then return end
|
||||||
|
|
||||||
|
if self.job == name then
|
||||||
|
self.job = nil
|
||||||
|
self.jobInfo = nil
|
||||||
|
end
|
||||||
|
|
||||||
self.groups[name] = nil
|
self.groups[name] = nil
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
lib.removePrincipal(self.source, ("group.%s"):format(name))
|
lib.removePrincipal(self.source, ("group.%s"):format(name))
|
||||||
@@ -349,11 +363,11 @@ local function createCharacterTable(info)
|
|||||||
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, true)
|
||||||
local jobName, jobInfo = self.getJob()
|
if job then
|
||||||
if jobInfo then
|
self.job = job.name
|
||||||
self.job = jobName
|
self.jobInfo = job
|
||||||
self.jobInfo = jobInfo
|
|
||||||
end
|
end
|
||||||
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
return job
|
return job
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -398,7 +412,7 @@ function NDCore.newCharacter(src, info)
|
|||||||
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, `groups`, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", {
|
||||||
identifier,
|
identifier,
|
||||||
charInfo.name,
|
charInfo.name,
|
||||||
charInfo.firstname,
|
charInfo.firstname,
|
||||||
|
|||||||
@@ -567,12 +567,24 @@ RegisterNetEvent("ND_Vehicles:toggleVehicleLock", function(netId)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- locking of npc vehicles, if the players spawns inside a vehicle it won't be locked.
|
-- locking of npc vehicles, if the players spawns inside a vehicle it won't be locked.
|
||||||
RegisterNetEvent("entityCreated", function(entity)
|
AddEventHandler("entityCreated", function(entity)
|
||||||
|
local time = os.time()
|
||||||
|
while not DoesEntityExist(entity) and os.time()-time < 5 do Wait(50) end
|
||||||
|
|
||||||
if not DoesEntityExist(entity) or GetEntityType(entity) ~= 2 then return end
|
if not DoesEntityExist(entity) or GetEntityType(entity) ~= 2 then return end
|
||||||
|
|
||||||
local state = Entity(entity).state
|
local state = Entity(entity).state
|
||||||
if state.owner or state.locked ~= nil then return end
|
if state.owner or state.locked ~= nil then return end
|
||||||
|
|
||||||
|
time = os.time()
|
||||||
local driver = GetPedInVehicleSeat(entity, -1)
|
local driver = GetPedInVehicleSeat(entity, -1)
|
||||||
|
while DoesEntityExist(entity) and driver == 0 and os.time()-time < 2 do
|
||||||
|
driver = GetPedInVehicleSeat(entity, -1)
|
||||||
|
Wait(100)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not DoesEntityExist(entity) then return end
|
||||||
|
|
||||||
if DoesEntityExist(driver) and IsPedAPlayer(driver) then
|
if DoesEntityExist(driver) and IsPedAPlayer(driver) then
|
||||||
state.locked = false
|
state.locked = false
|
||||||
state.hotwired = true
|
state.hotwired = true
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
NDCore = exports["ND_Core"]:GetCoreObject()
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
local startedResources = {}
|
|
||||||
local callbacks = {}
|
|
||||||
|
|
||||||
AddEventHandler("onResourceStart", function(resourceName)
|
|
||||||
startedResources[resourceName] = true
|
|
||||||
local callback = callbacks[resourceName]
|
|
||||||
if not callback then return end
|
|
||||||
callback(true)
|
|
||||||
end)
|
|
||||||
|
|
||||||
AddEventHandler("onResourceStop", function(resourceName)
|
|
||||||
startedResources[resourceName] = nil
|
|
||||||
local callback = callbacks[resourceName]
|
|
||||||
if not callback then return end
|
|
||||||
callback(false)
|
|
||||||
end)
|
|
||||||
|
|
||||||
function isResourceStarted(resourceName, cb)
|
|
||||||
local started = GetResourceState(resourceName) == "started"
|
|
||||||
startedResources[resourceName] = started
|
|
||||||
|
|
||||||
if cb then
|
|
||||||
callbacks[resourceName] = cb
|
|
||||||
cb(started)
|
|
||||||
end
|
|
||||||
|
|
||||||
return started
|
|
||||||
end
|
|
||||||
|
|
||||||
exports("isResourceStarted", isResourceStarted)
|
|
||||||
Reference in New Issue
Block a user