revert, 2.0.0 is in new branch

This commit is contained in:
Andyyy7666
2023-07-10 02:40:39 +02:00
parent 593443cae5
commit 5389ae0962
13 changed files with 1265 additions and 78 deletions

View File

@@ -4,29 +4,21 @@ end)
-- updates the money on the client.
RegisterNetEvent("ND:updateMoney", function(cash, bank)
NDCore.player.cash = cash
NDCore.player.bank = bank
NDCore.SelectedCharacter.cash = cash
NDCore.SelectedCharacter.bank = bank
end)
-- Sets main character.
RegisterNetEvent("ND:setCharacter", function(character)
NDCore.player = character
NDCore.SelectedCharacter = character
end)
-- Update main character info.
RegisterNetEvent("ND:updateCharacter", function(character)
NDCore.player = character
NDCore.SelectedCharacter = character
end)
-- Updates last lcoation.
RegisterNetEvent("ND:updateLastLocation", function(location)
if not NDCore.player then return end
NDCore.player.lastLocation = location
NDCore.SelectedCharacter.lastLocation = location
end)
-- Enable pvp for players.
AddEventHandler("playerSpawned", function()
print("^0ND Framework support discord: ^5https://discord.gg/Z9Mxu72zZ6")
SetCanAttackFriendly(PlayerPedId(), true, false)
NetworkSetFriendlyFireOption(true)
end)

View File

@@ -1,6 +1,19 @@
function NDCore.GetPlayersFromCoords(distance, coords)
function GetCoreObject()
return NDCore
end
function NDCore.Functions.GetSelectedCharacter()
return NDCore.SelectedCharacter
end
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
coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
else
coords = GetEntityCoords(PlayerPedId())
end
@@ -17,3 +30,51 @@ function NDCore.GetPlayersFromCoords(distance, coords)
end
return closePlayers
end
-- Callbacks are licensed under LGPL v3.0
-- <https://github.com/overextended/ox_lib>
NDCore.callback = {}
local events = {}
RegisterNetEvent("ND:callbacks", function(key, ...)
local cb = events[key]
return cb and cb(...)
end)
local function triggerCallback(_, name, cb, ...)
local key = ("%s:%s"):format(name, math.random(0, 100000))
TriggerServerEvent(("ND:%s_cb"):format(name), key, ...)
local promise = not cb and promise.new()
events[key] = function(response, ...)
response = { response, ... }
events[key] = nil
if promise then
return promise:resolve(response)
end
if cb then
cb(table.unpack(response))
end
end
if promise then
return table.unpack(Citizen.Await(promise))
end
end
setmetatable(NDCore.callback, {
__call = triggerCallback
})
function NDCore.callback.await(name, ...)
return triggerCallback(nil, name, false, ...)
end
function NDCore.callback.register(name, callback)
RegisterNetEvent(("ND:%s_cb"):format(name), function(key, ...)
TriggerServerEvent("ND:callbacks", key, callback(...))
end)
end

View File

@@ -1,36 +1,54 @@
CreateThread(function()
SetDiscordAppId(Config.discordAppId)
SetDiscordRichPresenceAsset(Config.discordAsset)
SetDiscordRichPresenceAssetSmall(Config.discordAssetSmall)
SetDiscordRichPresenceAction(0, Config.discordActionText, Config.discordActionLink)
SetDiscordRichPresenceAction(1, Config.discordActionText2, Config.discordActionLink2)
local presenceText = ("Playing: %s"):format(Config.serverName)
while true do
if NDCore.player then
local presence = ("Playing: %s as % %"):format(Config.serverName, NDCore.player.firstname, NDCore.player.lastname)
local presenceTextSmall = ("Playing as: %s %s"):format(NDCore.player.firstname, NDCore.player.lastname)
SetRichPresence(presence)
SetDiscordRichPresenceAssetText(presenceText)
SetDiscordRichPresenceAssetSmallText(presenceTextSmall)
end
Wait(60000)
end
end)
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
CreateThread(function()
AddTextEntry("FE_THDR_GTAO", Config.serverName)
local sleep = 500
while true do
Wait(sleep)
if NDCore.player and IsPauseMenuActive() then
sleep = 0
BeginScaleformMovieMethodOnFrontendHeader("SET_HEADING_DETAILS")
ScaleformMovieMethodAddParamPlayerNameString(("%s %s"):format(NDCore.player.firstname, NDCore.player.lastname))
PushScaleformMovieFunctionParameterString(("Cash: $%d"):format(NDCore.player.cash))
PushScaleformMovieFunctionParameterString(("Bank: $%d"):format(NDCore.player.bank))
EndScaleformMovieMethod()
elseif sleep == 0 then
sleep = 500
NDCore = {}
NDCore.SelectedCharacter = nil
NDCore.Characters = {}
NDCore.Functions = {}
NDCore.Config = config
-- discord rich precense will show on a users profile.
if config.enableRichPresence then
Citizen.CreateThread(function()
while true do
if NDCore.SelectedCharacter then
SetDiscordAppId(config.appId)
SetRichPresence(" Playing : " .. config.serverName .. " as " .. NDCore.SelectedCharacter.firstName .. " " .. NDCore.SelectedCharacter.lastName)
SetDiscordRichPresenceAsset(config.largeLogo)
SetDiscordRichPresenceAssetText("Playing: " .. config.serverName)
SetDiscordRichPresenceAssetSmall(config.smallLogo)
SetDiscordRichPresenceAssetSmallText("Playing as: " .. NDCore.SelectedCharacter.firstName .. " " .. NDCore.SelectedCharacter.lastName)
SetDiscordRichPresenceAction(0, config.firstButtonName, config.firstButtonLink)
SetDiscordRichPresenceAction(1, config.secondButtonName, config.secondButtonLink)
end
Citizen.Wait(config.updateIntervall * 1000)
end
end)
end
-- show server name, first name, last name, and the amount of money the character has in the pause menu.
if config.customPauseMenu then
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if NDCore.SelectedCharacter then
if IsPauseMenuActive() then
BeginScaleformMovieMethodOnFrontendHeader("SET_HEADING_DETAILS")
AddTextEntry("FE_THDR_GTAO", config.serverName)
ScaleformMovieMethodAddParamPlayerNameString(NDCore.SelectedCharacter.firstName .. " " .. NDCore.SelectedCharacter.lastName)
PushScaleformMovieFunctionParameterString("Cash: $" .. tostring(NDCore.SelectedCharacter.cash))
PushScaleformMovieFunctionParameterString("Bank: $" .. tostring(NDCore.SelectedCharacter.bank))
EndScaleformMovieMethod()
end
end
end
end)
end
-- Enables pvp if it's selected in the config.
AddEventHandler("playerSpawned", function()
if config.enablePVP then
SetCanAttackFriendly(PlayerPedId(), true, false)
NetworkSetFriendlyFireOption(true)
end
end)
print("^0This framework is created by ^5Andyyy#7666 ^0for support you can join the ^5discord: ^0https://discord.gg/Z9Mxu72zZ6")
end)