From 662c80c56a3f817779fc45d1ca7d53c4ce3adebb Mon Sep 17 00:00:00 2001 From: Thijmen <53520119+NietThijmen@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:36:45 +0200 Subject: [PATCH] Updates --- client/cl_menus.lua | 4 +-- client/cl_target.lua | 10 ++----- client/cl_tokens.lua | 45 ++++++++++++++++++++++++++++++ html/index.html | 2 +- html/scripts/listener.js | 4 +-- readme.md | 25 +---------------- server/sv_main.lua | 23 +++++++++++---- shared/sh_main.lua | 60 +++++++++++----------------------------- 8 files changed, 87 insertions(+), 86 deletions(-) diff --git a/client/cl_menus.lua b/client/cl_menus.lua index 03012af..556c58f 100644 --- a/client/cl_menus.lua +++ b/client/cl_menus.lua @@ -3,7 +3,7 @@ local function GenerateOptions() for i = 1, #Config.games, 1 do options[#options + 1] = { label = Config.games[i].label, - icon = Config.games[i].icon or 'fa-gamepad', -- WIP: Verplaatsen naar config voor fa-gamepad + icon = Config.games[i].icon or 'fa-gamepad', } end return options @@ -14,7 +14,7 @@ local function GenerateHacks() for i = 1, #Config.hacks, 1 do options[#options + 1] = { label = Config.hacks[i].label, - icon = Config.hacks[i].icon or 'fa-gamepad', -- WIP: Verplaatsen naar config voor fa-gamepad + icon = Config.hacks[i].icon or 'fa-gamepad', } end return options diff --git a/client/cl_target.lua b/client/cl_target.lua index b2bf5c9..bb18033 100644 --- a/client/cl_target.lua +++ b/client/cl_target.lua @@ -1,15 +1,9 @@ -local models = {1876055757, -1501557515, -1502319666, 815879628, -1991361770, 1301167921, -538006270, 2303605526, 4185618299, 3756961026, 2793409781, 398786301, 568464183, 3067040863, 3171514707, 3899793496, 974001996, 4206216415, 1457191833, 3054877820, 4129005630, 3963576280, 3325005861, 543442061, 372224036, -1273554963} -- WIP: Verplaatsen naar config? +local models = {2303605526, 3756961026, 1301167921, 2793409781, 1876055757, 2792647630, 398786301, 3067040863, 568464183, 3171514707, 3899793496, 974001996, 4206216415, 1457191833, 3054877820, 815879628, 4129005630, 3325005861, 900099857, 543442061, 372224036, 970154536} local function requireToken() if not lib.callback.await('qb-arcade:server:hasToken') then - - lib.notify({ - title = Lang:t('error.no_token_title'), - description = Lang:t('error.no_token'), - type = 'error', - }) - + QBCore.Functions.Notify(Lang:t('error.no_token'), 'error') return false end diff --git a/client/cl_tokens.lua b/client/cl_tokens.lua index 81e2328..91ab656 100644 --- a/client/cl_tokens.lua +++ b/client/cl_tokens.lua @@ -1,3 +1,5 @@ +local pedEntities = {} + local function Nearby() if IsControlJustPressed(0, 38) then lib.showContext('arcade_purchase_token') @@ -25,4 +27,47 @@ CreateThread(function() nearby = Nearby }) end +end) + +CreateThread(function() + for i, v in ipairs(Config.shops) do + lib.points.new({ + coords = v.coords, + distance = 25, + + onEnter = function() + -- spawn npc here + local model = joaat(v.model) + lib.requestModel(model) + local ped = CreatePed(4, model, v.coords.x, v.coords.y, v.coords.z, false, false, false) + SetEntityHeading(ped, v.coords.w) + FreezeEntityPosition(ped, true) + SetEntityInvincible(ped, true) + SetBlockingOfNonTemporaryEvents(ped, true) + SetPedDiesWhenInjured(ped, false) + SetPedCanPlayAmbientAnims(ped, true) + + if v.scenario then + TaskStartScenarioInPlace(ped, v.scenario, 0, true) + end + pedEntities[i] = ped + + exports['qb-target']:AddTargetEntity(ped, { + options = { + { + label = Lang:t('interactions.enter_token_shop'), + icon = v.icon, + action = function() + lib.showContext('arcade_purchase_token') + end + } + } + }) + end, + + onExit = function() + DeleteEntity(pedEntities[i]) + end, + }) + end end) \ No newline at end of file diff --git a/html/index.html b/html/index.html index 1d0454d..2485e97 100644 --- a/html/index.html +++ b/html/index.html @@ -14,7 +14,7 @@ - Arcade machine uitzetten + Arcade uitzetten diff --git a/html/scripts/listener.js b/html/scripts/listener.js index 0327de8..a2882b3 100644 --- a/html/scripts/listener.js +++ b/html/scripts/listener.js @@ -86,13 +86,13 @@ setTimeout(progress, 100); $(document).keyup(function(e) { if (e.keyCode === 27){ - $.post('https://qb-arcade/exit', JSON.stringify({})); + $.post('https://mtc-arcade/exit', JSON.stringify({})); } }); $( "#off_pc" ).click(function() { - $.post('https://qb-arcade/exit', JSON.stringify({})); + $.post('https://mtc-arcade/exit', JSON.stringify({})); }); function loadIframe(give,url) { url_game = url; diff --git a/readme.md b/readme.md index 0eeda78..0b8b0c9 100644 --- a/readme.md +++ b/readme.md @@ -1,13 +1,3 @@ -WIP: -- Locales -- Token Item -- Token Price -- Zones waar je een item kan kopen (OX menu met informatie over de prijs en waar je aantal tokens kan instellen en dan koop knop.) -- Controle of je een token hebt om een spel te spelen. -- In kunnen stellen bij normale spellen hoeveel tokens het kost. -- In kunnen stellen bij hacks hoeveel tokens het kost. -- Wanner iemand niet beschikt over een token bij de game melding in de zin van "Je hebt X token(s) nodig om dit spel te kunnen spelen" (in locales). - ![Arcade](https://i.imgur.com/5nO4C5G.png) # Arcade @@ -26,20 +16,7 @@ The Arcade is compatible with a wide range of MLO's for your FiveM experience. O ## 📦 Items You can find the images for the items mentioned below in the ```images``` directory. -```LUA -['gametoken'] = { - ['name'] = 'gametoken', - ['label'] = 'Game Token', - ['weight'] = 100, - ['type'] = 'item', - ['image'] = 'gametoken.png', - ['unique'] = false, - ['useable'] = false, - ['shouldClose'] = false, - ['combinable'] = nil, - ['description'] = 'Om een spelletje mee te spelen in de Arcade.' -}, -``` +To change the item you can edit ```server/sv_main.lua``` and change the item. ## 🪙 Credits A special thanks to the following people: diff --git a/server/sv_main.lua b/server/sv_main.lua index dd18e40..f9ff059 100644 --- a/server/sv_main.lua +++ b/server/sv_main.lua @@ -1,3 +1,20 @@ +CreateThread(function() + QBCore.Functions.AddItems({ + ['gametoken'] = { + ['name'] = 'gametoken', + ['label'] = 'Game Token', + ['weight'] = 100, + ['type'] = 'item', + ['image'] = 'gametoken.png', + ['unique'] = false, + ['useable'] = false, + ['shouldClose'] = false, + ['combinable'] = nil, + ['description'] = 'Game token.' + } + }) +end) + lib.callback.register('qb-arcade:server:hasToken', function(source) local src = source local player = QBCore.Functions.GetPlayer(src) @@ -17,11 +34,7 @@ RegisterNetEvent('qb-arcade:server:buyToken', function(amount) if not player then return end if not player.Functions.RemoveMoney(Config.PaymentType, price, 'arcade-token-purchase') then - TriggerClientEvent('ox_lib:notify', source, { - title = Lang:t('error.not_enough_money_title'), - description = Lang:t('error.not_enough_money'), - type = 'error', - }) + TriggerClientEvent('QBCore:Notify', source, Lang:t('error.not_enough_money')) return end diff --git a/shared/sh_main.lua b/shared/sh_main.lua index 1093a73..d7964a7 100644 --- a/shared/sh_main.lua +++ b/shared/sh_main.lua @@ -2,15 +2,26 @@ Config = {} QBCore = exports['qb-core']:GetCoreObject() -- Item that players get when they buy tokens and use to pay for a game. -Config.TokenItem = "gametoken" -- WIP (Item name: Game Token) +Config.TokenItem = "gametoken" Config.TokenPrice = "5" -Config.PaymentType = "cash" -- WIP +Config.PaymentType = "cash" -- cash, bank, crypto +-- Arcade coin shop points Config.Zones = { vector3(-1290.31, -298.4, 36.05), vector3(-1291.52, -300.7, 36.05) } +-- Arcade coin shop NPC's +Config.shops = { + { + model = 'ig_jimmydisanto', + coords = vector4(-1292.98, -301.59, 35.05, 300.74), + scenario = 'WORLD_HUMAN_CLIPBOARD', + icon = 'fas fa-cart-shopping' + } +} + Config.blip = { coords = vector3(-1286.24, -302.04, 36.03), label = "Arcade", @@ -60,55 +71,16 @@ Config.games = { Config.hacks = { { - label = "Rondjes", + label = "Lockpick", icon = 'fa-regular fa-circle', action = function() exports['ps-ui']:Circle(function(success) if success then - QBCore.Functions.Notify("Je hebt de hack voltooid!", "success") + QBCore.Functions.Notify("You opened the lock", "success") else - QBCore.Functions.Notify("Je hebt de hack gefaald!", "error") + QBCore.Functions.Notify("You closed the lock", "error") end end, 2, 20) -- NumberOfCircles, MS end }, - { - label = "Speurtocht", - icon = 'search', - action = function() - exports['ps-ui']:Maze(function(success) - if success then - QBCore.Functions.Notify("Je hebt de hack voltooid!", "success") - else - QBCore.Functions.Notify("Je hebt de hack gefaald!", "error") - end - end, 20) - end - }, - { - label = "VR", - icon = 'vr-cardboard', - action = function() - exports['ps-ui']:VarHack(function(success) - if success then - QBCore.Functions.Notify("Je hebt de hack voltooid!", "success") - else - QBCore.Functions.Notify("Je hebt de hack gefaald!", "error") - end - end, math.random(3,5), math.random(6,9)) - end - }, - { - label = "blokjes", - icon = 'fa-chess-board', - action = function() - exports['ps-ui']:Thermite(function(success) - if success then - QBCore.Functions.Notify("Je hebt de hack voltooid!", "success") - else - QBCore.Functions.Notify("Je hebt de hack gefaald!", "error") - end - end, 10, 5, 3) -- Time, Gridsize (5, 6, 7, 8, 9, 10), IncorrectBlocks - end - } } \ No newline at end of file