-- BEST SCRIPTS/ MLOS/ CARS IN DISCORD.GG/DEMONDEV!!! -- BEST SCRIPTS/ MLOS/ CARS IN DISCORD.GG/DEMONDEV!!! -- BEST SCRIPTS/ MLOS/ CARS IN DISCORD.GG/DEMONDEV!!! local tabletObject = nil local playerJob = nil local playerJobGrade = nil local playerJobLabel = nil Core = nil openMenuDrawText = false nuiLoaded = false menuOpen = false function NuiMessage(action, payload) while not nuiLoaded do Wait(0) end SendNUIMessage({ action = action, payload = payload }) end CreateThread(function() while not nuiLoaded do if NetworkIsSessionStarted() then SendNUIMessage({ action = "CHECK_NUI" }) end Wait(2000) end end) RegisterNUICallback("loaded", function(data, cb) nuiLoaded = true cb("ok") end) exports("createBilling", function(targetId, amount, reason, note, billingType) TriggerServerEvent("codem-billing:createBilling", targetId, amount, reason .. "" .. note, billingType) end) exports("CheckBilling", function(callback) return TriggerCallback("codem-billing:getMyUnpaidBilling", callback) end) RegisterNUICallback("CreateBill", function(data, cb) local from = data.from or "" local reason = data.reason or "" local note = data.note or "" local targetId = data.targetId or "" local amount = data.amount or "" local billingType if from == "myjob" then billingType = playerJob else billingType = "identifier" end TriggerServerEvent("codem-billing:createBilling", targetId, amount, reason .. "" .. note, billingType) cb("ok") end) RegisterNUICallback("getBills", function(data, cb) while playerJob == nil do Wait(0) end NuiMessage("setBills", Config.Bills[playerJob]) end) RegisterNUICallback("getPlayerName", function(data, cb) local playerId = data.id local playerName = TriggerCallback("codem-billing:getPlayerName", playerId) cb(playerName) end) RegisterNUICallback("getDueDate", function(data, cb) cb(Config.HowManyDays) end) Citizen.CreateThread(function() while not nuiLoaded do Citizen.Wait(50) end NuiMessage("configDefaulTax", Config.Tax) NuiMessage("configAllowJobs", Config.AllowBillingJobs) NuiMessage("locales", Config.Locales) NuiMessage("configPersonelAccount", Config.SendInvoiceAsStaffAccount) NuiMessage("confirSearchBill", Config.SearchPlayerBills) while playerJob == nil do Wait(50) end NuiMessage("playerJob", { job = playerJob, job_grade_name = playerJobLabel }) end) RegisterNetEvent("esx:playerLoaded") AddEventHandler("esx:playerLoaded", function() Wait(1000) SetPlayerJob() end) RegisterNetEvent("QBCore:Client:OnPlayerLoaded") AddEventHandler("QBCore:Client:OnPlayerLoaded", function() Wait(1000) SetPlayerJob() end) CreateThread(function() Core, Config.Framework = GetCore() SetPlayerJob() end) RegisterNetEvent("esx:setJob") AddEventHandler("esx:setJob", function(job) Wait(1000) SetPlayerJob() end) RegisterNetEvent("QBCore:Client:OnJobUpdate") AddEventHandler("QBCore:Client:OnJobUpdate", function(jobInfo) Wait(1000) SetPlayerJob() end) function SetPlayerJob() Wait(500) while not nuiLoaded do Wait(50) end WaitPlayer() local playerData if Config.Framework == "esx" or Config.Framework == "oldesx" then playerData = Core.GetPlayerData() playerJob = playerData.job.name else playerData = Core.Functions.GetPlayerData() playerJob = playerData.job.name playerJobLabel = playerData.job.label end if Config.AllowBillingJobs[playerJob] then NuiMessage("playerJob", { job = playerJob, job_grade_name = playerJobLabel }) else NuiMessage("playerJob", false) end end function WaitPlayer() if Config.Framework == "esx" or Config.Framework == "oldesx" then while Core == nil do Wait(0) end while Core.GetPlayerData() == nil do Wait(0) end while Core.GetPlayerData().job == nil do Wait(0) end else while Core == nil do Wait(0) end while Core.Functions.GetPlayerData() == nil do Wait(0) end while Core.Functions.GetPlayerData().metadata == nil do Wait(0) end end end RegisterNUICallback("payBill", function(data, cb) local result = TriggerCallback("codem-billing:payBill", data.uniqueid, data.targetIdentifier) updateMoney() cb(result) end) RegisterNUICallback("payBillFind", function(data, cb) local result = TriggerCallback("codem-billing:payBillFind", data) updateMoney() cb(result) end) RegisterNUICallback("getSocietyBills", function(data, cb) local result = TriggerCallback("codem-billing:getSocietyBills", data.society) cb(result) end) RegisterNUICallback("getAllSociety", function(data, cb) local result = TriggerCallback("codem-billing:getAllBill") cb(result) end) RegisterNUICallback("close", function(data, cb) menuOpen = false SetNuiFocus(false, false) stopAnim() cb("ok") end) RegisterNUICallback("payAllBills", function(data, cb) local result = TriggerCallback("codem-billing:payAllBills") updateMoney() cb(result) end) RegisterNUICallback("findBillingPlayer", function(data, cb) local result = TriggerCallback("codem-billing:findBillingPlayer", data.id) cb(result) end) RegisterNetEvent("codem-billing:updateBillData") AddEventHandler("codem-billing:updateBillData", function(billData) if menuOpen then NuiMessage("updateBillData", billData) updateMoney() end end) function updateMoney() local playerMoney = TriggerCallback("codem-billing:getPlayerMoney") NuiMessage("updateMoney", playerMoney) end RegisterNetEvent("codem-billing:openBillingMenu") AddEventHandler("codem-billing:openBillingMenu", function() openBillingMenu() end) function openBillingMenu() while Core == nil do Citizen.Wait(0) end if menuOpen or not nuiLoaded then return end menuOpen = true local billingData = TriggerCallback("codem-billing:getMyBilling") local playerData = TriggerCallback("codem-billing:getPlayerAccount") SetNuiFocus(true, true) startAnim() NuiMessage("openBillingMenu", { billingData = billingData, playerData = playerData }) end RegisterNUICallback("getNearbyPlayers", function(data, cb) local result = TriggerCallback("codem-billing:GetNearbyPlayers") cb(result) end) RegisterNUICallback("getMyBillingData", function(data, cb) local result = TriggerCallback("codem-billing:getMyBilling") cb(result) end) RegisterNUICallback("cancelBilling", function(data, cb) local result = TriggerCallback("codem-billing:cancelBilling", data.id) cb(result) end) RegisterNUICallback("cancelBillingjob", function(data, cb) local result = TriggerCallback("codem-billing:cancelBillingJob", data.id) cb(result) end) RegisterNUICallback("checkInvoice", function(data, cb) local result = TriggerCallback("codem-billing:checkInvoice", data.invoice) cb(result) end) RegisterNUICallback("getMyAllBillingData", function(data, cb) local result = TriggerCallback("codem-billing:getmyAllBillingData") cb(result) end) RegisterNUICallback("cancelmybilling", function(data, cb) local result = TriggerCallback("codem-billing:cancelmybilling", data.id) cb(result) end) RegisterNUICallback("searchBill", function(data, cb) local result = TriggerCallback("codem-billing:searchBill", data.id) cb(result) end) RegisterNUICallback("searchBillName", function(data, cb) local result = TriggerCallback("codem-billing:searchBillName", data.name) cb(result) end) RegisterNetEvent("codem-notification:showNotify") AddEventHandler("codem-notification:showNotify", function() NuiMessage("showNotify") end) RegisterNetEvent("codem-billing:refreshPage") AddEventHandler("codem-billing:refreshPage", function() NuiMessage("refreshPage") end) function startAnim() Citizen.CreateThread(function() local animDict = "amb@world_human_seat_wall_tablet@female@base" RequestAnimDict(animDict) while not HasAnimDictLoaded(animDict) do Citizen.Wait(0) end attachObject() TaskPlayAnim( GetPlayerPed(-1), animDict, "base", 8.0, -8.0, -1, 50, 0, false, false, false ) end) end function attachObject() tabletObject = CreateObject(GetHashKey("prop_cs_tablet"), 0, 0, 0, true, true, true) AttachEntityToEntity( tabletObject, GetPlayerPed(-1), GetPedBoneIndex(GetPlayerPed(-1), 57005), 0.17, 0.1, -0.13, 20.0, 180.0, 180.0, true, true, false, true, 1, true ) end function stopAnim() StopAnimTask( GetPlayerPed(-1), "amb@world_human_seat_wall_tablet@female@base", "base", 8.0, -8.0, -1, 50, 0, false, false, false ) if tabletObject then DeleteEntity(tabletObject) tabletObject = nil end end AddEventHandler("onResourceStop", function(resourceName) if GetCurrentServerEndpoint() == nil then return end if resourceName == GetCurrentResourceName() then stopAnim() end end) RegisterNUICallback("sendnotification", function(data, cb) Config.Notification( Config.NotificationText.notallowpersonelaccount.text, Config.NotificationText.notallowpersonelaccount.type, false ) cb("ok") end) function TriggerCallback(callbackName, ...) local result = false local status = "UNKNOWN" local attempts = 0 while Core == nil do Wait(0) end if Config.Framework == "esx" then Core.TriggerServerCallback(callbackName, function(data) status = "SUCCESS" result = data end, ...) else Core.Functions.TriggerCallback(callbackName, function(data) status = "SUCCESS" result = data end, ...) end CreateThread(function() while status == "UNKNOWN" do Wait(1000) attempts = attempts + 1 if attempts >= 4 then status = "FAILED" result = false break end end end) while status == "UNKNOWN" do Wait(0) end return result end -- BEST SCRIPTS/ MLOS/ CARS IN DISCORD.GG/DEMONDEV!!! -- BEST SCRIPTS/ MLOS/ CARS IN DISCORD.GG/DEMONDEV!!! -- BEST SCRIPTS/ MLOS/ CARS IN DISCORD.GG/DEMONDEV!!!