mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +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" />
|
||||
</p>
|
||||
|
||||
|
||||
@@ -10,6 +10,27 @@ function NDCore.Functions.GetCharacters()
|
||||
return NDCore.Characters
|
||||
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
|
||||
-- <https://github.com/overextended/ox_lib>
|
||||
NDCore.callback = {}
|
||||
@@ -56,4 +77,4 @@ function NDCore.callback.register(name, callback)
|
||||
RegisterNetEvent(("ND:%s_cb"):format(name), function(key, ...)
|
||||
TriggerServerEvent("ND:callbacks", key, callback(...))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
author "Andyyy#7666, N1K0#0001"
|
||||
description "ND Framework Core"
|
||||
version "1.0.0"
|
||||
version "1.0.3"
|
||||
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
@@ -36,4 +36,4 @@ server_exports {
|
||||
"GetCoreObject"
|
||||
}
|
||||
|
||||
dependency "oxmysql"
|
||||
dependency "oxmysql"
|
||||
|
||||
@@ -83,7 +83,9 @@ AddEventHandler("playerDropped", function()
|
||||
local player = source
|
||||
local character = NDCore.Players[player]
|
||||
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
|
||||
TriggerEvent("ND:characterUnloaded", player, character)
|
||||
character = nil
|
||||
|
||||
@@ -343,16 +343,12 @@ function NDCore.Functions.GetPlayerCharacters(player)
|
||||
end
|
||||
|
||||
-- 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 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})
|
||||
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
|
||||
TriggerClientEvent("ND:returnCharacters", player, NDCore.Functions.GetPlayerCharacters(player))
|
||||
end
|
||||
@@ -767,4 +763,4 @@ function NDCore.callback.register(name, callback)
|
||||
local src = source
|
||||
TriggerClientEvent("ND:callbacks", src, key, callback(src, ...))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,20 +11,6 @@ function GetCoreObject()
|
||||
return NDCore
|
||||
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)
|
||||
if not started then return end
|
||||
SetConvarReplicated("inventory:framework", "nd")
|
||||
|
||||
Reference in New Issue
Block a user