Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
NietThijmen authored Sep 6, 2023
1 parent 7a930d5 commit 662c80c
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 86 deletions.
4 changes: 2 additions & 2 deletions client/cl_menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 2 additions & 8 deletions client/cl_target.lua
Original file line number Diff line number Diff line change
@@ -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

Expand Down
45 changes: 45 additions & 0 deletions client/cl_tokens.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local pedEntities = {}

local function Nearby()
if IsControlJustPressed(0, 38) then
lib.showContext('arcade_purchase_token')
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<iframe id = "browser" src="" frameborder="0" scrolling="no">

</iframe>
<a id = "off_pc">Arcade machine uitzetten</a>
<a id = "off_pc">Arcade uitzetten</a>
</div>
<script src="./scripts/listener.js" type="text/javascript"></script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions html/scripts/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 1 addition & 24 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
23 changes: 18 additions & 5 deletions server/sv_main.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down
60 changes: 16 additions & 44 deletions shared/sh_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
}
}

0 comments on commit 662c80c

Please sign in to comment.