mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 13:56:02 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9d8826188 | ||
|
|
7412c14976 | ||
|
|
5242cf289d | ||
|
|
906383bbd9 | ||
|
|
a5b297e6f8 | ||
|
|
4551db736c | ||
|
|
30ac126949 | ||
|
|
220ecbbce1 | ||
|
|
9a7afdbc8f |
@@ -1,4 +1,4 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://user-images.githubusercontent.com/86536434/193703880-5cb7deef-af37-42cc-8df2-b13332afee67.png" />
|
<img src="https://user-images.githubusercontent.com/86536434/193703880-5cb7deef-af37-42cc-8df2-b13332afee67.png" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,27 @@ function NDCore.Functions.GetCharacters()
|
|||||||
return NDCore.Characters
|
return NDCore.Characters
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function NDCore.Functions.GetPlayersFromCoords(distance, coords)
|
||||||
|
if coords then
|
||||||
|
coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
|
||||||
|
else
|
||||||
|
coords = GetEntityCoords(PlayerPedId())
|
||||||
|
end
|
||||||
|
distance = distance or 5
|
||||||
|
local closePlayers = {}
|
||||||
|
local players = GetActivePlayers()
|
||||||
|
for _, player in ipairs(players) do
|
||||||
|
local target = GetPlayerPed(player)
|
||||||
|
local targetCoords = GetEntityCoords(target)
|
||||||
|
local targetdistance = #(targetCoords - coords)
|
||||||
|
if targetdistance <= distance then
|
||||||
|
closePlayers[#closePlayers + 1] = player
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return closePlayers
|
||||||
|
end
|
||||||
|
|
||||||
-- Callbacks are licensed under LGPL v3.0
|
-- Callbacks are licensed under LGPL v3.0
|
||||||
-- <https://github.com/overextended/ox_lib>
|
-- <https://github.com/overextended/ox_lib>
|
||||||
NDCore.callback = {}
|
NDCore.callback = {}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
author "Andyyy#7666, N1K0#0001"
|
author "Andyyy#7666, N1K0#0001"
|
||||||
description "ND Framework Core"
|
description "ND Framework Core"
|
||||||
version "1.0.0"
|
version "1.0.3"
|
||||||
|
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ AddEventHandler("playerDropped", function()
|
|||||||
local player = source
|
local player = source
|
||||||
local character = NDCore.Players[player]
|
local character = NDCore.Players[player]
|
||||||
if character then
|
if character then
|
||||||
NDCore.Functions.UpdateLastLocation(character.id, character.lastLocation)
|
local ped = GetPlayerPed(player)
|
||||||
|
local lastLocation = GetEntityCoords(ped)
|
||||||
|
NDCore.Functions.UpdateLastLocation(character.id, {x = lastLocation.x, y = lastLocation.y, z = lastLocation.z})
|
||||||
end
|
end
|
||||||
TriggerEvent("ND:characterUnloaded", player, character)
|
TriggerEvent("ND:characterUnloaded", player, character)
|
||||||
character = nil
|
character = nil
|
||||||
|
|||||||
@@ -343,16 +343,12 @@ function NDCore.Functions.GetPlayerCharacters(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Creates a new character for the player and returns all their characters to the client.
|
-- Creates a new character for the player and returns all their characters to the client.
|
||||||
function NDCore.Functions.CreateCharacter(player, firstName, lastName, dob, gender, cash, bank, cb)
|
function NDCore.Functions.CreateCharacter(player, firstName, lastName, dob, gender, cb)
|
||||||
local characterId = false
|
local characterId = false
|
||||||
local license = NDCore.Functions.GetPlayerIdentifierFromType("license", player)
|
local license = NDCore.Functions.GetPlayerIdentifierFromType("license", player)
|
||||||
if not cash or not bank or tonumber(cash) > config.startingCash or tonumber(bank) > config.startingBank then
|
|
||||||
cash = config.startingCash
|
|
||||||
bank = config.startingBank
|
|
||||||
end
|
|
||||||
local result = MySQL.query.await("SELECT character_id FROM characters WHERE license = ?", {license})
|
local result = MySQL.query.await("SELECT character_id FROM characters WHERE license = ?", {license})
|
||||||
if result and config.characterLimit > #result then
|
if result and config.characterLimit > #result then
|
||||||
characterId = MySQL.insert.await("INSERT INTO characters (license, first_name, last_name, dob, gender, cash, bank) VALUES (?, ?, ?, ?, ?, ?, ?)", {license, firstName, lastName, dob, gender, cash, bank})
|
characterId = MySQL.insert.await("INSERT INTO characters (license, first_name, last_name, dob, gender, cash, bank, data) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", {license, firstName, lastName, dob, gender, config.startingCash, config.startingBank, json.encode({groups={}})})
|
||||||
if cb then cb(characterId) end
|
if cb then cb(characterId) end
|
||||||
TriggerClientEvent("ND:returnCharacters", player, NDCore.Functions.GetPlayerCharacters(player))
|
TriggerClientEvent("ND:returnCharacters", player, NDCore.Functions.GetPlayerCharacters(player))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,20 +11,6 @@ function GetCoreObject()
|
|||||||
return NDCore
|
return NDCore
|
||||||
end
|
end
|
||||||
|
|
||||||
CreateThread(function()
|
|
||||||
while true do
|
|
||||||
Wait(30000)
|
|
||||||
for player, playerInfo in pairs(NDCore.Players) do
|
|
||||||
local ped = GetPlayerPed(player)
|
|
||||||
if DoesEntityExist(ped) then
|
|
||||||
local lastLocation = GetEntityCoords(ped)
|
|
||||||
playerInfo.lastLocation = {x = lastLocation.x, y = lastLocation.y, z = lastLocation.z}
|
|
||||||
TriggerClientEvent("ND:updateLastLocation", player, playerInfo.lastLocation)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
isResourceStarted("ox_inventory", function(started)
|
isResourceStarted("ox_inventory", function(started)
|
||||||
if not started then return end
|
if not started then return end
|
||||||
SetConvarReplicated("inventory:framework", "nd")
|
SetConvarReplicated("inventory:framework", "nd")
|
||||||
|
|||||||
Reference in New Issue
Block a user