diff --git a/ND_Core/source/client/main.lua b/ND_Core/source/client/main.lua index ace3b74..c0938c0 100644 --- a/ND_Core/source/client/main.lua +++ b/ND_Core/source/client/main.lua @@ -8,7 +8,6 @@ local background = config.backgrounds[math.random(1, #config.backgrounds)] local started = true registered = false -admin = false cash = nil bank = nil @@ -16,27 +15,27 @@ bank = nil RegisterNetEvent("permsChecked") AddEventHandler("permsChecked", function(role, rolePermission) if rolePermission then - if role == "ADMIN" then - admin = true - else - SendNUIMessage({ - type = "givePerms", - deptRole = role - }) - end + SendNUIMessage({ + type = "givePerms", + deptRole = role + }) end end) +RegisterNetEvent("refreshCharacters") +AddEventHandler("refreshCharacters", function() + TriggerServerEvent("getCharacters") +end) + Citizen.CreateThread(function() while started do Citizen.Wait(200) local ped = PlayerPedId() if IsPedOnFoot(ped) or IsPedInVehicle(ped, GetVehiclePedIsIn(ped, false), false) then print("^0This framework is created by ^5Andyyy#7666 ^0for support you can join the ^5discord: ^0https://discord.gg/Z9Mxu72zZ6") - for i = 1, #config.departments do -- if you have an error that says attempt to index a nil value (global 'config') it's beacuse you have edited the config wrong. - TriggerServerEvent("checkPerms", config.departments[i]) -- check permissions for each department with the department names. + for departmentName in pairs(config.departments) do -- if you have an error that says attempt to index a nil value (global 'config') it's beacuse you have edited the config wrong. + TriggerServerEvent("checkPerms", config.departments[departmentName]) -- check permissions for each department with the department names. end - TriggerServerEvent("checkPerms", "ADMIN") -- check if the player has the admin role. TriggerServerEvent("getCharacters") Citizen.Wait(100) TriggerServerEvent("getAop") @@ -46,6 +45,7 @@ Citizen.CreateThread(function() started = false SendNUIMessage({ type = "onStart", + enableMoneySystem = config.enableMoneySystem, maxStartingBank = config.maxStartingBank, maxStartingCash = config.maxStartingCash }) @@ -59,25 +59,25 @@ end) RegisterNetEvent("returnCharacters") AddEventHandler("returnCharacters", function(characters) + characterAmount = 0 SendNUIMessage({ type = "refresh" }) - for i = 1, #characters do - index = characters[i] + for _, character in pairs(characters) do SendNUIMessage({ type = "character", - id = index.id, - firstName = index.firstName, - lastName = index.lastName, - dateOfBirth = index.dob, - gender = index.gender, - twtName = index.twt, - department = index.department, - startingCash = index.cash, - startingBank = index.bank + id = character.id, + firstName = character.firstName, + lastName = character.lastName, + dateOfBirth = character.dob, + gender = character.gender, + twtName = character.twt, + department = character.department, + startingCash = character.cash, + startingBank = character.bank }) + characterAmount = characterAmount + 1 end - characterAmount = #characters SetDisplay(true, "ui", background) end) @@ -133,51 +133,82 @@ RegisterNUICallback("setMainCharacter", function(data) mainStartingBank = data.startingBank mainCharaterId = data.character - for i = 1, #config.departments do - validDept = config.departments[i] - if mainDepartment == validDept then - for i = 1, #config.spawns[validDept] do - SendNUIMessage({ - type = "setSpawns", - x = config.spawns[validDept][i].x, - y = config.spawns[validDept][i].y, - z = config.spawns[validDept][i].z, - name = config.spawns[validDept][i].name - }) - end - end + for _, spawn in pairs(config.spawns[mainDepartment]) do + SendNUIMessage({ + type = "setSpawns", + x = spawn.x, + y = spawn.y, + z = spawn.z, + name = spawn.name + }) end TriggerServerEvent("characterOnline", mainCharaterId) + TriggerServerEvent("getPriority") registered = true end) --- This will display the money that the player has. -RegisterNetEvent("returnMoney") -AddEventHandler("returnMoney", function(newCash, newBank) - while not registered do - Citizen.Wait(10) - end - cash = newCash - bank = newBank - if config.legacyMoneyDisplay then - if registered then - while true do - Citizen.Wait(0) - text("💵", 0.885, 0.028, 0.35) - text("💳", 0.885, 0.068, 0.35) - text("~g~$~w~".. cash, 0.91, 0.03, 0.55) - text("~b~$~w~".. bank, 0.91, 0.07, 0.55) - end +if config.enableMoneySystem then + -- This will display the money that the player has. + RegisterNetEvent("returnMoney") + AddEventHandler("returnMoney", function(newCash, newBank) + while not registered do + Citizen.Wait(10) end - else - SendNUIMessage({ - type = "Money", - cash = "Cash: $" .. cash, - bank = "Bank: $" .. bank - }) - end -end) + cash = newCash + bank = newBank + if config.legacyMoneyDisplay then + if registered then + while true do + Citizen.Wait(0) + text("💵", 0.885, 0.028, 0.35, 7) + text("💳", 0.885, 0.068, 0.35, 7) + text("~g~$~w~".. cash, 0.91, 0.03, 0.55, 7) + text("~b~$~w~".. bank, 0.91, 0.07, 0.55, 7) + end + end + else + SendNUIMessage({ + type = "Money", + cash = "Cash: $" .. cash, + bank = "Bank: $" .. bank + }) + end + end) + + -- This is to update the players money on the ui. + RegisterNetEvent("updateMoney") + AddEventHandler("updateMoney", function() + TriggerServerEvent("getMoney", mainCharaterId) + end) + + -- Notification when you recieve money. + RegisterNetEvent("receiveBank") + AddEventHandler("receiveBank", function(amount, playerSending, playerId) + BeginTextCommandThefeedPost("STRING") + AddTextComponentSubstringPlayerName("Received $" .. amount .. " from " .. playerSending .. " [".. playerId .."]") + EndTextCommandThefeedPostMessagetext("CHAR_BANK_FLEECA", "CHAR_BANK_FLEECA", true, 9,"FleecaBank", "") + end) + + -- Notification when you receive cash. + RegisterNetEvent("receiveCash") + AddEventHandler("receiveCash", function(amount, playerSending, playerId) + BeginTextCommandThefeedPost("STRING") + AddTextComponentSubstringPlayerName(playerSending .. " gave you $" .. amount .. ".") + EndTextCommandThefeedPostMessagetext("CHAR_DEFAULT", "CHAR_DEFAULT", true, 9, playerSending .. " [".. playerId .."]", "") + end) + + -- Notification when receiving salary. + RegisterNetEvent("receiveSalary") + AddEventHandler("receiveSalary", function(amount) + if registered then + BeginTextCommandThefeedPost("STRING") + AddTextComponentSubstringPlayerName("Daily Salary + $" .. config.salaryAmount) + EndTextCommandThefeedPostMessagetext("CHAR_BANK_FLEECA", "CHAR_BANK_FLEECA", true, 9,"FleecaBank", "") + TriggerServerEvent("getMoney", mainCharaterId) + end + end) +end -- Teleporting RegisterNUICallback("tpToLocation", function(data) @@ -238,8 +269,24 @@ if config.enableRichPrecence then end) end --- hide gta default cash, ammo and reticle hud. -if config.hideAmmoAndMoney or config.hideReticle then +if config.enablePriorityCooldown then + TriggerEvent("chat:addSuggestion", "/" .. config.startPriorityCommand, "Start a priority.") + TriggerEvent("chat:addSuggestion", "/" .. config.stopPriorityCommand, "Stop an active priority.") + TriggerEvent("chat:addSuggestion", "/" .. config.cooldownPriorityCommand, "Start a cooldown on priorities.", { + {name="Time", help="Time in minutes to start a cooldown"} + }) + + RegisterNetEvent("returnPriority") + AddEventHandler("returnPriority", function(priority) + if config.canSeePriority[mainDepartment] then + priorityText = priority + else + priorityText = nil + end + end) +end + +if config.hideAmmoAndMoney or config.hideReticle or config.customPauseMenu or config.enablePriorityCooldown then Citizen.CreateThread(function() while true do Citizen.Wait(0) @@ -257,48 +304,20 @@ if config.hideAmmoAndMoney or config.hideReticle then BeginScaleformMovieMethodOnFrontendHeader("SET_HEADING_DETAILS") AddTextEntry("FE_THDR_GTAO", config.serverName) ScaleformMovieMethodAddParamPlayerNameString(mainFirstName .. " " .. mainLastName) - --PushScaleformMovieFunctionParameterString("Cash: $" .. cash) - --PushScaleformMovieFunctionParameterString("Bank: $" .. bank) + if registered and config.enableMoneySystem then + PushScaleformMovieFunctionParameterString("Cash: $" .. cash) + PushScaleformMovieFunctionParameterString("Bank: $" .. bank) + end EndScaleformMovieMethod() end end + if config.enablePriorityCooldown and priorityText then + text(priorityText, 0.182, 0.891, 0.4, 4) + end end end) end --- This is to update the players money on the ui. -RegisterNetEvent("updateMoney") -AddEventHandler("updateMoney", function() - TriggerServerEvent("getMoney", mainCharaterId) -end) - --- Notification when you recieve money. -RegisterNetEvent("receiveBank") -AddEventHandler("receiveBank", function(amount, playerSending, playerId) - BeginTextCommandThefeedPost("STRING") - AddTextComponentSubstringPlayerName("Received $" .. amount .. " from " .. playerSending .. " [".. playerId .."]") - EndTextCommandThefeedPostMessagetext("CHAR_BANK_FLEECA", "CHAR_BANK_FLEECA", true, 9,"FleecaBank", "") -end) - --- Notification when you receive cash. -RegisterNetEvent("receiveCash") -AddEventHandler("receiveCash", function(amount, playerSending, playerId) - BeginTextCommandThefeedPost("STRING") - AddTextComponentSubstringPlayerName(playerSending .. " gave you $" .. amount .. ".") - EndTextCommandThefeedPostMessagetext("CHAR_DEFAULT", "CHAR_DEFAULT", true, 9, playerSending .. " [".. playerId .."]", "") -end) - --- Notification when receiving salary. -RegisterNetEvent("receiveSalary") -AddEventHandler("receiveSalary", function(amount) - if registered then - BeginTextCommandThefeedPost("STRING") - AddTextComponentSubstringPlayerName("Daily Salary + $" .. config.salaryAmount) - EndTextCommandThefeedPostMessagetext("CHAR_BANK_FLEECA", "CHAR_BANK_FLEECA", true, 9,"FleecaBank", "") - TriggerServerEvent("getMoney", mainCharaterId) - end -end) - -- Notification above the map. function notify(message) BeginTextCommandThefeedPost("STRING") @@ -325,8 +344,8 @@ function getCharacterInfo(infoType) end end -function text(text, x, y, scale) - SetTextFont(7) +function text(text, x, y, scale, font) + SetTextFont(font) SetTextProportional(0) SetTextScale(scale, scale) SetTextEdge(1, 0, 0, 0, 255)