diff --git a/client/client.lua b/client/client.lua index 901b228..c55d230 100644 --- a/client/client.lua +++ b/client/client.lua @@ -4,78 +4,167 @@ -- ██╔══╝ ╚██╗ ██╔╝██╔══╝ ██║╚██╗██║ ██║ ╚════██║ -- ███████╗ ╚████╔╝ ███████╗██║ ╚████║ ██║ ███████║ -- ╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝ - - -local QBCore = exports["qb-core"]:GetCoreObject() -local PlayerData = QBCore.Functions.GetPlayerData() +local QBCore = nil +local ESX = nil +local PlayerData = nil local ped, pid, Player, playerId, player +local OpenMenu = false +-- Start Frameworks -RegisterNetEvent("QBCore:Client:OnPlayerUnload", function() - PlayerData = {} -end) - -RegisterNetEvent("QBCore:Client:OnPlayerLoaded") -AddEventHandler("QBCore:Client:OnPlayerLoaded", function () - PlayerData = {} -end) +if Config.Framework == "QBCORE" then + QBCore = exports["qb-core"]:GetCoreObject() + PlayerData = QBCore.Functions.GetPlayerData() + SendNUIMessage({ + action = 'updatedata', + pid = 0, + phone = 'Loading', + job = 'Loading', + name = 'Loading', + bank = 'Loading', + logo = Config.Logo, + playerss = 'Loading', + maxPlayers = Config.MaxPlayers, + }) +elseif Config.Framework == "ESX" then + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + SendNUIMessage({ + action = 'updatedata', + pid = 0, + phone = 'Loading', + job = 'Loading', + name = 'Loading', + bank = 'Loading', + logo = Config.Logo, + playerss = 'Loading', + maxPlayers = Config.MaxPlayers, + }) +else + -- Your own framework +end -GroupDigits = function(value) - local left,num,right = string.match(value,'^([^%d]*%d)(%d*)(.-)$') - return left..(num:reverse():gsub('(%d%d%d)','%1' .. ','):reverse())..right +--Data Extra Start +if Config.Framework == "QBCORE" then +--Extra DATA QBCORE PLAYER CHANGE CHARACTER + RegisterNetEvent("QBCore:Client:OnPlayerUnload", function() + PlayerData = {} + end) + RegisterNetEvent("QBCore:Client:OnPlayerLoaded") + AddEventHandler("QBCore:Client:OnPlayerLoaded", function () + PlayerData = {} + end) + +elseif Config.Framework == "ESX" then +--Extra ESX +else +--Other framework your own code end +--Data Extra End +---Keyboard +RegisterKeyMapping(Config.OpenScore, Config.KeyName, 'keyboard', Config.KeyOpen) +TriggerEvent('chat:addSuggestion', Config.OpenScore, Config.ChatCommandSuggest) -Citizen.CreateThread(function () - while true do - Wait(500) - if LocalPlayer.state.isLoggedIn then - - QBCore.Functions.GetPlayerData(function(PlayerData) - QBCore.Functions.TriggerCallback('Ultra-Scoreboard:CurrentPlayers', function(player) - ped = PlayerPedId() - pid = GetPlayerServerId(PlayerId()) - Player = QBCore.Functions.GetPlayerData() - playerId = PlayerId() +--Function OnKey +RegisterCommand(Config.OpenScore,function () + OpenMenu = not OpenMenu + if OpenMenu then + SetNuiFocus(true, true) + SendNUIMessage({ action = 'show'}) + SendNUIMessage({ action = 'bottom'}) + if Config.UseRobberys == true then + SendNUIMessage({ action = 'showrobbery'}) + end + else + SetNuiFocus(false, false) + SendNUIMessage({action = 'hide'}) + end + + if Config.Framework == "QBCORE" then + QBCore.Functions.TriggerCallback('Ultra-Scoreboard:CurrentPlayers', function(oPlayers) + ped = PlayerPedId() + pid = GetPlayerServerId(PlayerId()) + PlayerData = QBCore.Functions.GetPlayerData() + playerId = PlayerId() + SendNUIMessage({ + action = 'updatedata', + pid = pid, + phone = PlayerData.charinfo.phone, + job = PlayerData.job.label or Config.NoJob, + name = PlayerData.charinfo.firstname.. " " ..PlayerData.charinfo.lastname, + bank = Config.TypeIconMoney ..GroupDigits(PlayerData.money['bank']), + logo = Config.Logo, + playerss = oPlayers, + maxPlayers = Config.MaxPlayers, + }) + end) + QBCore.Functions.TriggerCallback('Ultra-Scoreboard:CurrentJobs', function(police, ambulance, mechanic, realestate, taxi, abogado) + ped = PlayerPedId() + pid = GetPlayerServerId(PlayerId()) + PlayerData = QBCore.Functions.GetPlayerData() + playerId = PlayerId() + + SendNUIMessage({ + action = 'updatedatajob', + mechanic = mechanic, + police = police, + ambulance = ambulance, + realestate = realestate, + taxi = taxi, + abogado = abogado, + robos = Config.RobList, + }) + + -- ✓ ✘ + end) + + elseif Config.Framework == "ESX" then + ESX.PlayerData = ESX.GetPlayerData() + local player = PlayerId() + local pid = GetPlayerServerId(player) + local playersList = 0 + for i = 1, #ESX.PlayerData.accounts, 1 do + if ESX.PlayerData.accounts[i].name == "bank" then + bank = ESX.PlayerData.accounts[i].money + end + end + ESX.TriggerServerCallback('Ultra-Scoreboard:CurrentJobs', function(police, ambulance, mechanic, realestate, taxi, abogado, oPlayers, rpName ,rPhone) + SendNUIMessage({ + action = 'updatedatajob', + mechanic = mechanic, + police = police, + ambulance = ambulance, + realestate = realestate, + taxi = taxi, + abogado = abogado, + robos = Config.RobList, + }) SendNUIMessage({ action = 'updatedata', pid = pid, - phone = Player.charinfo.phone, - job = Player.job.label or Config.NoJob, - name = Player.charinfo.firstname.. " " ..PlayerData.charinfo.lastname, - bank = Config.TypeIconMoney ..GroupDigits(Player.money['bank']), + phone = rPhone, + job = ESX.PlayerData.job.label or Config.NoJob, + name = rpName, + bank = Config.TypeIconMoney ..ESX.Math.GroupDigits(bank), logo = Config.Logo, - playerss = player, + playerss = oPlayers, maxPlayers = Config.MaxPlayers, }) end) - end) - else - SendNUIMessage({action = 'hide'}) - end - Wait(500) + + end end) -Citizen.CreateThread(function () - while true do - Wait(500) - QBCore.Functions.TriggerCallback('Ultra-Scoreboard:CurrentPlayers2', function(police, ambulance, mechanic, realestate, taxi, abogado) - SendNUIMessage({ - action = 'updatedatajob', - mechanic = mechanic, - police = police, - ambulance = ambulance, - realestate = realestate, - taxi = taxi, - abogado = abogado, - }) - end) - Wait(500) - end +RegisterNUICallback("exit" , function(data, cb) + OpenMenu = false + SetNuiFocus(false, false) + SendNUIMessage({action = 'hide'}) end) +--Other functions + local function GetPlayers() local players = {} for _, player in ipairs(GetActivePlayers()) do @@ -87,22 +176,7 @@ local function GetPlayers() return players end -RegisterKeyMapping(Config.OpenScore, Config.KeyName, 'keyboard', Config.KeyOpen) - -TriggerEvent('chat:addSuggestion', Config.OpenScore, Config.ChatCommandSuggest) - -RegisterCommand(Config.OpenScore,function () - SetNuiFocus(true, true) - SendNUIMessage({ - action = 'show' - }) -end) - -RegisterNUICallback("exit" , function(data, cb) - SetNuiFocus(false, false) - SendNUIMessage({ - action = 'hide' - }) -end) - - +GroupDigits = function(value) + local left,num,right = string.match(value,'^([^%d]*%d)(%d*)(.-)$') + return left..(num:reverse():gsub('(%d%d%d)','%1' .. ','):reverse())..right +end \ No newline at end of file diff --git a/config.lua b/config.lua index 8313e8a..fbb6032 100644 --- a/config.lua +++ b/config.lua @@ -5,11 +5,13 @@ -- ╚██████╗╚██████╔╝██║ ╚████║██║ ██║╚██████╔╝ -- ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ -Config = Config or {} +Config = {} +Config.Framework = "QBCORE" -- QBCORE o ESX +Config.Debug = false -- Debug mode Config.Logo = "https://i.imgur.com/yduIdh7.png" -Config.OpenScore = "scoreb" +Config.OpenScore = "scoreboard" Config.ChatCommandSuggest = "Open Scoreboard" Config.KeyOpen = "F10" Config.KeyName = "Open Scorebaord" @@ -17,4 +19,22 @@ Config.KeyName = "Open Scorebaord" Config.MaxPlayers = GetConvarInt('sv_maxclients', 70) Config.TypeIconMoney = " $" -Config.NoJob = "unemployed" \ No newline at end of file +Config.NoJob = "unemployed" + +Config.UseRobberys = true + +--!!WARNING!! +-- The Label is not working yet, I only put it to make an order guide! +-- if you want to change the rob you have to change it in the html + +Config.RobList = { + {order = 1 , label = 'FLEECA', requieredCops = 3}, + {order = 2 , label = 'PACIFIC BANK', requieredCops = 2}, + {order = 3 , label = 'VANGELICO', requieredCops = 6}, + {order = 4 , label = 'STORE', requieredCops = 3}, + {order = 5 , label = 'HUMANE LABS', requieredCops = 4}, + {order = 6 , label = 'BOBCAT', requieredCops = 5}, + {order = 7 , label = 'UNION', requieredCops = 3}, + {order = 8 , label = 'YACHT', requieredCops = 2}, + {order = 9 , label = 'VANT', requieredCops = 1}, +} diff --git a/fxmanifest.lua b/fxmanifest.lua index 06aee9a..657218a 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -2,22 +2,26 @@ fx_version 'cerulean' game 'gta5' -author 'Clau#1981' - +author 'Clau#1981, Robeer#9999' +version '1.1' description 'Ultra Scoreboard' +shared_scripts { + -- '@es_extended/imports.lua', --On ESX ENABLE + -- '@es_extended/locale.lua', -- On ESX ENABLE + 'config.lua', +} + client_scripts { 'client/*.lua', } server_scripts { + '@oxmysql/lib/MySQL.lua', + --'@mysql-async/lib/MySQL.lua', -- FOR OLD VERSION OF MYSQL 'server/*.lua', } -shared_scripts { - 'config.lua' -} - ui_page { 'html/index.html', } diff --git a/html/app.js b/html/app.js index 1b86ad3..4f93deb 100644 --- a/html/app.js +++ b/html/app.js @@ -1,3 +1,4 @@ +var robberyshow = false; window.addEventListener("message", function(event) { var v = event.data let bank = event.data.bank; @@ -14,7 +15,6 @@ window.addEventListener("message", function(event) { $('.playersonline').html(' Players:'+v.playerss+"/"+v.maxPlayers+''); break; - case "updatedatajob": $('.jdat1').text(v.mechanic); $('.jdat2').text(v.police); @@ -22,7 +22,7 @@ window.addEventListener("message", function(event) { $('.jdat4').text(v.realestate); $('.jdat5').text(v.taxi); $('.jdat6').text(v.abogado); - + canRob(v.police,v.robos); break; case "show": @@ -31,11 +31,29 @@ window.addEventListener("message", function(event) { case "hide": $('.allscore').hide(300) + $('.robbery').hide(300) + break; + + case "bottom": + $("#robberybottom").click(function () { + if ( robberyshow == false ) + { + $('.robbery').show(300) + robberyshow = true; + }else{ + $('.robbery').hide(300) + robberyshow = false; + } + + }); + break; + + case "showrobbery": + $('.planelrobberyalll').show(300) break; } }); - //EXIT// document.addEventListener('keydown', this.exitKey) @@ -46,6 +64,69 @@ function exitKey(event) { { $.post("https://Ultra-Scoreboard/exit", JSON.stringify({})) + $('.robbery').hide(300) } } + +function canRob(polices,robs) + + { + if(robs[0].requieredCops==polices){ + $('.rdat1').text('✓'); + } + else{ + $('.rdat1').text('✘'); + } + if(robs[1].requieredCops==polices){ + $('.rdat2').text('✓'); + } + else{ + $('.rdat2').text('✘'); + } + if(robs[2].requieredCops==polices){ + $('.rdat3').text('✓'); + } + else{ + $('.rdat3').text('✘'); + } + if(robs[3].requieredCops==polices){ + $('.rdat4').text('✓'); + } + else{ + $('.rdat4').text('✘'); + } + if(robs[4].requieredCops==polices){ + $('.rdat5').text('✓'); + } + else{ + $('.rdat5').text('✘'); + } + if(robs[5].requieredCops==polices){ + $('.rdat6').text('✓'); + } + else{ + $('.rdat6').text('✘'); + } + if(robs[6].requieredCops==polices){ + $('.rdat7').text('✓'); + } + else{ + $('.rdat7').text('✘'); + } + if(robs[7].requieredCops == polices){ + $('.rdat8').text('✓'); + } + else{ + $('.rdat8').text('✘'); + } + if(robs[8].requieredCops == polices){ + $('.rdat9').text('✓'); + } + else{ + $('.rdat9').text('✘'); + } +} + + + diff --git a/html/index.html b/html/index.html index 37e61fc..1615460 100644 --- a/html/index.html +++ b/html/index.html @@ -14,66 +14,137 @@ + - +