ed
490
resources/[freizeit]/[gym]/dynyx-gym/client/main.lua
Normal file
|
@ -0,0 +1,490 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
CreateThread(function()
|
||||
for k, v in pairs(Config.Threadmills) do
|
||||
exports['qb-target']:AddBoxZone("treadmill"..k, v.coords - vector3(0.0, 0.0, 1.0), 1, 2, {
|
||||
name = "treadmill"..k,
|
||||
heading = 300,
|
||||
debugPoly = false,
|
||||
minZ = v.coords.z - 1.0,
|
||||
maxZ = v.coords.z + 2.0,
|
||||
}, {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
event = "dynyx-gym:treadmill",
|
||||
icon = "fas fa-person-running",
|
||||
label = 'Use Treadmill'
|
||||
},
|
||||
},
|
||||
distance = 2.0
|
||||
})
|
||||
end
|
||||
for k, v in pairs(Config.LiftWeight) do
|
||||
exports['qb-target']:AddBoxZone("liftweights"..k, v.coords - vector3(0.0, 0.0, 1.0), 1, 2, {
|
||||
name = "liftweights"..k,
|
||||
heading = 300,
|
||||
debugPoly = false,
|
||||
minZ = v.coords.z - 1.0,
|
||||
maxZ = v.coords.z + 2.0,
|
||||
}, {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
event = 'dynyx-gym:liftweights',
|
||||
icon = "fas fa-dumbbell",
|
||||
label = 'Lift Weights'
|
||||
},
|
||||
},
|
||||
distance = 2.0
|
||||
})
|
||||
end
|
||||
exports['qb-target']:AddBoxZone("chinups", vector3(-1258.97, -356.16, 36.99), 1, 2, {
|
||||
name = "chinups",
|
||||
heading = 300.0,
|
||||
debugPoly = false,
|
||||
minZ = 30.0,
|
||||
maxZ = 39.0,
|
||||
}, {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
event = 'dynyx-gym:chinup',
|
||||
icon = "fa-solid fa-arrow-up",
|
||||
label = 'Do Chinups'
|
||||
},
|
||||
},
|
||||
distance = 2.0
|
||||
})
|
||||
|
||||
exports['qb-target']:AddBoxZone("chinups2", vector3(-1257.71, -358.84, 36.99), 1, 2, {
|
||||
name = "chinups2",
|
||||
heading = 300.0,
|
||||
debugPoly = false,
|
||||
minZ = 30.0,
|
||||
maxZ = 39.0,
|
||||
}, {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
event = 'dynyx-gym:chinup2',
|
||||
icon = "fa-solid fa-arrow-up",
|
||||
label = 'Do Chinups'
|
||||
},
|
||||
},
|
||||
distance = 2.0
|
||||
})
|
||||
exports['qb-target']:AddCircleZone("yoga", vector3(-1262.42, -360.93, 36.96), 3, {
|
||||
name = "yoga",
|
||||
debugPoly = false,
|
||||
}, {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
event = "dynyx-gym:yoga",
|
||||
icon = 'fas fa-face-smile',
|
||||
label = 'Start Yoga',
|
||||
}
|
||||
},
|
||||
distance = 2.5,
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterNetEvent('dynyx-gym:treadmill', function()
|
||||
local hasItem = QBCore.Functions.HasItem(Config.GymPassItem)
|
||||
if hasItem then
|
||||
Treadmill()
|
||||
else
|
||||
QBCore.Functions.Notify("You dont have a membership pass", "error")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('dynyx-gym:chinup', function()
|
||||
local hasItem = QBCore.Functions.HasItem(Config.GymPassItem)
|
||||
if hasItem then
|
||||
Chinup()
|
||||
else
|
||||
QBCore.Functions.Notify("You dont own a membership!", "error")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('dynyx-gym:chinup2', function()
|
||||
local hasItem = QBCore.Functions.HasItem(Config.GymPassItem)
|
||||
if hasItem then
|
||||
Chinup2()
|
||||
else
|
||||
QBCore.Functions.Notify("You dont own a membership!", "error")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('dynyx-gym:liftweights', function()
|
||||
local hasItem = QBCore.Functions.HasItem(Config.GymPassItem)
|
||||
if hasItem then
|
||||
LiftWeight()
|
||||
else
|
||||
QBCore.Functions.Notify("You dont own a membership!", "error")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('dynyx-gym:yoga', function()
|
||||
local hasItem = QBCore.Functions.HasItem(Config.GymPassItem)
|
||||
if hasItem then
|
||||
Yoga()
|
||||
else
|
||||
QBCore.Functions.Notify("You dont own a membership!", "error")
|
||||
end
|
||||
end)
|
||||
|
||||
local function LoadAnimDict(dict)
|
||||
RequestAnimDict(dict)
|
||||
while not HasAnimDictLoaded(dict) do
|
||||
Wait(10)
|
||||
end
|
||||
end
|
||||
|
||||
function ChinupsAnim()
|
||||
local ped = PlayerPedId()
|
||||
|
||||
local chinup = Config.Skills.Chinups.ChinupAnimCoords
|
||||
SetEntityCoords(ped, chinup.x, chinup.y, chinup.z, false, false, false, true)
|
||||
SetEntityHeading(ped, chinup.w)
|
||||
end
|
||||
|
||||
function ChinupsAnim2()
|
||||
local ped = PlayerPedId()
|
||||
|
||||
local chinup = Config.Skills.Chinups.ChinupAnimCoords2
|
||||
SetEntityCoords(ped, chinup.x, chinup.y, chinup.z, false, false, false, true)
|
||||
SetEntityHeading(ped, chinup.w)
|
||||
end
|
||||
|
||||
local function ThreadmillReward(results)
|
||||
if results == 'success' then
|
||||
exports["mz-skills"]:UpdateSkill(Config.Skills.ThreadMills.skill, Config.Skills.ThreadMills.amount)
|
||||
Wait(2000)
|
||||
TriggerServerEvent('hud:server:GainStress', Config.Skills.ThreadMills.Stress)
|
||||
TriggerEvent('inventory:client:busy:status', false)
|
||||
elseif results == 'failed' then
|
||||
QBCore.Functions.Notify("That did not feel too good..", "error")
|
||||
Wait(3000)
|
||||
TriggerServerEvent('hud:server:GainStress', Config.Skills.ThreadMills.Minigame.FailedMinigameStress)
|
||||
end
|
||||
end
|
||||
|
||||
local function StartThreadmillMinigame()
|
||||
-------------------------------------------------------------------------------------------- ps-ui section
|
||||
if Config.Minigame == 'ps-ui' then
|
||||
exports['ps-ui']:Circle(function(success)
|
||||
if success then
|
||||
ThreadmillReward('success')
|
||||
else --failed
|
||||
ThreadmillReward('failed')
|
||||
end
|
||||
end, Config.Skills.ThreadMills.Minigame.circles, Config.Skills.ThreadMills.Minigame.time)
|
||||
-------------------------------------------------------------------------------------------- qb-lock section
|
||||
elseif Config.Minigame == 'qb-lock' then
|
||||
local success = exports['qb-lock']:StartLockPickCircle(Config.Skills.ThreadMills.Minigame.circles, Config.Skills.ThreadMills.Minigame.time, success)
|
||||
if success then
|
||||
ThreadmillReward('success')
|
||||
else --failed
|
||||
ThreadmillReward('failed')
|
||||
end
|
||||
elseif Config.Minigame == 'skillCheck' then
|
||||
local success = lib.skillCheck({'easy', 'easy', 'medium', 'medium'}, {'w', 'a', 's', 'd'})
|
||||
if success then
|
||||
ThreadmillReward('success')
|
||||
else --failed
|
||||
ThreadmillReward('failed')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Treadmill()
|
||||
local ped = PlayerPedId()
|
||||
TaskStartScenarioInPlace(ped, "WORLD_HUMAN_JOG_STANDING", 0, true)
|
||||
if Config.Progressbar == 'qb' then
|
||||
QBCore.Functions.Progressbar('random_task', 'Jogging', Config.Skills.ThreadMills.ProgressbarDuration, false, false, {
|
||||
disableMovement = true,
|
||||
disableCarMovement = true,
|
||||
disableMouse = false,
|
||||
disableCombat = true,
|
||||
}, {}, {}, {}, function()
|
||||
StartThreadmillMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end)
|
||||
elseif Config.Progressbar == 'ox' then
|
||||
exports.ox_inventory:Progress({
|
||||
duration = Config.Skills.ThreadMills.ProgressbarDuration,
|
||||
label = "Jogging",
|
||||
useWhileDead = false,
|
||||
disable = {
|
||||
move = true,
|
||||
car = true,
|
||||
combat = true,
|
||||
mouse = false,
|
||||
},
|
||||
}, function(cancel)
|
||||
if not cancel then
|
||||
StartThreadmillMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function ChinupReward(results)
|
||||
if results == 'success' then
|
||||
exports["mz-skills"]:UpdateSkill(Config.Skills.Chinups.skill, Config.Skills.Chinups.amount)
|
||||
Wait(2000)
|
||||
TriggerServerEvent('hud:server:GainStress', Config.Skills.Chinups.Stress)
|
||||
TriggerEvent('inventory:client:busy:status', false)
|
||||
elseif results == 'failed' then
|
||||
QBCore.Functions.Notify("That did not feel too good..", "error")
|
||||
Wait(3000)
|
||||
TriggerServerEvent('hud:server:GainStress', Config.Skills.Chinups.Minigame.FailedMinigameStress)
|
||||
end
|
||||
end
|
||||
|
||||
local function StartChinupMinigame()
|
||||
-------------------------------------------------------------------------------------------- ps-ui section
|
||||
if Config.Minigame == 'ps-ui' then
|
||||
exports['ps-ui']:Circle(function(success)
|
||||
if success then
|
||||
ChinupReward('success')
|
||||
else --failed
|
||||
ChinupReward('failed')
|
||||
end
|
||||
end, Config.Skills.Chinups.Minigame.circles, Config.Skills.Chinups.Minigame.time)
|
||||
-------------------------------------------------------------------------------------------- qb-lock section
|
||||
elseif Config.Minigame == 'qb-lock' then
|
||||
local success = exports['qb-lock']:StartLockPickCircle(Config.Skills.Chinups.Minigame.circles, Config.Skills.Chinups.Minigame.time, success)
|
||||
if success then
|
||||
ChinupReward('success')
|
||||
else --failed
|
||||
ChinupReward('failed')
|
||||
end
|
||||
elseif Config.Minigame == 'skillCheck' then
|
||||
local success = lib.skillCheck({'easy', 'easy', 'medium', 'medium'}, {'w', 'a', 's', 'd'})
|
||||
if success then
|
||||
ChinupReward('success')
|
||||
else --failed
|
||||
ChinupReward('failed')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Chinup()
|
||||
local ped = PlayerPedId()
|
||||
ChinupsAnim()
|
||||
TaskStartScenarioInPlace(ped, "PROP_HUMAN_MUSCLE_CHIN_UPS", 0, true)
|
||||
if Config.Progressbar == 'qb' then
|
||||
QBCore.Functions.Progressbar('random_task', 'Doing Chin-ups', Config.Skills.Chinups.ProgressbarDuration, false, false, {
|
||||
disableMovement = true,
|
||||
disableCarMovement = true,
|
||||
disableMouse = false,
|
||||
disableCombat = true,
|
||||
}, {}, {}, {}, function()
|
||||
StartChinupMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end)
|
||||
elseif Config.Progressbar == 'ox' then
|
||||
exports.ox_inventory:Progress({
|
||||
duration = Config.Skills.Chinups.ProgressbarDuration,
|
||||
label = "Doing Chin-ups",
|
||||
useWhileDead = false,
|
||||
disable = {
|
||||
move = true,
|
||||
car = true,
|
||||
combat = true,
|
||||
mouse = false,
|
||||
},
|
||||
}, function(cancel)
|
||||
if not cancel then
|
||||
StartChinupMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function Chinup2()
|
||||
local ped = PlayerPedId()
|
||||
ChinupsAnim2()
|
||||
TaskStartScenarioInPlace(ped, "PROP_HUMAN_MUSCLE_CHIN_UPS", 0, true)
|
||||
if Config.Progressbar == 'qb' then
|
||||
QBCore.Functions.Progressbar('random_task', 'Doing Chin-ups', Config.Skills.Chinups.ProgressbarDuration, false, false, {
|
||||
disableMovement = true,
|
||||
disableCarMovement = true,
|
||||
disableMouse = false,
|
||||
disableCombat = true,
|
||||
}, {}, {}, {}, function()
|
||||
StartChinupMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end)
|
||||
elseif Config.Progressbar == 'ox' then
|
||||
exports.ox_inventory:Progress({
|
||||
duration = Config.Skills.Chinups.ProgressbarDuration,
|
||||
label = "Doing Chin-ups",
|
||||
useWhileDead = false,
|
||||
disable = {
|
||||
move = true,
|
||||
car = true,
|
||||
combat = true,
|
||||
mouse = false,
|
||||
},
|
||||
}, function(cancel)
|
||||
if not cancel then
|
||||
StartChinupMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function LiftWeightReward(results)
|
||||
if results == 'success' then
|
||||
exports["mz-skills"]:UpdateSkill(Config.Skills.LiftWeights.skill, Config.Skills.LiftWeights.amount)
|
||||
Wait(2000)
|
||||
TriggerServerEvent('hud:server:GainStress', Config.Skills.LiftWeights.Stress)
|
||||
TriggerEvent('inventory:client:busy:status', false)
|
||||
elseif results == 'failed' then
|
||||
QBCore.Functions.Notify("That did not feel too good..", "error")
|
||||
Wait(3000)
|
||||
TriggerServerEvent('hud:server:GainStress', Config.Skills.LiftWeights.Minigame.FailedMinigameStress)
|
||||
end
|
||||
end
|
||||
|
||||
local function StartLiftWeightMinigame()
|
||||
-------------------------------------------------------------------------------------------- ps-ui section
|
||||
if Config.Minigame == 'ps-ui' then
|
||||
exports['ps-ui']:Circle(function(success)
|
||||
if success then
|
||||
LiftWeightReward('success')
|
||||
else --failed
|
||||
LiftWeightReward('failed')
|
||||
end
|
||||
end, Config.Skills.LiftWeights.Minigame.circles, Config.Skills.LiftWeights.Minigame.time)
|
||||
-------------------------------------------------------------------------------------------- qb-lock section
|
||||
elseif Config.Minigame == 'qb-lock' then
|
||||
local success = exports['qb-lock']:StartLockPickCircle(Config.Skills.LiftWeights.Minigame.circles, Config.Skills.LiftWeights.Minigame.time, success)
|
||||
if success then
|
||||
LiftWeightReward('success')
|
||||
else --failed
|
||||
LiftWeightReward('failed')
|
||||
end
|
||||
elseif Config.Minigame == 'skillCheck' then
|
||||
local success = lib.skillCheck({'easy', 'easy', 'medium', 'medium'}, {'w', 'a', 's', 'd'})
|
||||
if success then
|
||||
LiftWeightReward('success')
|
||||
else --failed
|
||||
LiftWeightReward('failed')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function LiftWeight()
|
||||
local ped = PlayerPedId()
|
||||
TaskStartScenarioInPlace(ped, "world_human_muscle_free_weights", 0, true)
|
||||
if Config.Progressbar == 'qb' then
|
||||
QBCore.Functions.Progressbar('random_task', 'Lifting Weights', Config.Skills.LiftWeights.ProgressbarDuration, false, false, {
|
||||
disableMovement = true,
|
||||
disableCarMovement = true,
|
||||
disableMouse = false,
|
||||
disableCombat = true,
|
||||
}, {}, {}, {}, function()
|
||||
StartLiftWeightMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end)
|
||||
elseif Config.Progressbar == 'ox' then
|
||||
exports.ox_inventory:Progress({
|
||||
duration = Config.Skills.LiftWeights.ProgressbarDuration,
|
||||
label = "Lifting Weights",
|
||||
useWhileDead = false,
|
||||
disable = {
|
||||
move = true,
|
||||
car = true,
|
||||
combat = true,
|
||||
mouse = false,
|
||||
},
|
||||
}, function(cancel)
|
||||
if not cancel then
|
||||
StartLiftWeightMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function YogaReward(results)
|
||||
if results == 'success' then
|
||||
exports["mz-skills"]:UpdateSkill(Config.Skills.Yoga.skill, Config.Skills.Yoga.amount)
|
||||
Wait(2000)
|
||||
TriggerServerEvent('hud:server:RelieveStress', Config.Skills.Yoga.Stress)
|
||||
TriggerEvent('inventory:client:busy:status', false)
|
||||
elseif results == 'failed' then
|
||||
QBCore.Functions.Notify("That did not feel too good..", "error")
|
||||
Wait(3000)
|
||||
TriggerServerEvent('hud:server:GainStress', Config.Skills.Yoga.Minigame.FailedMinigameStress)
|
||||
end
|
||||
end
|
||||
|
||||
local function StartYogaMinigame()
|
||||
-------------------------------------------------------------------------------------------- ps-ui section
|
||||
if Config.Minigame == 'ps-ui' then
|
||||
exports['ps-ui']:Circle(function(success)
|
||||
if success then
|
||||
YogaReward('success')
|
||||
else --failed
|
||||
YogaReward('failed')
|
||||
end
|
||||
end, Config.Skills.Yoga.Minigame.circles, Config.Skills.Yoga.Minigame.time)
|
||||
-------------------------------------------------------------------------------------------- qb-lock section
|
||||
elseif Config.Minigame == 'qb-lock' then
|
||||
local success = exports['qb-lock']:StartLockPickCircle(Config.Skills.Yoga.Minigame.circles, Config.Skills.Yoga.Minigame.time, success)
|
||||
if success then
|
||||
YogaReward('success')
|
||||
else --failed
|
||||
YogaReward('failed')
|
||||
end
|
||||
elseif Config.Minigame == 'skillCheck' then
|
||||
local success = lib.skillCheck({'easy', 'easy', 'medium', 'medium'}, {'w', 'a', 's', 'd'})
|
||||
if success then
|
||||
YogaReward('success')
|
||||
else --failed
|
||||
YogaReward('failed')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Yoga()
|
||||
local ped = PlayerPedId()
|
||||
TaskStartScenarioInPlace(ped, "WORLD_HUMAN_YOGA", 0, true)
|
||||
if Config.Progressbar == 'qb' then
|
||||
QBCore.Functions.Progressbar('random_task', 'Yoga Exercising', Config.Skills.Yoga.ProgressbarDuration, false, false, {
|
||||
disableMovement = true,
|
||||
disableCarMovement = true,
|
||||
disableMouse = false,
|
||||
disableCombat = true,
|
||||
}, {}, {}, {}, function()
|
||||
StartYogaMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end)
|
||||
elseif Config.Progressbar == 'ox' then
|
||||
exports.ox_inventory:Progress({
|
||||
duration = Config.Skills.Yoga.ProgressbarDuration,
|
||||
label = "Yoga Exercising",
|
||||
useWhileDead = false,
|
||||
disable = {
|
||||
move = true,
|
||||
car = true,
|
||||
combat = true,
|
||||
mouse = false,
|
||||
},
|
||||
}, function(cancel)
|
||||
if not cancel then
|
||||
StartYogaMinigame()
|
||||
ClearPedTasks(ped)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
176
resources/[freizeit]/[gym]/dynyx-gym/client/shop.lua
Normal file
|
@ -0,0 +1,176 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
CreateThread(function()
|
||||
-- Makes Blip
|
||||
Gym = AddBlipForCoord(Config.GymPedSpawn)
|
||||
SetBlipSprite(Gym, 311)
|
||||
SetBlipDisplay(Gym, 4)
|
||||
SetBlipScale(Gym, 0.65)
|
||||
SetBlipAsShortRange(Gym, true)
|
||||
SetBlipColour(Gym, 7)
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentSubstringPlayerName(Config.BlipName)
|
||||
EndTextCommandSetBlipName(Gym)
|
||||
-- Spawns Ped
|
||||
local PedCoords = Config.GymPedSpawn
|
||||
PedHash = GetHashKey(Config.GymPed)
|
||||
RequestModel(PedHash)
|
||||
while not HasModelLoaded(PedHash) do
|
||||
Citizen.Wait(1)
|
||||
end
|
||||
if HasModelLoaded(PedHash) then
|
||||
local GymPed = CreatePed(1, PedHash, PedCoords.x, PedCoords.y, PedCoords.z, PedCoords.w, false, true)
|
||||
FreezeEntityPosition(GymPed, true)
|
||||
SetEntityInvincible(GymPed, true)
|
||||
TaskStartScenarioInPlace(GymPed, "WORLD_HUMAN_CLIPBOARD", 0, true)
|
||||
SetBlockingOfNonTemporaryEvents(GymPed, true)
|
||||
if Config.Target == 'qb' then
|
||||
exports['qb-target']:AddBoxZone("gymnpc", vector3(PedCoords.x, PedCoords.y, PedCoords.z + 1), 1.5, 1.5, {
|
||||
name = "gymnpc",
|
||||
heading = 0,
|
||||
debugPoly = false,
|
||||
minZ = 30.0,
|
||||
maxZ = 39.0,
|
||||
}, {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
event = "dynyx_gym:OpenMemberBuy",
|
||||
icon = 'fa-solid fa-book',
|
||||
label = 'Buy Membership'
|
||||
},
|
||||
},
|
||||
distance = 2.0
|
||||
})
|
||||
elseif Config.Target == 'ox' then
|
||||
exports.ox_target:addSphereZone({
|
||||
coords = vec3(PedCoords.x, PedCoords.y, PedCoords.z + 1),
|
||||
radius = 1,
|
||||
debug = false,
|
||||
options = {
|
||||
{
|
||||
onSelect = function()
|
||||
TriggerEvent('dynyx_gym:OpenMemberBuy')
|
||||
end,
|
||||
icon = 'fa-solid fa-book',
|
||||
label = "Buy Membership",
|
||||
}
|
||||
}
|
||||
})
|
||||
else
|
||||
print("**Invalid Config.Target.**")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('dynyx_gym:OpenMemberBuy', function()
|
||||
if Config.Menu == 'qb' then
|
||||
exports['qb-menu']:openMenu({
|
||||
{
|
||||
id = 1,
|
||||
header = "Welcome! Please Purchase a Gym Member to workout!",
|
||||
},{
|
||||
id = 2,
|
||||
header = "Buy Gym Membership",
|
||||
txt = "$"..Config.GymPassPrice,
|
||||
params = {
|
||||
event = "dynyx_gym:LifetimeConfirm",
|
||||
}
|
||||
},
|
||||
})
|
||||
elseif Config.Menu == 'ox' then
|
||||
lib.registerContext({
|
||||
id = 'GymMemberMenu1',
|
||||
title = 'Welcome! Please Purchase a Gym Membership to workout!',
|
||||
options = {
|
||||
{
|
||||
title = 'Buy Gym Membership',
|
||||
description = '$'..Config.GymPassPrice,
|
||||
arrow = true,
|
||||
icon = 'dollar',
|
||||
event = 'dynyx_gym:LifetimeConfirm',
|
||||
}
|
||||
}
|
||||
})
|
||||
lib.showContext('GymMemberMenu1')
|
||||
else
|
||||
print("**Invalid Config.Menu.**")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('dynyx_gym:LifetimeConfirm', function()
|
||||
if Config.Menu == 'qb' then
|
||||
exports['qb-menu']:openMenu({
|
||||
{
|
||||
id = 1,
|
||||
header = "Go Back",
|
||||
params = {
|
||||
event = "dynyx-gym:OpenMemberBuy",
|
||||
}
|
||||
},{
|
||||
id = 2,
|
||||
header = "Confirm Purchase",
|
||||
txt = "Purchase of $"..Config.GymPassPrice,
|
||||
params = {
|
||||
event = "dynyx_gym:BuyCard",
|
||||
}
|
||||
},
|
||||
})
|
||||
elseif Config.Menu == 'ox' then
|
||||
lib.registerContext({
|
||||
id = 'GymMemberMenu2',
|
||||
title = 'Please Confirm.',
|
||||
options = {
|
||||
{
|
||||
title = 'Confirm Purchase',
|
||||
description = 'Purchase of $'..Config.GymPassPrice,
|
||||
icon = 'dollar',
|
||||
event = 'dynyx_gym:BuyCard',
|
||||
}
|
||||
}
|
||||
})
|
||||
lib.showContext('GymMemberMenu2')
|
||||
else
|
||||
print("**Invalid Config.Menu.**")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('dynyx_gym:BuyCard', function()
|
||||
if Config.Progressbar == 'qb' then
|
||||
QBCore.Functions.Progressbar('random_task', 'Processing Purchase', 3000, false, false, {
|
||||
disableMovement = true,
|
||||
disableCarMovement = true,
|
||||
disableMouse = false,
|
||||
disableCombat = true,
|
||||
}, {
|
||||
animDict = "missheistdockssetup1clipboard@base",
|
||||
anim = "base",
|
||||
flags = 8,
|
||||
}, {}, {}, function()
|
||||
TriggerServerEvent('dynyx_gym:BuyGymM')
|
||||
end)
|
||||
elseif Config.Progressbar == 'ox' then
|
||||
exports.ox_inventory:Progress({
|
||||
duration = 3000,
|
||||
label = "Processing Purchase",
|
||||
useWhileDead = false,
|
||||
disable = {
|
||||
move = true,
|
||||
car = true,
|
||||
combat = true,
|
||||
mouse = false,
|
||||
},
|
||||
anim = {
|
||||
dict = "missheistdockssetup1clipboard@base",
|
||||
clip = "base",
|
||||
flags = 8,
|
||||
},
|
||||
}, function(cancel)
|
||||
if not cancel then
|
||||
TriggerServerEvent('dynyx_gym:BuyGymM')
|
||||
end
|
||||
end)
|
||||
else
|
||||
print("**Invalid Config.Progressbar.**")
|
||||
end
|
||||
end)
|
103
resources/[freizeit]/[gym]/dynyx-gym/config.lua
Normal file
|
@ -0,0 +1,103 @@
|
|||
-- | https://discord.com/invite/A4gVRjnvaE | For any support
|
||||
|
||||
-- Make sure you have this https://github.com/GreenSlayer/mz-skills
|
||||
|
||||
-- ***IF YOU ARE USING OX UNCOMMENT "@ox_lib/init.lua", IN fxmanifest.lua***
|
||||
|
||||
Config = {}
|
||||
|
||||
Config.Target = 'qb' -- ox / qb
|
||||
Config.Menu = 'qb' -- ox / qb
|
||||
Config.Progressbar = 'qb' -- ox / qb
|
||||
Config.Inventory = 'qb' -- ox / qb
|
||||
Config.Notifications = 'qb' -- ox / qb
|
||||
|
||||
Config.GymPed = "a_m_y_clubcust_04" -- Ped Model of the Ped you buy a membership
|
||||
Config.GymPedSpawn = vector4(-1255.53, -354.77, 35.96, 296.64) -- Location of the Ped you buy membership and Blip Location
|
||||
Config.BlipName = 'Gym' -- Blip Name
|
||||
|
||||
Config.GymPassPrice = 1250 -- Price of Membership
|
||||
Config.GymPassItem = 'gym_pass' -- Item Name of Gym Membership
|
||||
|
||||
Config.EnableMinigame = true -- (true == Enables Minigame) (false == Disables Minigame)
|
||||
Config.Minigame = 'skillCheck' -- qb-lock / ps-ui / skillCheck (Ox_lib Required)(If using skillcheck, Minigame setting wont work)
|
||||
|
||||
|
||||
Config.Skills = {
|
||||
['ThreadMills'] = {
|
||||
skill = 'Stamina', -- The Type of Skill
|
||||
amount = math.random(0, 1), -- The amount of skill rep you gain
|
||||
Stress = math.random(5, 9), -- GainStress -- You Can set the amount of Stress you gain here
|
||||
ProgressbarDuration = math.random(1000, 2500), -- This is the duration for the progressbar
|
||||
Minigame = { -- Circle Minigame
|
||||
time = 5,
|
||||
circles = 1,
|
||||
FailedMinigameStress = math.random(10, 15) -- If you failed the minigame you will gain stress as a punishment for failing it
|
||||
}
|
||||
},
|
||||
['Chinups'] = {
|
||||
skill = 'Strength', -- The Type of Skill
|
||||
amount = math.random(0, 2), -- The amount of skill rep you gain
|
||||
Stress = math.random(5, 9), -- GainStress -- You Can set the amount of Stress you gain here
|
||||
ProgressbarDuration = math.random(6000, 12000), -- This is the duration for the progressbar
|
||||
Minigame = { -- Circle Minigame
|
||||
time = 20,
|
||||
circles = 7,
|
||||
FailedMinigameStress = math.random(10, 15) -- If you failed the minigame you will gain stress as a punishment for failing it
|
||||
},
|
||||
ChinupAnimCoords = vector4(-1258.79, -355.49, 35.96, 338.63),
|
||||
ChinupAnimCoords2 = vector4(-1257.45, -358.75, 35.96, 294.17)
|
||||
},
|
||||
['LiftWeights'] = {
|
||||
skill = 'Strength', -- The Type of Skill
|
||||
amount = math.random(0, 2), -- The amount of skill rep you gain
|
||||
Stress = math.random(5, 9), -- GainStress -- You Can set the amount of Stress you gain here
|
||||
ProgressbarDuration = math.random(6000, 12000), -- This is the duration for the progressbar
|
||||
Minigame = { -- Circle Minigame
|
||||
time = 18,
|
||||
circles = 8,
|
||||
FailedMinigameStress = math.random(10, 15) -- If you failed the minigame you will gain stress as a punishment for failing it
|
||||
}
|
||||
},
|
||||
['Yoga'] = {
|
||||
skill = 'Stamina', -- The Type of Skill
|
||||
amount = math.random(0, 0), -- The amount of skill rep you gain
|
||||
Stress = math.random(15, 20), --RelieveStress -- You Can set the amount of Stress you relieve here
|
||||
ProgressbarDuration = math.random(7000, 12000), -- This is the duration for the progressbar
|
||||
Minigame = { -- Circle Minigame
|
||||
time = 18,
|
||||
circles = 8,
|
||||
FailedMinigameStress = math.random(10, 15) -- If you failed the minigame you will gain stress as a punishment for failing it
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Config.Threadmills = { -- Coords of each Threadmill
|
||||
[1] = {
|
||||
coords = vector3(-1257.55, -366.77, 36.96)
|
||||
},
|
||||
[2] = {
|
||||
coords = vector3(-1259.0, -367.58, 36.96)
|
||||
},
|
||||
[3] = {
|
||||
coords = vector3(-1260.41, -368.4, 36.96)
|
||||
},
|
||||
[4] = {
|
||||
coords = vector3(-1261.93, -369.09, 36.96)
|
||||
},
|
||||
[5] = {
|
||||
coords = vector3(-1263.23, -369.84, 36.96)
|
||||
},
|
||||
[6] = {
|
||||
coords = vector3(-1264.67, -370.58, 36.96)
|
||||
},
|
||||
}
|
||||
|
||||
Config.LiftWeight = { -- Coords of each Weight
|
||||
[1] = {
|
||||
coords = vector3(-1268.11, -366.05, 36.99)
|
||||
},
|
||||
[2] = {
|
||||
coords = vector3(-1269.8, -362.56, 36.96)
|
||||
},
|
||||
}
|
24
resources/[freizeit]/[gym]/dynyx-gym/fxmanifest.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
|
||||
name "dynyx-gym"
|
||||
description "Gym Workout Script made by Dynyx Scripts"
|
||||
author "Green"
|
||||
version "2.0"
|
||||
|
||||
lua54 'yes'
|
||||
|
||||
shared_scripts {
|
||||
-- "@ox_lib/init.lua", -- Uncomment this if you are using OX_LIB
|
||||
"config.lua",
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'@PolyZone/client.lua',
|
||||
'@PolyZone/BoxZone.lua',
|
||||
'client/*.lua',
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
'server/*.lua',
|
||||
}
|
BIN
resources/[freizeit]/[gym]/dynyx-gym/images/gym_pass.png
Normal file
After Width: | Height: | Size: 27 KiB |
39
resources/[freizeit]/[gym]/dynyx-gym/server/main.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
function Notify(source, text, status)
|
||||
if Config.Notifications == "ox" then
|
||||
TriggerClientEvent('ox_lib:notify', source, {
|
||||
title = 'GYM',
|
||||
description = text,
|
||||
type = status
|
||||
})
|
||||
elseif Config.Notifications == "qb" then
|
||||
TriggerClientEvent('QBCore:Notify', source, text, status)
|
||||
else
|
||||
print("Config.Notifications is invalid.")
|
||||
end
|
||||
end
|
||||
RegisterServerEvent('dynyx_gym:BuyGymM', function()
|
||||
local src = source
|
||||
if Config.Inventory == 'qb' then
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
local cashcurr = Player.Functions.GetMoney('cash')
|
||||
|
||||
if cashcurr >= Config.GymPassPrice then
|
||||
Player.Functions.RemoveMoney('cash', Config.GymPassPrice)
|
||||
Player.Functions.AddItem(Config.GymPassItem, 1)
|
||||
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[Config.GymPassItem], "add")
|
||||
else
|
||||
Notify(src, 'Not Enough Money', 'error')
|
||||
end
|
||||
elseif Config.Inventory == 'ox' then
|
||||
local item = exports.ox_inventory:GetItem(src, "money")
|
||||
|
||||
if item.count >= Config.GymPassPrice then
|
||||
exports.ox_inventory:RemoveItem(src, "money", Config.GymPassPrice)
|
||||
exports.ox_inventory:AddItem(src, Config.GymPassItem, 1)
|
||||
else
|
||||
Notify(src, 'Not Enough Money', 'error')
|
||||
end
|
||||
end
|
||||
end)
|
13
resources/[freizeit]/[gym]/mz-skills/.github/workflows/workflows.yml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
name: Discord Webhook
|
||||
on: [push]
|
||||
jobs:
|
||||
Discord_notification:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
- name: Run Discord Webhook
|
||||
uses: Kingsage311/classic-discord-webhook@main
|
||||
with:
|
||||
id: ${{ secrets.B1_ID }}
|
||||
token: ${{ secrets.B1_TOKEN }}
|
674
resources/[freizeit]/[gym]/mz-skills/LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
61
resources/[freizeit]/[gym]/mz-skills/README.md
Normal file
|
@ -0,0 +1,61 @@
|
|||
## mz-skills
|
||||
- A database held skill/XP system for qb-core (and use with other mz-resources).
|
||||
- All credit to Kings#4220. This resource is based on the custom line branch of "B1-skillz" - for the original resource (with GTA V inherent modifications) please see: https://github.com/Burn-One-Studios/B1-skillz
|
||||
|
||||
### [ Installation ]
|
||||
- Download the resource and drop it to your resource folder.
|
||||
- Import the SQL file to your server's database (i.e. run the sql file and make sure the database runs)
|
||||
- Add ``start mz-skills`` to your server.cfg (or simply make sure mz-skills is in your [qb] folder)
|
||||
|
||||
### [ Using mz-skills ]
|
||||
!. To Update a skill please use the following export:
|
||||
```lua
|
||||
exports["mz-skills"]:UpdateSkill(skill, amount)
|
||||
```
|
||||
For example, to update "Searching" from bin-diving (as used with mz-bins)
|
||||
```lua
|
||||
exports["mz-skills"]:UpdateSkill("Searching", 1)
|
||||
```
|
||||
You can randomise the amount of skill gained, for example:
|
||||
```lua
|
||||
local searchgain = math.random(1, 3)
|
||||
exports["mz-skills"]:UpdateSkill("Searching", searchgain)
|
||||
```
|
||||
B. The export to check to see if a skill is equal or greater than a particular value is as follows:
|
||||
```lua
|
||||
exports["mz-skills"]:CheckSkill(skill, val)
|
||||
```
|
||||
|
||||
You can use this to lock content behind a particular level, for example:
|
||||
```lua
|
||||
exports["mz-skills"]:CheckSkill("Searching", 100, function(hasskill)
|
||||
if hasskill then
|
||||
TriggerEvent('mz-bins:client:Reward')
|
||||
else
|
||||
QBCore.Functions.Notify('You need at least 100XP in Searching to do this.', "error", 3500)
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
- The export to obtain a player's current skill to interact with other scripts is as follows:
|
||||
```lua
|
||||
exports["qb-skillz"]:GetCurrentSkill(skill)
|
||||
```
|
||||
|
||||
- For radial menu access to "skills" command add this to qb-radialmenu/config.lua - line 296 and following:
|
||||
```lua
|
||||
[3] = {
|
||||
id = 'skills',
|
||||
title = 'Check Skills',
|
||||
icon = 'triangle-exclamation',
|
||||
type = 'client',
|
||||
event = 'mz-skills:client:CheckSkills',
|
||||
shouldClose = true,
|
||||
},
|
||||
```
|
||||
|
||||
### [ Previews ]
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/Kingsage311/Kingsage311/main/assets/skillzcustom.png"/>
|
||||
</p>
|
122
resources/[freizeit]/[gym]/mz-skills/client/functions.lua
Normal file
|
@ -0,0 +1,122 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
FetchSkills = function()
|
||||
QBCore.Functions.TriggerCallback("skillsystem:fetchStatus", function(data)
|
||||
if data then
|
||||
for status, value in pairs(data) do
|
||||
if Config.Skills[status] then
|
||||
Config.Skills[status]["Current"] = value["Current"]
|
||||
else
|
||||
print("Removing: " .. status)
|
||||
end
|
||||
end
|
||||
end
|
||||
RefreshSkills()
|
||||
end)
|
||||
end
|
||||
|
||||
GetCurrentSkill = function(skill)
|
||||
return Config.Skills[skill]
|
||||
end
|
||||
|
||||
--exports('GetCurrentSkill')
|
||||
|
||||
UpdateSkill = function(skill, amount)
|
||||
if not Config.Skills[skill] then
|
||||
print("Skill " .. skill .. " does not exist")
|
||||
return
|
||||
end
|
||||
local SkillAmount = Config.Skills[skill]["Current"]
|
||||
if SkillAmount + tonumber(amount) < 0 then
|
||||
Config.Skills[skill]["Current"] = 0
|
||||
elseif SkillAmount + tonumber(amount) > 250000 then
|
||||
Config.Skills[skill]["Current"] = 100
|
||||
else
|
||||
Config.Skills[skill]["Current"] = SkillAmount + tonumber(amount)
|
||||
end
|
||||
RefreshSkills()
|
||||
if Config.Notifications and tonumber(amount) > 0 then
|
||||
if Config.NotifyType == "3d" then
|
||||
Notification("~g~+" .. amount .. " SHITTY NOTI SYSTEM ~s~" .. skill)
|
||||
elseif Config.NotifyType == 'qb' then
|
||||
QBCore.Functions.Notify("+" .. amount .. " XP to " .. skill, "success", 3500)
|
||||
elseif Config.NotifyType == "okok" then
|
||||
exports['okokNotify']:Alert("SKILL GAINED", "+" .. amount .. " XP to " .. skill, 3500, 'info')
|
||||
end
|
||||
end
|
||||
TriggerServerEvent("skillsystem:update", json.encode(Config.Skills))
|
||||
end
|
||||
|
||||
function round(num)
|
||||
return math.floor(num+.5)
|
||||
end
|
||||
|
||||
function round1(num)
|
||||
return math.floor(num+1)
|
||||
end
|
||||
|
||||
RefreshSkills = function()
|
||||
for type, value in pairs(Config.Skills) do
|
||||
if Config.Debug then
|
||||
print(type .. ": " .. value['Current'])
|
||||
elseif Config.Debug and not Config.Skills[skill] then
|
||||
print("something went wrong")
|
||||
end
|
||||
if value["Stat"] then
|
||||
StatSetInt(value["Stat"], round(value["Current"]), true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
exports('CheckSkill', function(skill, val, hasskill)
|
||||
if Config.Skills[skill] then
|
||||
if Config.Skills[skill]["Current"] >= tonumber(val) then
|
||||
hasskill(true)
|
||||
else
|
||||
hasskill(false)
|
||||
end
|
||||
else
|
||||
print("Skill " .. skill .. " doesn't exist")
|
||||
hasskill(false)
|
||||
end
|
||||
end)
|
||||
|
||||
MessageBox = function(text, alpha)
|
||||
if alpha > 255 then
|
||||
alpha = 255
|
||||
elseif alpha < 0 then
|
||||
alpha = 0
|
||||
end
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, math.floor(alpha))
|
||||
SetTextEdge(2, 0, 0, 0, math.floor(alpha))
|
||||
SetTextDropShadow()
|
||||
SetTextEntry("STRING")
|
||||
SetTextCentre(1)
|
||||
SetTextScale(0.31, 0.31)
|
||||
AddTextComponentString(text)
|
||||
local factor = (string.len(text)) / 350
|
||||
local x = 0.015
|
||||
local y = 0.5
|
||||
local width = 0.05
|
||||
local height = 0.025
|
||||
DrawText(x + (width / 2.0), y + (height / 2.0) - 0.01)
|
||||
DrawRect(x + (width / 2.0), y + (height / 2.0), width, height, 25, 25, 25, math.floor(alpha))
|
||||
end
|
||||
|
||||
Notification = function(message)
|
||||
local alpha = 185
|
||||
|
||||
for time = 1, 250 do
|
||||
Citizen.Wait(1)
|
||||
|
||||
if time >= 150 then
|
||||
alpha = alpha - 2
|
||||
if alpha <= 0 then
|
||||
alpha = 0
|
||||
end
|
||||
end
|
||||
MessageBox(message, alpha)
|
||||
end
|
||||
end
|
59
resources/[freizeit]/[gym]/mz-skills/client/gui.lua
Normal file
|
@ -0,0 +1,59 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
local function createSkillMenu()
|
||||
skillMenu = {}
|
||||
skillMenu[#skillMenu + 1] = {
|
||||
isHeader = true,
|
||||
header = 'Skills',
|
||||
isMenuHeader = true,
|
||||
icon = 'fas fa-chart-simple'
|
||||
}
|
||||
|
||||
for k,v in pairs(Config.Skills) do
|
||||
if v['Current'] <= 100 then
|
||||
SkillLevel = 'Level 0 (Unskilled)'
|
||||
elseif v['Current'] > 100 and v['Current'] <= 200 then
|
||||
SkillLevel = 'Level 1 (Beginner)'
|
||||
elseif v['Current'] > 200 and v['Current'] <= 400 then
|
||||
SkillLevel = 'Level 2 (Amateur)'
|
||||
elseif v['Current'] > 400 and v['Current'] <= 800 then
|
||||
SkillLevel = 'Level 3 (Intermediate)'
|
||||
elseif v['Current'] > 800 and v['Current'] <= 1600 then
|
||||
SkillLevel = 'Level 4 (Competent)'
|
||||
elseif v['Current'] > 1600 and v['Current'] <= 3200 then
|
||||
SkillLevel = 'Level 5 (Skilled)'
|
||||
elseif v['Current'] > 3200 and v['Current'] <= 6400 then
|
||||
SkillLevel = 'Level 6 (Adept)'
|
||||
elseif v['Current'] > 6400 and v['Current'] <= 12800 then
|
||||
SkillLevel = 'Level 7 (Master)'
|
||||
elseif v['Current'] > 12800 then
|
||||
SkillLevel = 'Level 8 (Proficient)'
|
||||
else
|
||||
SkillLevel = 'Unknown'
|
||||
end
|
||||
skillMenu[#skillMenu + 1] = {
|
||||
header = ''.. k .. '',
|
||||
txt = '( '..SkillLevel..' ) Total XP ( '..round1(v['Current'])..' )',
|
||||
icon = ''..v['icon']..'',
|
||||
params = {
|
||||
args = {
|
||||
v
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
exports['qb-menu']:openMenu(skillMenu)
|
||||
end
|
||||
|
||||
RegisterCommand(Config.Skillmenu, function()
|
||||
if Config.TypeCommand then
|
||||
createSkillMenu()
|
||||
else
|
||||
Wait(10)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("mz-skills:client:CheckSkills")
|
||||
AddEventHandler("mz-skills:client:CheckSkills", function()
|
||||
createSkillMenu()
|
||||
end)
|
28
resources/[freizeit]/[gym]/mz-skills/client/main.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||
Citizen.CreateThread(function()
|
||||
FetchSkills()
|
||||
while true do
|
||||
local seconds = Config.UpdateFrequency * 1000
|
||||
Citizen.Wait(seconds)
|
||||
for skill, value in pairs(Config.Skills) do
|
||||
UpdateSkill(skill, value["RemoveAmount"])
|
||||
end
|
||||
TriggerServerEvent("skillsystem:update", json.encode(Config.Skills))
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
|
||||
for skill, value in pairs(Config.Skills) do
|
||||
Config.Skills[skill]["Current"] = 0
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
AddEventHandler('onResourceStart', function(resource)
|
||||
if resource == GetCurrentResourceName() then
|
||||
Wait(100)
|
||||
FetchSkills()
|
||||
end
|
||||
end)
|
112
resources/[freizeit]/[gym]/mz-skills/config.lua
Normal file
|
@ -0,0 +1,112 @@
|
|||
Config = {}
|
||||
|
||||
-------------
|
||||
--MZ-SKILLS--
|
||||
-------------
|
||||
|
||||
Config.UpdateFrequency = 300 -- Seconds interval between removing values (no need to touch this)
|
||||
|
||||
Config.Notifications = true -- Notification played when skill is added (set to "false" to disable)
|
||||
|
||||
Config.NotifyType = 'qb' -- Notification type: 'qb' for QBCore notification, 'okok' for okokNotify
|
||||
|
||||
Config.Debug = false -- Set to "true" to print debugging messages
|
||||
|
||||
Config.TypeCommand = true -- Set to "false" to disable the "/skills" command (or whatever word you set in the next function)
|
||||
|
||||
Config.Skillmenu = "skills" -- phrase typed to display skills menu (check readme.md to set to commit to radial menu)
|
||||
|
||||
-------------
|
||||
--RP SKILLS--
|
||||
-------------
|
||||
|
||||
-- Please feel free to add/subtract the skills you are using in your city as you see fit.
|
||||
-- Please avoid taking skills away after players have already started accumulating XP.
|
||||
-- The following skills which appear in this default list are used by one or more mz- resources.
|
||||
|
||||
Config.Skills = {
|
||||
["Stamina"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "MP0_STAMINA",
|
||||
['icon'] = 'fas fa-walking',
|
||||
},
|
||||
["Strength"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "MP0_STRENGTH",
|
||||
['icon'] = 'fas fa-dumbbell',
|
||||
},
|
||||
["Searching"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "BINDIVE_ABILITY",
|
||||
['icon'] = 'fas fa-trash',
|
||||
},
|
||||
["Scraping"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "SCRAP_ABILITY",
|
||||
['icon'] = 'fas fa-screwdriver',
|
||||
},
|
||||
["Hacking"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "HACK_ABILITY",
|
||||
['icon'] = 'fas fa-laptop-code',
|
||||
},
|
||||
["Street Reputation"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "DRUGREP_ABILITY",
|
||||
['icon'] = 'fas fa-cannabis',
|
||||
},
|
||||
["Drug Manufacture"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "DRUGMAKE_ABILITY",
|
||||
['icon'] = 'fas fa-pills',
|
||||
},
|
||||
["Delivery Runner"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "RUNNER_ABILITY",
|
||||
['icon'] = 'fas fa-car',
|
||||
},
|
||||
["Hitman"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "HITMAN_ABILITY",
|
||||
['icon'] = 'fas fa-skull',
|
||||
},
|
||||
["Driving"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "DRIVER_ABILITY",
|
||||
['icon'] = 'fas fa-car-alt',
|
||||
},
|
||||
["Lumberjack"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "TREE_ABILITY",
|
||||
['icon'] = 'fas fa-tree',
|
||||
},
|
||||
["Heist Reputation"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "HEIST_ABILITY",
|
||||
['icon'] = 'fa-solid fa-user-secret',
|
||||
},
|
||||
["Diving"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "DIVING_ABILITY",
|
||||
['icon'] = 'fas fa-water',
|
||||
},
|
||||
["Electrical"] = {
|
||||
["Current"] = 0,
|
||||
["RemoveAmount"] = 0,
|
||||
["Stat"] = "ELECTRICAL_ABILITY",
|
||||
['icon'] = 'fas fa-bolt',
|
||||
},
|
||||
}
|
24
resources/[freizeit]/[gym]/mz-skills/fxmanifest.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
|
||||
description 'mz-skills - a customised fork of B1-skillz created by Kings#4220'
|
||||
|
||||
version '1.1.0'
|
||||
|
||||
shared_script 'config.lua'
|
||||
|
||||
server_scripts {
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'server/main.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'client/main.lua',
|
||||
'client/functions.lua',
|
||||
'client/gui.lua'
|
||||
}
|
||||
|
||||
exports {
|
||||
"UpdateSkill",
|
||||
"GetCurrentSkill"
|
||||
}
|
23
resources/[freizeit]/[gym]/mz-skills/server/main.lua
Normal file
|
@ -0,0 +1,23 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
QBCore.Functions.CreateCallback('skillsystem:fetchStatus', function(source, cb)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if Player then
|
||||
local status = MySQL.scalar.await('SELECT skills FROM players WHERE citizenid = ?', {Player.PlayerData.citizenid})
|
||||
if status ~= nil then
|
||||
cb(json.decode(status))
|
||||
else
|
||||
cb(nil)
|
||||
end
|
||||
else
|
||||
cb()
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('skillsystem:update', function (data)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
MySQL.query('UPDATE players SET skills = @skills WHERE citizenid = @citizenid', {
|
||||
['@skills'] = data,
|
||||
['@citizenid'] = Player.PlayerData.citizenid
|
||||
})
|
||||
end)
|
2
resources/[freizeit]/[gym]/mz-skills/skills.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER table players
|
||||
ADD COLUMN `skills` LONGTEXT;
|
26
resources/[freizeit]/[gym]/ps-ui/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
name: Bug Report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected Behaviour**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
28
resources/[freizeit]/[gym]/ps-ui/.github/pull_request_template.md
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
### Description
|
||||
e.g. UI does not close after completing menu game
|
||||
<!-- Provide a brief summary of the changes proposed in this pull request. -->
|
||||
|
||||
### Related Issue
|
||||
<!-- Link to the related issue(s) this pull request addresses. -->
|
||||
e.g. Closes #123
|
||||
|
||||
### Type of Change
|
||||
<!-- Please delete options that are not relevant. -->
|
||||
- [ ] Bug fix
|
||||
- [ ] New feature
|
||||
- [ ] Improvement
|
||||
- [ ] Documentation update
|
||||
- [ ] Other (please specify):
|
||||
|
||||
### Checklist
|
||||
- [ ] I have read and followed the contributing guidelines.
|
||||
- [ ] I have tested the changes locally.
|
||||
- [ ] I have updated the documentation if necessary.
|
||||
- [ ] I have added or updated tests to cover the changes.
|
||||
- [ ] I have verified that the code style and formatting adhere to the project's standards.
|
||||
|
||||
### Screenshots
|
||||
<!-- If applicable, add screenshots to help explain the changes. -->
|
||||
|
||||
### Additional Information
|
||||
<!-- Provide any additional context or information that reviewers should be aware of. -->
|
674
resources/[freizeit]/[gym]/ps-ui/LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
5
resources/[freizeit]/[gym]/ps-ui/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Script Archived & Merged into ps_lib
|
||||
|
||||
This script has been **archived** and its entire functionality has been **merged into the [`ps_lib` library**.](https://github.com/Project-Sloth/ps_lib)
|
||||
|
||||
Going forward, all updates, patches, and new features will be maintained in the [`ps_lib` repository.](https://github.com/Project-Sloth/ps_lib)
|
35
resources/[freizeit]/[gym]/ps-ui/client/circle.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
local p = nil
|
||||
|
||||
--- Starts a circle game and handles the result.
|
||||
--- @param cb function: Callback function that will receive the result of the game (true for success, false for failure)
|
||||
--- @param circles number|nil: Number of circles in the game (default is 1 if nil or less than 1)
|
||||
--- @param seconds number|nil: Time duration of the game in seconds (default is 10 if nil or less than 1)
|
||||
local function circle(cb, circles, seconds)
|
||||
if circles == nil or circles < 1 then circles = 1 end
|
||||
if seconds == nil or seconds < 1 then seconds = 10 end
|
||||
DebugPrint("Circle called with " .. circles .. " circles and " .. seconds .. " seconds")
|
||||
p = promise.new()
|
||||
SendNUIMessage({
|
||||
action = 'CircleGame',
|
||||
data = {
|
||||
circles = circles,
|
||||
time = seconds,
|
||||
}
|
||||
})
|
||||
SetNuiFocus(true, true)
|
||||
local result = Citizen.Await(p)
|
||||
cb(result)
|
||||
end
|
||||
|
||||
--- Callback for when the game finishes.
|
||||
--- @param data any: Data sent from the NUI (not used in this function)
|
||||
--- @param cb function: Callback function to signal completion of the NUI callback (must be called to complete the NUI callback)
|
||||
RegisterNuiCallback('circle-result', function(data, cb)
|
||||
local result = data.endResult
|
||||
p:resolve(result)
|
||||
p = nil
|
||||
SetNuiFocus(false, false)
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
exports("Circle", circle)
|
45
resources/[freizeit]/[gym]/ps-ui/client/display.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
local storedText = ""
|
||||
local storedColor = "primary"
|
||||
|
||||
--- Displays text with a specified color and icon.
|
||||
--- @param text string|nil: The text to display (defaults to an empty string if nil)
|
||||
--- @param color string|nil: The color for the text (defaults to "primary" if nil)
|
||||
--- @param icon string|nil: The icon to display (defaults to 'fa-solid fa-circle-info' if nil)
|
||||
exports("DisplayText", function(text, color, icon)
|
||||
if text == nil then storedText = "" else storedText = text end
|
||||
if color == nil then storedColor = "primary" else storedColor = color end
|
||||
DebugPrint("DisplayText called with " .. text .. " text and " .. color .. " color")
|
||||
SendNUIMessage({
|
||||
action = "ShowDrawTextMenu",
|
||||
data = {
|
||||
title = "No Title", -- Static title for the text display
|
||||
keys = storedText, -- The text to display
|
||||
icon = icon or 'fa-solid fa-circle-info', -- Icon to display (default is 'fa-solid fa-circle-info')
|
||||
color = storedColor, -- Color of the text
|
||||
}
|
||||
})
|
||||
end)
|
||||
|
||||
--- Hides the currently displayed text.
|
||||
exports("HideText", function()
|
||||
storedText = ""
|
||||
storedColor = "primary"
|
||||
SendNUIMessage({
|
||||
action = "HideDrawTextMenu",
|
||||
})
|
||||
end)
|
||||
|
||||
--- Updates the displayed text.
|
||||
--- @param text string|nil: The new text to display (defaults to an empty string if nil)
|
||||
exports("UpdateText", function(text, color, icon)
|
||||
if text == nil then storedText = "" else storedText = text end
|
||||
if color == nil then storedColor = "primary" else storedColor = color end
|
||||
SendNUIMessage({
|
||||
action = "ShowDrawTextMenu",
|
||||
data = {
|
||||
keys = storedText, -- The updated text to display
|
||||
icon = icon or 'fa-solid fa-circle-info', -- Icon to display (default is 'fa-solid fa-circle-info')
|
||||
color = storedColor, -- Color of the text
|
||||
}
|
||||
})
|
||||
end)
|
163
resources/[freizeit]/[gym]/ps-ui/client/examples.lua
Normal file
|
@ -0,0 +1,163 @@
|
|||
|
||||
|
||||
-- Number Maze
|
||||
RegisterCommand("maze",function()
|
||||
exports['ps-ui']:Maze(function(success)
|
||||
if success then
|
||||
print("success")
|
||||
else
|
||||
print("fail")
|
||||
end
|
||||
end, 20) -- Hack Time Limit
|
||||
end)
|
||||
|
||||
-- VAR
|
||||
RegisterCommand("var", function()
|
||||
exports['ps-ui']:VarHack(function(success)
|
||||
if success then
|
||||
print("success")
|
||||
else
|
||||
print("fail")
|
||||
end
|
||||
end, 2, 3) -- Number of Blocks, Time (seconds)
|
||||
end)
|
||||
|
||||
-- CIRCLE
|
||||
RegisterCommand("circle", function()
|
||||
exports['ps-ui']:Circle(function(success)
|
||||
if success then
|
||||
print("success")
|
||||
else
|
||||
print("fail")
|
||||
end
|
||||
end, 2, 20) -- NumberOfCircles, MS
|
||||
end)
|
||||
|
||||
-- THERMITE
|
||||
RegisterCommand("thermite", function()
|
||||
exports['ps-ui']:Thermite(function(success)
|
||||
if success then
|
||||
print("success")
|
||||
else
|
||||
print("fail")
|
||||
end
|
||||
end, 10, 5, 3) -- Time, Gridsize (5, 6, 7, 8, 9, 10), IncorrectBlocks
|
||||
end)
|
||||
|
||||
-- SCRAMBLER
|
||||
RegisterCommand("scrambler", function()
|
||||
exports['ps-ui']:Scrambler(function(success)
|
||||
if success then
|
||||
print("success")
|
||||
else
|
||||
print("fail")
|
||||
end
|
||||
end, "numeric", 30, 0) -- Type (alphabet, numeric, alphanumeric, greek, braille, runes), Time (Seconds), Mirrored (0: Normal, 1: Normal + Mirrored 2: Mirrored only )
|
||||
end)
|
||||
|
||||
-- DISPLAY TEXT
|
||||
RegisterCommand("display", function()
|
||||
exports['ps-ui']:DisplayText("Example Text", "primary") -- Colors: primary, error, success, warning, info, mint
|
||||
end)
|
||||
|
||||
RegisterCommand("hide", function()
|
||||
exports['ps-ui']:HideText()
|
||||
end)
|
||||
|
||||
|
||||
local status = false
|
||||
RegisterCommand("status", function()
|
||||
if not status then
|
||||
status = true
|
||||
exports['ps-ui']:StatusShow("Area Dominance", {
|
||||
"Gang: Ballas",
|
||||
"Influence: %100",
|
||||
})
|
||||
else
|
||||
status = false
|
||||
exports['ps-ui']:StatusHide()
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
RegisterCommand("cmenu", function()
|
||||
exports['ps-ui']:CreateMenu({
|
||||
{
|
||||
header = "header1",
|
||||
text = "text1",
|
||||
icon = "fa-solid fa-circle",
|
||||
color = "red",
|
||||
event = "event:one",
|
||||
args = {
|
||||
1,
|
||||
"two",
|
||||
"3",
|
||||
},
|
||||
server = false,
|
||||
|
||||
},
|
||||
{
|
||||
header = "header2",
|
||||
text = "text3",
|
||||
icon = "fa-solid fa-circle",
|
||||
color = "blue",
|
||||
event = "event:two",
|
||||
args = {
|
||||
1,
|
||||
"two",
|
||||
"3",
|
||||
},
|
||||
server = false,
|
||||
},
|
||||
{
|
||||
header = "header3",
|
||||
text = "text3",
|
||||
icon = "fa-solid fa-circle",
|
||||
color = "green",
|
||||
event = "event:three",
|
||||
args = {
|
||||
1,
|
||||
"two",
|
||||
"3",
|
||||
},
|
||||
server = true,
|
||||
},
|
||||
{
|
||||
header = "header4",
|
||||
text = "text4",
|
||||
event = "event:four",
|
||||
args = {
|
||||
1,
|
||||
"two",
|
||||
"3",
|
||||
},
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
||||
RegisterCommand("input", function()
|
||||
local input = exports['ps-ui']:Input({
|
||||
title = "Test",
|
||||
inputs = {
|
||||
{
|
||||
type = "text",
|
||||
placeholder = "test2"
|
||||
},
|
||||
{
|
||||
type = "password",
|
||||
placeholder = "password"
|
||||
},
|
||||
{
|
||||
type = "number",
|
||||
placeholder = "666"
|
||||
},
|
||||
}
|
||||
})
|
||||
for k,v in pairs(input) do
|
||||
print(k,v)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterCommand("showimage", function()
|
||||
exports['ps-ui']:ShowImage("https://user-images.githubusercontent.com/91661118/168956591-43462c40-e7c2-41af-8282-b2d9b6716771.png")
|
||||
end)
|
41
resources/[freizeit]/[gym]/ps-ui/client/input.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
local p = nil
|
||||
local active = false
|
||||
|
||||
--- Displays an input form and waits for user input.
|
||||
--- @param InputData table: Data to be used for the input form, typically includes fields like labels, types, and icons.
|
||||
--- @return table: User input data as returned from the form.
|
||||
local function input(InputData)
|
||||
DebugPrint("Input called with " .. json.encode(InputData))
|
||||
p = promise.new()
|
||||
while active do Wait(0) end
|
||||
active = true
|
||||
SendNUIMessage({
|
||||
action = "ShowInput",
|
||||
data = InputData
|
||||
})
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
local inputs = Citizen.Await(p)
|
||||
return inputs
|
||||
end
|
||||
|
||||
--- Callback for handling user input.
|
||||
--- @param data table: Data received from the NUI input form, includes user input values.
|
||||
--- @param cb function: Callback function to signal completion of the NUI callback (must be called to complete the NUI callback).
|
||||
RegisterNUICallback('input-callback', function(data, cb)
|
||||
SetNuiFocus(false, false)
|
||||
p:resolve(data)
|
||||
p = nil
|
||||
active = false
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
--- Callback for closing the input form.
|
||||
--- @param data any: Data sent from the NUI (not used in this function).
|
||||
--- @param cb function: Callback function to signal completion of the NUI callback (must be called to complete the NUI callback).
|
||||
RegisterNUICallback('input-close', function(data, cb)
|
||||
SetNuiFocus(false, false)
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
exports("Input", input)
|
64
resources/[freizeit]/[gym]/ps-ui/client/menu.lua
Normal file
|
@ -0,0 +1,64 @@
|
|||
local storedData = {}
|
||||
|
||||
---Creates a menu and registers its events.
|
||||
---@param menuData table: Data for the menu, including items and submenus.
|
||||
local function createMenu(menuData)
|
||||
for _, item in ipairs(menuData) do
|
||||
storedData[item.id] = item
|
||||
if item.subMenu then
|
||||
for _, subItem in ipairs(item.subMenu) do
|
||||
storedData[subItem.id] = subItem
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SendNUI("ShowMenu", nil, {
|
||||
menuData = menuData
|
||||
}, true)
|
||||
end
|
||||
|
||||
--- Event handler for creating a menu from a network event.
|
||||
--- @param menuData table: Data for the menu, including items and submenus.
|
||||
RegisterNetEvent("ps-ui:CreateMenu", function(menuData)
|
||||
if not menuData then
|
||||
return
|
||||
end
|
||||
|
||||
createMenu(menuData)
|
||||
end)
|
||||
|
||||
--- Closes the current menu.
|
||||
local function hideMenu()
|
||||
SendNUI("HideMenu", nil, {}, false)
|
||||
storedData = {}
|
||||
end
|
||||
|
||||
--- NUI callback for closing the menu.
|
||||
--- @param data any: Data from the NUI (not used in this function).
|
||||
--- @param cb function: Callback function to signal completion of the NUI callback.
|
||||
RegisterNUICallback('menuClose', function(data, cb)
|
||||
SetNuiFocus(false, false)
|
||||
storedData = {}
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
--- NUI callback for menu item selection.
|
||||
--- @param data table: Data from the NUI, including event details.
|
||||
--- @param cb function: Callback function to signal completion of the NUI callback. The callback should be called with a string status, e.g., 'ok' or an error message.
|
||||
RegisterNUICallback('MenuSelect', function(data, cb)
|
||||
local menuData = storedData[data.data.id]
|
||||
if menuData then
|
||||
if menuData.server then
|
||||
TriggerServerEvent(menuData.event, table.unpack(menuData.args))
|
||||
else
|
||||
TriggerEvent(menuData.event, table.unpack(menuData.args))
|
||||
end
|
||||
|
||||
SetNuiFocus(false, false)
|
||||
storedData = {}
|
||||
end
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
exports("CreateMenu", createMenu)
|
||||
exports("HideMenu", hideMenu)
|
19
resources/[freizeit]/[gym]/ps-ui/client/notify.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
--- Sends a notification to the user.
|
||||
--- @param text string: The text content of the notification.
|
||||
--- @param type string|nil: The type of notification (e.g., 'primary', 'success', 'error'). Defaults to 'primary' if nil.
|
||||
--- @param length number|nil: Duration of the notification in milliseconds. Defaults to 5000 milliseconds (5 seconds) if nil.
|
||||
local function notify(text, type, length)
|
||||
type = type or 'primary' -- Default to 'primary' if type is nil
|
||||
length = length or 5000 -- Default to 5000 milliseconds if length is nil
|
||||
DebugPrint("Notify called with " .. text .. " text and " .. type .. " type")
|
||||
SendNUI("ShowNotification", nil, {
|
||||
text = text, -- Notification text
|
||||
type = type, -- Notification type
|
||||
length = length -- Duration of the notification
|
||||
}, false)
|
||||
end
|
||||
|
||||
--- Network event handler for sending a notification.
|
||||
RegisterNetEvent('ps-ui:Notify', notify)
|
||||
|
||||
exports('Notify', notify)
|
16
resources/[freizeit]/[gym]/ps-ui/client/numbermaze.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
--- Starts the maze game.
|
||||
--- @param callback function: Callback function to handle the result of the game (true for success, false for failure).
|
||||
--- @param speed number|nil: Time duration of the game in seconds. Defaults to 10 seconds if nil.
|
||||
local function Maze(callback, speed)
|
||||
if speed == nil then speed = 10 end -- Default to 10 seconds if speed is nil
|
||||
DebugPrint("Maze called with " .. speed .. " speed")
|
||||
SendNUI("GameLauncher", callback, {
|
||||
game = "NumberMaze", -- Name of the game
|
||||
gameName = "NumberMaze", -- Display name of the game
|
||||
gameDescription = "Test your skills in the Number Maze! Race against the clock to find the correct sequence and beat the challenge. Can you solve it before time runs out?", -- Description of the game
|
||||
gameTime = speed, -- Time duration of the game
|
||||
triggerEvent = 'maze-callback', -- Event to trigger on completion
|
||||
maxAnswersIncorrect = 2, -- Maximum number of incorrect answers allowed
|
||||
}, true)
|
||||
end
|
||||
exports("Maze", Maze)
|
21
resources/[freizeit]/[gym]/ps-ui/client/scrambler.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
--- Starts the scrambler game.
|
||||
--- @param callback function: Callback function to handle the result of the game (true for success, false for failure).
|
||||
--- @param type string|nil: Type of the game (e.g., 'alphabet', 'numeric'). Defaults to "alphabet" if nil.
|
||||
--- @param time number|nil: Time duration of the game in seconds. Defaults to 10 seconds if nil.
|
||||
--- @param mirrored number|nil: Option to include mirrored text (0: Normal, 1: Normal + Mirrored, 2: Mirrored only). Defaults to 0 if nil.
|
||||
local function scrambler(callback, type, time, mirrored)
|
||||
if type == nil then type = "alphabet" end -- Default to "alphabet" if type is nil
|
||||
if time == nil then time = 10 end -- Default to 10 seconds if time is nil
|
||||
if mirrored == nil then mirrored = 0 end -- Default to 0 if mirrored is nil
|
||||
DebugPrint("Scrambler called with " .. type .. " type and " .. time .. " time")
|
||||
SendNUI("GameLauncher", callback, { -- Use SendNUI with nil callback
|
||||
game = "Scramber", -- Internal name of the game
|
||||
gameName = "Scrambler", -- Display name of the game
|
||||
gameDescription = "Challenge your brain with the Scrambler game! Depending on your choice, you'll either unscramble letters or numbers, with an option for mirrored text. Can you solve the puzzles before time runs out?", -- Description of the game
|
||||
amountOfAnswers = 4, -- Number of answers to provide in the game
|
||||
gameTime = time, -- Time duration of the game
|
||||
sets = type, -- Type of the game
|
||||
changeBoardAfter = 1, -- Specifies if the board should change after a certain condition
|
||||
}, true)
|
||||
end
|
||||
exports("Scrambler", scrambler)
|
28
resources/[freizeit]/[gym]/ps-ui/client/showImage.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
--- Sets the display state for the NUI with an optional image.
|
||||
--- @param bool boolean: Determines whether to show or hide the NUI. `true` to show, `false` to hide.
|
||||
--- @param img string|nil: URL of the image to display. Ignored if `bool` is `false`.
|
||||
local function setDisplay(bool, img)
|
||||
DebugPrint("ShowImage called with " .. tostring(bool) .. " bool and " .. img .. " img")
|
||||
SendNUI("ShowImage", nil, {
|
||||
url = bool and img or nil,
|
||||
show = bool,
|
||||
}, true)
|
||||
end
|
||||
|
||||
--- Shows an image by setting the display state to `true`.
|
||||
--- @param img string: URL of the image to display.
|
||||
local function showImage(img)
|
||||
setDisplay(true, img)
|
||||
end
|
||||
|
||||
--- NUI callback for handling the image display state change.
|
||||
--- @param data table: Data received from the NUI callback.
|
||||
--- @field data.show boolean: Indicates whether the image was shown or hidden.
|
||||
--- @param cb function: Callback function to signal completion of the NUI callback.
|
||||
RegisterNUICallback("showItemImage-callback", function(data, cb)
|
||||
setDisplay(false)
|
||||
SetNuiFocus(false, false)
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
exports("ShowImage", showImage)
|
33
resources/[freizeit]/[gym]/ps-ui/client/status.lua
Normal file
|
@ -0,0 +1,33 @@
|
|||
--- Shows the status bar with the given details.
|
||||
--- @param title string: Title to display on the status bar.
|
||||
--- @param description string: Description to display on the status bar.
|
||||
--- @param icon string: Icon to display on the status bar.
|
||||
--- @param values table: List of items to display in the status bar. Each item is typically a table with `key` and `value` fields.
|
||||
local function statusShow(title, description, icon, values)
|
||||
DebugPrint("StatusBar called with " .. title .. " title, " .. description .. " description, " .. icon .. " icon, and " .. json.encode(values) .. " values")
|
||||
SendNUI("ShowStatusBar", nil, {
|
||||
title = title,
|
||||
description = description,
|
||||
icon = icon,
|
||||
items = values,
|
||||
}, false)
|
||||
end
|
||||
--- Hides the status bar.
|
||||
local function statusHide()
|
||||
SendNUI("HideStatusBar", nil, {}, false)
|
||||
end
|
||||
|
||||
--- Updates the status bar with new information.
|
||||
--- @param title string: Title to display on the status bar.
|
||||
--- @param values table: List of items to display in the status bar. Each item is typically a table with `key` and `value` fields.
|
||||
local function statusUpdate(title, values)
|
||||
SendNUI("updateStatusBar", nil, {
|
||||
update = true,
|
||||
title = title,
|
||||
values = values,
|
||||
}, false)
|
||||
end
|
||||
|
||||
exports("StatusShow", statusShow)
|
||||
exports("StatusHide", statusHide)
|
||||
exports("StatusUpdate", statusUpdate)
|
35
resources/[freizeit]/[gym]/ps-ui/client/thermite.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
local correctBlocksBasedOnGrid = {
|
||||
[5] = 10,
|
||||
[6] = 14,
|
||||
[7] = 18,
|
||||
[8] = 20,
|
||||
[9] = 24,
|
||||
[10] = 28,
|
||||
}
|
||||
|
||||
--- Starts the Thermite game with the specified parameters.
|
||||
--- @param cb function: Callback function that will receive the result of the game (true for success, false for failure).
|
||||
--- @param time number|nil: Time duration for the game in seconds. Default is 10 if nil.
|
||||
--- @param gridsize number|nil: Size of the game grid (number of blocks per side). Default is 6 if nil.
|
||||
--- @param wrong number|nil: Maximum number of incorrect answers allowed. Default is 3 if nil.
|
||||
--- @param correctBlocks number|nil: Number of correct blocks to display. If not provided, it is determined based on the grid size.
|
||||
local function thermite(cb, time, gridsize, wrong, correctBlocks)
|
||||
-- Default values if parameters are not provided
|
||||
if time == nil then time = 10 end
|
||||
if gridsize <= 5 or gridsize == nil then gridsize = 6 end
|
||||
if wrong == nil then wrong = 3 end
|
||||
|
||||
local correctBlockCount = correctBlocks or correctBlocksBasedOnGrid[gridsize]
|
||||
DebugPrint("Thermite called with " .. correctBlockCount .. " correct blocks and " .. time .. " time")
|
||||
SendNUI("GameLauncher", cb, { -- Use SendNUI with nil callback
|
||||
game = "MemoryGame", -- Name of the game
|
||||
gameName = "Memory Game", -- Display name of the game
|
||||
gameDescription = "Test your memory with Thermite! Match blocks on a grid before time runs out. Adjust grid size and incorrect answers for added challenge!", -- Description of the game
|
||||
amountOfAnswers = correctBlockCount, -- Number of correct blocks to display
|
||||
gameTime = time, -- Time duration for the game
|
||||
maxAnswersIncorrect = wrong, -- Maximum number of incorrect answers allowed
|
||||
displayInitialAnswersFor = 3, -- Time to display initial answers (seconds)
|
||||
gridSize = gridsize, -- Size of the game grid
|
||||
}, true)
|
||||
end
|
||||
exports("Thermite", thermite)
|
56
resources/[freizeit]/[gym]/ps-ui/client/utils.lua
Normal file
|
@ -0,0 +1,56 @@
|
|||
local callback = nil
|
||||
local isActive = false
|
||||
local debug = false
|
||||
|
||||
-- When the NUI is closed, call the callback function and returns result
|
||||
RegisterNUICallback('minigame:callback', function(res, cb)
|
||||
SetNuiFocus(false, false)
|
||||
|
||||
if callback then
|
||||
callback(res)
|
||||
end
|
||||
|
||||
DebugPrint("Minigame closed. Result: " .. tostring(res))
|
||||
|
||||
isActive = false
|
||||
|
||||
cb('ok')
|
||||
end)
|
||||
|
||||
-- Sends a NUI message to the UI
|
||||
---@param action string -- Action to be sent to the NUI
|
||||
---@param cb fun()|nil -- Callback function to be called when the NUI is closed, or nil if no callback is needed
|
||||
---@param data table -- Data to be sent to the NUI
|
||||
---@param nuiFocus boolean -- Whether to set NUI focus or not
|
||||
function SendNUI(action, cb, data, nuiFocus)
|
||||
if not isActive then
|
||||
isActive = true
|
||||
SetNuiFocus(nuiFocus, nuiFocus)
|
||||
SendNUIMessage({
|
||||
action = action,
|
||||
data = data
|
||||
})
|
||||
if not cb then
|
||||
isActive = false
|
||||
end
|
||||
end
|
||||
|
||||
if cb then
|
||||
callback = cb
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Debug function to print to the console
|
||||
function DebugPrint(...)
|
||||
if not debug then return end
|
||||
local args <const> = { ... }
|
||||
|
||||
local appendStr = ''
|
||||
for _, v in ipairs(args) do
|
||||
appendStr = appendStr .. ' ' .. tostring(v)
|
||||
end
|
||||
local msgTemplate = '^3[%s]^0%s'
|
||||
local finalMsg = msgTemplate:format("ps-ui", appendStr)
|
||||
print(finalMsg)
|
||||
end
|
20
resources/[freizeit]/[gym]/ps-ui/client/var.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
-- Starts the VarHack game with the specified parameters.
|
||||
--- @param callback function: Callback function that will receive the result of the game (true for success, false for failure).
|
||||
--- @param blocks number|nil: Number of blocks in the game. Default is 5 if nil or out of range (1-15).
|
||||
--- @param speed number|nil: Speed of the game in seconds. Default is 20 if nil or less than 2.
|
||||
local function varHack(callback, blocks, speed)
|
||||
if speed == nil or (speed < 2) then speed = 20 end -- Default speed if not provided or less than 2
|
||||
if blocks == nil or (blocks < 1 or blocks > 15) then blocks = 5 end -- Default blocks if not provided or out of range (1-15
|
||||
DebugPrint("VarHack called with " .. blocks .. " blocks and " .. speed .. " speed")
|
||||
SendNUI("GameLauncher", callback, {
|
||||
game = "NumberPuzzle", -- Name of the game
|
||||
gameName = "NumberPuzzle", -- Display name of the game
|
||||
gameDescription = "Test your skills with VarHack! Solve the number puzzle by matching blocks within the time limit. Adjust the number of blocks and game speed for a personalized challenge!", -- Description of the game
|
||||
gameTime = 15, -- Duration of the game in seconds
|
||||
triggerEvent = 'var-callback', -- Event to trigger on game completion
|
||||
maxAnswersIncorrect = 2, -- Maximum number of incorrect answers allowed
|
||||
amountOfAnswers = blocks, -- Number of blocks in the game
|
||||
timeForNumberDisplay = 3, -- Time to display numbers (seconds)
|
||||
}, true)
|
||||
end
|
||||
exports("VarHack", varHack)
|
18
resources/[freizeit]/[gym]/ps-ui/fxmanifest.lua
Normal file
|
@ -0,0 +1,18 @@
|
|||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
author 'Project Sloth'
|
||||
description 'UI Library'
|
||||
version '2.0.1'
|
||||
repository 'https://github.com/Project-Sloth/ps-ui'
|
||||
credits 'https://github.com/sharkiller/nopixel_minigame'
|
||||
lua54 'yes'
|
||||
|
||||
ui_page 'web/build/index.html'
|
||||
|
||||
client_scripts {
|
||||
'client/**'
|
||||
}
|
||||
|
||||
files {
|
||||
'web/build/**',
|
||||
}
|
24
resources/[freizeit]/[gym]/ps-ui/web/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
48
resources/[freizeit]/[gym]/ps-ui/web/README.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Svelte + TS + Vite
|
||||
|
||||
This template should help get you started developing with Svelte and TypeScript in Vite.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
|
||||
|
||||
## Need an official Svelte framework?
|
||||
|
||||
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
|
||||
|
||||
## Technical considerations
|
||||
|
||||
**Why use this over SvelteKit?**
|
||||
|
||||
- It brings its own routing solution which might not be preferable for some users.
|
||||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
|
||||
`vite dev` and `vite build` wouldn't work in a SvelteKit environment, for example.
|
||||
|
||||
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
|
||||
|
||||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
|
||||
|
||||
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
|
||||
|
||||
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
|
||||
|
||||
**Why include `.vscode/extensions.json`?**
|
||||
|
||||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
|
||||
|
||||
**Why enable `allowJs` in the TS template?**
|
||||
|
||||
While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.
|
||||
|
||||
**Why is HMR not preserving my local component state?**
|
||||
|
||||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
|
||||
|
||||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
|
||||
|
||||
```ts
|
||||
// store.ts
|
||||
// An extremely simple external store
|
||||
import { writable } from 'svelte/store'
|
||||
export default writable(0)
|
||||
```
|
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/Hacker.ttf
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/Roboto-Regular.ttf
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/fa-brands-400.ttf
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/fa-brands-400.woff2
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/fa-regular-400.ttf
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/fa-regular-400.woff2
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/fa-solid-900.ttf
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/fa-solid-900.woff2
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/favicon.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/images/ps-logo.png
Normal file
After Width: | Height: | Size: 29 KiB |
5
resources/[freizeit]/[gym]/ps-ui/web/build/index.css
Normal file
1
resources/[freizeit]/[gym]/ps-ui/web/build/index.html
Normal file
|
@ -0,0 +1 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><link rel="icon" href="./favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer"><title>PS-UI</title><script type="module" crossorigin src="./index.js"></script><link rel="stylesheet" crossorigin href="./index.css"></head><body><div id="app"></div></body></html>
|
73
resources/[freizeit]/[gym]/ps-ui/web/build/index.js
Normal file
BIN
resources/[freizeit]/[gym]/ps-ui/web/build/ka1.ttf
Normal file
1
resources/[freizeit]/[gym]/ps-ui/web/css/master.css
Normal file
|
@ -0,0 +1 @@
|
|||
@import './themes.css';
|
16
resources/[freizeit]/[gym]/ps-ui/web/css/themes.css
Normal file
|
@ -0,0 +1,16 @@
|
|||
:root {
|
||||
--color-green: #02f1b5;
|
||||
--color-palegreen: #039672;
|
||||
--color-darkblue: #131313;
|
||||
--color-blue: #0057ae;
|
||||
--color-lightgrey: #dadada;
|
||||
--color-white: #ffffff;
|
||||
--color-black: #000000;
|
||||
--color-darkgrey: #6a6a6a;
|
||||
--color-red: #e10404;
|
||||
|
||||
--cube-bg-darkgreen: #0f2a25;
|
||||
|
||||
font-size: 0.8em;
|
||||
font-family: 'roboto', sans-serif;
|
||||
}
|
21
resources/[freizeit]/[gym]/ps-ui/web/index.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="./public/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
|
||||
integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<title>PS-UI</title>
|
||||
<link rel="stylesheet" href="./css/master.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
3019
resources/[freizeit]/[gym]/ps-ui/web/package-lock.json
generated
Normal file
29
resources/[freizeit]/[gym]/ps-ui/web/package.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "ps-ui",
|
||||
"version": "2.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.1",
|
||||
"@tsconfig/svelte": "^5.0.2",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"postcss": "^8.4.33",
|
||||
"svelte": "^4.2.8",
|
||||
"svelte-check": "^3.6.2",
|
||||
"svelte-preprocess": "^5.1.3",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.0.11",
|
||||
"html-minifier": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^6.5.1",
|
||||
"@mojs/core": "^1.7.1"
|
||||
}
|
||||
}
|
1961
resources/[freizeit]/[gym]/ps-ui/web/pnpm-lock.yaml
generated
Normal file
7
resources/[freizeit]/[gym]/ps-ui/web/postcss.config.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import tailwind from 'tailwindcss';
|
||||
import autoprefixer from 'autoprefixer';
|
||||
import tailwindConfig from './tailwind.config.cjs';
|
||||
|
||||
export default {
|
||||
plugins: [tailwind(tailwindConfig), autoprefixer],
|
||||
}
|
BIN
resources/[freizeit]/[gym]/ps-ui/web/public/favicon.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/[freizeit]/[gym]/ps-ui/web/public/images/ps-logo.png
Normal file
After Width: | Height: | Size: 29 KiB |
224
resources/[freizeit]/[gym]/ps-ui/web/src/App.svelte
Normal file
|
@ -0,0 +1,224 @@
|
|||
<script lang="ts">
|
||||
// Svelte
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
// Stores
|
||||
import { isDevMode, showComponent } from './stores/GeneralStores';
|
||||
import { showUi } from './stores/GeneralStores';
|
||||
|
||||
// Enums
|
||||
import { UIComponentsEnum } from './enums/UIComponentsEnum';
|
||||
|
||||
// PS-UI components
|
||||
import GameLauncher from './games/GameLauncher.svelte';
|
||||
import { EventHandler, handleKeyUp } from './../utils/eventHandler';
|
||||
import Image from './components/Image.svelte';
|
||||
import { notificationMock } from './../utils/mockEvent';
|
||||
import Notification from './components/Notification.svelte';
|
||||
import { GamesEnum } from './enums/GamesEnum';
|
||||
import InputComponent from './components/InputComponent.svelte';
|
||||
import StatusBarComponent from './components/StatusBarComponent.svelte';
|
||||
import DrawTextComponent from './components/DrawTextComponent.svelte';
|
||||
import InteractionMenuComponent from './components/InteractionMenuComponent.svelte';
|
||||
import CircleGame from './games/CircleGame.svelte';
|
||||
|
||||
EventHandler();
|
||||
document.onkeyup = handleKeyUp;
|
||||
|
||||
if(isDevMode) {
|
||||
notificationMock();
|
||||
const memoryGameData = {
|
||||
game: GamesEnum.Memory,
|
||||
gameName: 'Memory MiniGame',
|
||||
gameDescription: 'Lorem ipsum is placceholder text commonly used in the arachic, print and publishing industries for previewing layouts and visual mockups.',
|
||||
amountOfAnswers: 9,
|
||||
gameTime: 30, // seconds
|
||||
maxAnswersIncorrect: 0,
|
||||
displayInitialAnswersFor: 5, //seconds
|
||||
gridSize: 10, //5,6,7,8,9,10 - one of these values as number of rows and columns
|
||||
triggerEvent: 'memorygame-callback',
|
||||
};
|
||||
// setupGame({ data: memoryGameData});
|
||||
|
||||
const scramblerGameData = {
|
||||
game: GamesEnum.Scrambler,
|
||||
gameName: 'Scrambler MiniGame',
|
||||
gameDescription: 'Lorem ipsum is placeholder text commonly used in the arachic, print and publishing industries for previewing layouts and visual mockups.',
|
||||
amountOfAnswers: 4, // count of numbers to display
|
||||
gameTime: 80, // seconds
|
||||
sets: 'numeric', // numeric, alphabet, alphanumeric, greek, braille, runes
|
||||
changeBoardAfter: 3 //seconds
|
||||
};
|
||||
// setupGame({ data: scramblerGameData});
|
||||
|
||||
const numberMazeGameData = {
|
||||
game: GamesEnum.NumberMaze,
|
||||
gameName: 'Number Maze MiniGame',
|
||||
gameDescription: 'Lorem ipsum is placeholder text commonly used in the arachic, print and publishing industries for previewing layouts and visual mockups.',
|
||||
gameTime: 30, // seconds
|
||||
maxAnswersIncorrect: 2,
|
||||
triggerEvent: 'maze-callback',
|
||||
};
|
||||
// setupGame({ data: numberMazeGameData});
|
||||
|
||||
const numberPuzzleGameData = {
|
||||
game: GamesEnum.NumberPuzzle,
|
||||
gameName: 'Number Puzzle MiniGame',
|
||||
gameDescription: 'Lorem ipsum is placeholder text commonly used in the arachic, print and publishing industries for previewing layouts and visual mockups.',
|
||||
gameTime: 3, // seconds
|
||||
maxAnswersIncorrect: 2,
|
||||
amountOfAnswers: 5,
|
||||
timeForNumberDisplay: 5, // seconds
|
||||
triggerEvent: 'var-callback',
|
||||
};
|
||||
// setupGame({ data: numberPuzzleGameData});
|
||||
|
||||
//input
|
||||
const inputData = [
|
||||
{
|
||||
id: '1',
|
||||
label: 'Name',
|
||||
icon: 'fa-solid fa-pen',
|
||||
placeholder: 'Insert name',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
label: 'Password',
|
||||
icon: 'fa-solid fa-lock',
|
||||
placeholder: 'Enter password',
|
||||
type: 'password',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
label: 'Phone',
|
||||
icon: 'fa-solid fa-phone',
|
||||
placeholder: 'Enter phone number',
|
||||
type: 'phone',
|
||||
},
|
||||
];
|
||||
|
||||
// showInput(inputData);
|
||||
|
||||
const statusBarData = {
|
||||
title: 'Area Dominance',
|
||||
description: 'Write some description here',
|
||||
icon: 'fa-solid fa-circle-info',
|
||||
items: [
|
||||
{
|
||||
key: 'Gang', value: 'Ballas'
|
||||
},
|
||||
{
|
||||
key: 'Dominance', value: '20%'
|
||||
}
|
||||
],
|
||||
};
|
||||
// showStatusBar(statusBarData);
|
||||
|
||||
// // double call for status bar
|
||||
// setTimeout(() => {
|
||||
// showStatusBar(
|
||||
// {
|
||||
// title: 'Area Check',
|
||||
// description: 'Whats up',
|
||||
// icon: 'fa-solid fa-heart',
|
||||
// items: [
|
||||
// {
|
||||
// key: 'Gang', value: 'Ace'
|
||||
// }
|
||||
// ],
|
||||
// }
|
||||
// )
|
||||
// }, 5000);
|
||||
|
||||
const drawTextData = {
|
||||
icon: 'fa-solid fa-circle-info',
|
||||
keys: 'Press [E] to interact',
|
||||
color: 'yellow'
|
||||
};
|
||||
// showDrawTextMenu(drawTextData);
|
||||
|
||||
// // double call for draw text
|
||||
// setTimeout(() => {
|
||||
// showDrawTextMenu(
|
||||
// {
|
||||
// icon: 'fa-solid fa-circle-info',
|
||||
// keys: 'Press [E] to interact and check if the old one exists',
|
||||
// color: ''
|
||||
// }
|
||||
// );
|
||||
// }, 5000);
|
||||
|
||||
const interactionMenuData = [
|
||||
{
|
||||
header: 'Menu item 1',
|
||||
text: 'Some text',
|
||||
icon: 'fa-solid fa-user',
|
||||
color: '#02f1b5',
|
||||
callback: '',
|
||||
subMenu: null,
|
||||
},
|
||||
{
|
||||
header: 'Menu item 2',
|
||||
icon: 'fa-solid fa-user',
|
||||
color: '',
|
||||
callback: '',
|
||||
subMenu: [
|
||||
{
|
||||
header: 'Submenu1',
|
||||
icon: 'fa-solid fa-circle-info',
|
||||
color: '#02f1b5',
|
||||
},
|
||||
{
|
||||
header: 'Submenu2',
|
||||
icon: 'fa-solid fa-circle-info',
|
||||
color: '#02f1b5',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
// setupInteractionMenu(interactionMenuData);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if $showUi }
|
||||
<!-- class="min-h-screen min-w-full" -->
|
||||
<main transition:fade={{ duration: 100 }} class="main-bg">
|
||||
{#if $showComponent === UIComponentsEnum.StatusBar}
|
||||
<StatusBarComponent />
|
||||
{/if}
|
||||
|
||||
{#if $showComponent === UIComponentsEnum.DrawText}
|
||||
<DrawTextComponent />
|
||||
{/if}
|
||||
|
||||
{#if $showComponent === UIComponentsEnum.Menu}
|
||||
<InteractionMenuComponent />
|
||||
{/if}
|
||||
|
||||
{#if $showComponent === UIComponentsEnum.Input}
|
||||
<InputComponent />
|
||||
{/if}
|
||||
|
||||
{#if $showComponent === UIComponentsEnum.Game}
|
||||
<GameLauncher />
|
||||
{/if}
|
||||
|
||||
{#if $showComponent === UIComponentsEnum.Image}
|
||||
<Image />
|
||||
{/if}
|
||||
|
||||
{#if $showComponent === UIComponentsEnum.Notification}
|
||||
<Notification />
|
||||
{/if}
|
||||
<CircleGame />
|
||||
</main>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.main-bg {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
BIN
resources/[freizeit]/[gym]/ps-ui/web/src/assets/svelte.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
|
@ -0,0 +1,40 @@
|
|||
<script lang="ts">
|
||||
export let color: string = '';
|
||||
</script>
|
||||
|
||||
<svg
|
||||
version="1.1"
|
||||
id="Layer_1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 437.3 512"
|
||||
style="enable-background:new 0 0 437.3 512;"
|
||||
xml:space="preserve"
|
||||
fill={color}
|
||||
>
|
||||
<g>
|
||||
<path
|
||||
d="M230.3,455.7c-8.3,0-16.6,0-25,0c-8.5-3.1-17.2-5.7-25.4-9.4c-21.9-9.8-42.1-22.2-58.1-40.4c-10-11.3-16.2-24.2-15.6-39.9
|
||||
c0.5-13.5,0.1-27,0.1-40.5c0-2-0.2-3.2-2.5-4.1c-24.3-9.4-38-29.4-38.1-55.6c-0.1-24.7-0.3-49.4,0.1-74.1c0.2-9.7,0.9-19.6,3.2-29
|
||||
c12.1-47.6,42.8-78.7,87.9-96.4c21.1-8.3,43.3-10.3,65.8-10c33.5,0.4,64.5,8.9,91.8,28.7c35.8,26,56,60.8,56.8,105.6
|
||||
c0.5,25.3,0.2,50.7,0,76c-0.2,25.5-14.4,45.8-37.8,54.6c-2.4,0.9-2.8,2.1-2.8,4.3c0.1,14.3-0.1,28.6,0.1,42.9
|
||||
c0.2,11.1-3.6,20.9-9.8,29.8c-10,14.4-23.5,24.8-38.1,34C266.6,442.5,249.2,450.7,230.3,455.7z M165.8,219.1
|
||||
c-4.7,0.4-9.3,0.5-14,1.1c-12.7,1.5-22,8-26.3,20.1c-4.1,11.4-2.3,22.9,2.4,33.7c3.9,8.9,13.3,13.7,22.6,10.8c9-2.8,17.7-7.2,26-12
|
||||
c8.6-5,15.2-12.4,19.6-21.6c5.8-12,2.3-22.3-9.5-28.3C180,219.5,173,218.9,165.8,219.1z M274.1,218.4c-5.8,1-11.9,1.4-17.5,3.2
|
||||
c-14.4,4.7-19.2,16.8-12.3,30.2c1.7,3.3,3.8,6.5,6.2,9.4c9.1,11.3,21.8,17.4,34.8,22.6c11.9,4.8,24.3-0.9,28.1-13.1
|
||||
c1.9-6.2,2.5-13,2.9-19.5c0.7-12.6-7.2-24.7-19.2-28.7C289.9,220.2,282,219.7,274.1,218.4z M212.6,371.3c-0.5-6.4-2.3-9-6.2-9.2
|
||||
c-3.9-0.2-5.8,2.4-6.9,8.9c-4,0-7.9,0-12.1,0c0.3-4.2-0.8-7.4-4.8-8.6c-4.1-1.2-6.5,1.3-8.5,4.6c-3.7-2-5.4-4.9-5.4-8.9
|
||||
c0-5.8,0-11.7,0-17.5c0-6.9-0.8-8.1-7.2-10.2c-9.7-3.3-19.4-6.5-29.2-9.7c-1.3-0.4-2.7-0.9-4.1-1c-3-0.2-5.1,1.3-6,4
|
||||
c-1,2.7-0.2,5.2,2.2,6.9c1.2,0.9,2.8,1.4,4.2,1.9c8.4,2.8,16.7,5.7,25.1,8.4c2,0.6,2.6,1.6,2.6,3.6c-0.1,4.7,0,9.4,0,14
|
||||
c0,7,2.8,12.6,8.2,16.9c8.1,6.6,17.7,8.5,27.7,8.5c17,0.1,34.1,0.3,51.1-0.1c6.8-0.2,13.7-1.2,20.3-3c9.4-2.7,15.9-8.8,16.8-19.2
|
||||
c0.5-5.4,0.7-10.9,0.6-16.3c0-2.6,0.7-3.9,3.3-4.7c8.7-2.7,17.2-5.7,25.8-8.8c4.8-1.7,6.3-6.8,3.1-10.2c-2.4-2.6-5.3-2.2-8.3-1.2
|
||||
c-10.3,3.5-20.6,7-31,10.4c-3.8,1.2-5.4,3.6-5.3,7.5c0.1,6,0.2,12,0,17.9c-0.1,4.8-1.2,9.3-6.5,11.3c-1.1-3.4-3.1-5.9-6.7-5.4
|
||||
c-5.1,0.6-5.4,4.8-5.7,9c-4.2,0-8.1,0-12.1,0c-0.5-6.3-2.3-8.9-6.2-9.1c-3.8-0.2-5.8,2.4-6.9,9.2
|
||||
C220.6,371.3,216.7,371.3,212.6,371.3z M218,331C218,331,218,331,218,331c3.9,0,7.8,0.2,11.7-0.1c5.6-0.3,8.7-3,9.4-8.6
|
||||
c0.4-3.4,0.3-7-0.1-10.5c-1.6-11.9-4.4-23.5-11.1-33.7c-5.3-8.2-13.3-8.9-18.6-1.1c-9,13.3-12.5,28.4-12.3,44.3
|
||||
c0.1,5.9,3.9,9.2,9.8,9.5C210.4,331.2,214.2,331,218,331z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M512 208v224c0 8.75-7.25 16-16 16H416v-128h-32v128h-64v-128h-32v128H224v-128H192v128H128v-128H96v128H16C7.25 448 0 440.8 0 432v-224C0 199.2 7.25 192 16 192H64V144C64 135.2 71.25 128 80 128H128V80C128 71.25 135.2 64 144 64h224C376.8 64 384 71.25 384 80V128h48C440.8 128 448 135.2 448 144V192h48C504.8 192 512 199.2 512 208z"/></svg>
|
After Width: | Height: | Size: 570 B |
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M400 0C426.5 0 448 21.49 448 48V144C448 170.5 426.5 192 400 192H352V224H608C625.7 224 640 238.3 640 256C640 273.7 625.7 288 608 288H512V320H560C586.5 320 608 341.5 608 368V464C608 490.5 586.5 512 560 512H400C373.5 512 352 490.5 352 464V368C352 341.5 373.5 320 400 320H448V288H192V320H240C266.5 320 288 341.5 288 368V464C288 490.5 266.5 512 240 512H80C53.49 512 32 490.5 32 464V368C32 341.5 53.49 320 80 320H128V288H32C14.33 288 0 273.7 0 256C0 238.3 14.33 224 32 224H288V192H240C213.5 192 192 170.5 192 144V48C192 21.49 213.5 0 240 0H400zM256 64V128H384V64H256zM224 448V384H96V448H224zM416 384V448H544V384H416z"/></svg>
|
After Width: | Height: | Size: 858 B |
|
@ -0,0 +1,229 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import Icon from "./Icon.svelte";
|
||||
import { isDevMode, showComponent, showUi } from "../stores/GeneralStores";
|
||||
import { drawTextStore, hideDrawTextMenu, hideDrawTextStore } from "../stores/DrawTextStore";
|
||||
|
||||
let drawTextDataValue:any = {};
|
||||
drawTextStore.subscribe((value) => drawTextDataValue = value);
|
||||
|
||||
let hideDrawTextValue = false;
|
||||
hideDrawTextStore.subscribe(value => {
|
||||
hideDrawTextValue = value;
|
||||
});
|
||||
|
||||
let marginLeftVal = '2%';
|
||||
let interactionText = [], colorValue = '';
|
||||
|
||||
onMount(() => {
|
||||
getColorValue();
|
||||
handleInteractionText();
|
||||
|
||||
if(isDevMode) {
|
||||
setTimeout(() => {
|
||||
hideDrawTextMenu();
|
||||
}, 10000);
|
||||
}
|
||||
});
|
||||
|
||||
function getColorValue() {
|
||||
switch(drawTextDataValue.color) {
|
||||
case "primary":
|
||||
colorValue ="#0275d8";
|
||||
break;
|
||||
case "error":
|
||||
colorValue = "#d9534f";
|
||||
break;
|
||||
case "success":
|
||||
colorValue = "#5cb85c";
|
||||
break;
|
||||
case "warning":
|
||||
colorValue = "#f0ad4e";
|
||||
break;
|
||||
case "info":
|
||||
colorValue = "#5bc0de";
|
||||
break;
|
||||
case "mint":
|
||||
colorValue = "#a1f8c7";
|
||||
break;
|
||||
default:
|
||||
colorValue = "var(--color-green)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function handleInteractionText() {
|
||||
let matches = drawTextDataValue.keys.match(/\[(.*?)\]/);
|
||||
if (matches) {
|
||||
let submatch = matches[0];
|
||||
|
||||
let splitText = drawTextDataValue.keys.split(submatch);
|
||||
interactionText = [
|
||||
{
|
||||
value: splitText[0],
|
||||
color: 'var(--color-lightgrey)'
|
||||
},
|
||||
{
|
||||
value: submatch,
|
||||
color: colorValue
|
||||
},
|
||||
{
|
||||
value: splitText[1],
|
||||
color: 'var(--color-lightgrey)'
|
||||
}
|
||||
];
|
||||
} else {
|
||||
interactionText = [
|
||||
{
|
||||
value: drawTextDataValue.keys,
|
||||
color: 'var(--color-lightgrey)'
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function closeDrawText() {
|
||||
const statusWrapperDom = document.getElementById('draw-text-wrapper');
|
||||
if(statusWrapperDom) {
|
||||
statusWrapperDom.style.animation = '2s slide-left';
|
||||
|
||||
let keyFrames = document.createElement('style');
|
||||
|
||||
keyFrames.innerHTML = `
|
||||
@keyframes slide-left {
|
||||
from {
|
||||
margin-left: `+marginLeftVal+`;
|
||||
}
|
||||
to {
|
||||
margin-left: -20%;
|
||||
}
|
||||
}
|
||||
|
||||
.draw-text-wrapper {
|
||||
-moz-animation: 2s slide-left;
|
||||
-webkit-animation: 2s slide-left;
|
||||
animation: 2s slide-left;
|
||||
}
|
||||
`;
|
||||
|
||||
statusWrapperDom.appendChild(keyFrames);
|
||||
|
||||
setTimeout(() => {
|
||||
showUi.set(false);
|
||||
showComponent.set(null);
|
||||
|
||||
drawTextStore.set({
|
||||
// title: '',
|
||||
icon: '',
|
||||
keys: '',
|
||||
color: ''
|
||||
});
|
||||
hideDrawTextStore.set(false);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
if(hideDrawTextValue) {
|
||||
closeDrawText();
|
||||
}
|
||||
|
||||
if(drawTextDataValue) {
|
||||
handleInteractionText();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="draw-text-wrapper" class="draw-text-wrapper" style="margin-left:{marginLeftVal};">
|
||||
<div class="draw-text-title-wrapper">
|
||||
<div class="icon">
|
||||
<Icon icon={drawTextDataValue.icon} styleColor={colorValue} />
|
||||
</div>
|
||||
|
||||
<div class="title-info">
|
||||
<p class="title-description">
|
||||
{#each interactionText as text}
|
||||
<p style="color: {text.color};">{text.value}</p>
|
||||
{/each}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.draw-text-wrapper {
|
||||
-moz-animation: 1s slide-right;
|
||||
-webkit-animation: 1s slide-right;
|
||||
animation: 1s slide-right;
|
||||
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
|
||||
min-width: 10vw;
|
||||
width: max-content;
|
||||
|
||||
min-height: 3vw;
|
||||
height: fit-content;
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
background-color: var(--color-darkblue);
|
||||
border-radius: 0.3vw;
|
||||
|
||||
padding: 0.75vw 1.5vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@keyframes slide-right {
|
||||
from {
|
||||
margin-left: -20%;
|
||||
}
|
||||
to {
|
||||
margin-left: 2%;
|
||||
}
|
||||
}
|
||||
@keyframes slide-left {
|
||||
from {
|
||||
margin-left: 2%;
|
||||
}
|
||||
to {
|
||||
margin-left: -100%;
|
||||
}
|
||||
}
|
||||
|
||||
.draw-text-wrapper > .draw-text-title-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.draw-text-wrapper > .draw-text-title-wrapper > .icon {
|
||||
width: 1.5vw;
|
||||
margin: auto 0.75vw auto 0;
|
||||
|
||||
font-size: 1.25vw;
|
||||
}
|
||||
.draw-text-wrapper > .draw-text-title-wrapper > .title-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.draw-text-wrapper > .draw-text-title-wrapper > .title-info > .title-description {
|
||||
font-size: 1vw;
|
||||
font-weight: 300;
|
||||
color: var(--color-lightgrey);
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
word-wrap: break-word;
|
||||
flex-wrap: wrap;
|
||||
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
.draw-text-wrapper > .draw-text-title-wrapper > .title-info > .title-description > p {
|
||||
margin-right: 0.25vw;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,8 @@
|
|||
<script lang="ts">
|
||||
export let icon: string;
|
||||
export let color: string = '';
|
||||
export let classes: string = '';
|
||||
export let styleColor: string = '';
|
||||
</script>
|
||||
|
||||
<i class="{color} {icon} {classes}" style="color: {styleColor};" />
|
|
@ -0,0 +1,13 @@
|
|||
<script lang="ts">
|
||||
import { imageStore } from './../stores/ImageStore';
|
||||
import { fly } from 'svelte/transition';
|
||||
</script>
|
||||
|
||||
{#if $imageStore.show}
|
||||
<div class="flex items-center justify-center min-h-screen" transition:fly="{{y: +400}}">
|
||||
<div class="flex items-center flex-col ps-bg-darkblue p-10 shadow-md shadow-gray-800 rounded-md">
|
||||
<!-- svelte-ignore a11y-img-redundant-alt -->
|
||||
<img src={$imageStore.url} alt="Image Placeholder" />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
|
@ -0,0 +1,203 @@
|
|||
<script lang="ts">
|
||||
import { hideUi, isDevMode } from "../stores/GeneralStores";
|
||||
import { inputStore } from "../stores/InputStores";
|
||||
import Icon from "./Icon.svelte";
|
||||
import { onMount } from "svelte";
|
||||
import fetchNui from "../../utils/fetch";
|
||||
import { handleKeyUp } from "../../utils/eventHandler";
|
||||
|
||||
document.onkeyup = handleKeyUp;
|
||||
let inputData:any = $inputStore;
|
||||
|
||||
onMount(() => {
|
||||
inputData = inputData.map((val) => {
|
||||
val.value = null;
|
||||
return val;
|
||||
});
|
||||
});
|
||||
|
||||
function submit() {
|
||||
let returnData = [];
|
||||
|
||||
let inputs = document.querySelectorAll('input');
|
||||
inputs.forEach((input: HTMLInputElement, index) => {
|
||||
let returnObj = {
|
||||
id: input.id,
|
||||
value: input.value,
|
||||
// compIndex: index
|
||||
};
|
||||
|
||||
returnData.push(returnObj)
|
||||
});
|
||||
|
||||
if(!isDevMode) {
|
||||
fetchNui('input-callback', returnData);
|
||||
}
|
||||
|
||||
closeInputs();
|
||||
}
|
||||
|
||||
export function closeInputs(): void {
|
||||
let inputs = document.querySelectorAll('input');
|
||||
inputs.forEach((input: HTMLInputElement) => {
|
||||
input.value = '';
|
||||
});
|
||||
|
||||
inputData = [];
|
||||
|
||||
if(!isDevMode) {
|
||||
fetchNui('input-close', { ok: true });
|
||||
}
|
||||
|
||||
hideUi();
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="input-base-wrapper">
|
||||
<div class="logo">
|
||||
<img src="./images/ps-logo.png" alt="ps-logo" />
|
||||
</div>
|
||||
|
||||
<div class="input-form">
|
||||
{#each inputData as inputValue}
|
||||
<div class="input-wrapper">
|
||||
<div class="input-data-wrapper">
|
||||
<div class="input-icon">
|
||||
<Icon icon={inputValue.icon} color="ps-text-green" classes="text-2xl" />
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<p class="label">
|
||||
{inputValue.label}
|
||||
</p>
|
||||
<input id={inputValue.id} type={inputValue.type} class="value" placeholder={inputValue.placeholder} value={inputValue.value} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="horizontal-line"></div>
|
||||
<!-- <div class="input-message">
|
||||
{inputValue.placeholder}
|
||||
</div> -->
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="button-wrapper">
|
||||
<button class="submit-btn" on:click={submit}>Submit</button>
|
||||
<button class="cancel-btn" on:click={closeInputs}>Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.input-base-wrapper {
|
||||
/* centering the view */
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
width: 25vw;
|
||||
min-height: 28vw;
|
||||
height: fit-content;
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
background-color: var(--color-darkblue);
|
||||
border-radius: 0.3vw;
|
||||
|
||||
padding: 0.5vw 2vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.input-base-wrapper > .input-form {
|
||||
margin-top: 1vw;
|
||||
height: 100%;
|
||||
|
||||
/* border: 0.1px solid red; */
|
||||
}
|
||||
|
||||
.input-base-wrapper > .input-form > .input-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.input-base-wrapper > .input-form > .input-wrapper > .horizontal-line {
|
||||
width: inherit;
|
||||
height: 1px;
|
||||
background-color: var(--color-lightgrey);
|
||||
}
|
||||
.input-base-wrapper > .input-form > .input-wrapper > .input-message {
|
||||
font-size: 0.8vw;
|
||||
opacity: 0.85;
|
||||
color: var(--color-lightgrey);
|
||||
margin-top: 0.2vw;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
.input-base-wrapper > .input-form > .input-wrapper > .input-data-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
padding: 0.5vw 0;
|
||||
}
|
||||
.input-base-wrapper > .input-form > .input-wrapper:not(:last-child) {
|
||||
margin-bottom: 1vw;
|
||||
}
|
||||
|
||||
.input-base-wrapper > .input-form > .input-wrapper > .input-data-wrapper > .input-icon {
|
||||
margin-right: 0.75vw;
|
||||
width: 1.5vw;
|
||||
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
.input-base-wrapper > .input-form > .input-wrapper > .input-data-wrapper > .input-area {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
color: var(--color-lightgrey);
|
||||
}
|
||||
.input-base-wrapper > .input-form > .input-wrapper > .input-data-wrapper > .input-area > .label {
|
||||
font-size: 1vw;
|
||||
font-weight: 500 !important;
|
||||
}
|
||||
.input-base-wrapper > .input-form > .input-wrapper > .input-data-wrapper > .input-area > .value {
|
||||
font-size: 0.8vw;
|
||||
font-weight: 300 !important;
|
||||
width: 18vw;
|
||||
background-color: inherit;
|
||||
margin-top: 0.2vw;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
padding-left: 0;
|
||||
outline: none;
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-color: var(--color-green);
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
.input-base-wrapper > .button-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-evenly;
|
||||
|
||||
margin: 1.5vw auto 1.25vw auto;
|
||||
color: var(--color-black);
|
||||
}
|
||||
.input-base-wrapper > .button-wrapper > .submit-btn {
|
||||
background-color: var(--color-green);
|
||||
}
|
||||
.input-base-wrapper > .button-wrapper > .cancel-btn {
|
||||
background-color: var(--color-darkgrey);
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 0.3vw;
|
||||
padding: 0.3vw 1vw;
|
||||
text-transform: uppercase;
|
||||
font-weight: 500 !important;
|
||||
}
|
||||
button:not(:last-child) {
|
||||
margin-right: 0.5vw;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,256 @@
|
|||
<script lang="ts">
|
||||
import { closeInteractionMenu, menuStore } from "../stores/MenuStores";
|
||||
import Icon from "./Icon.svelte";
|
||||
import fetchNui from "../../utils/fetch";
|
||||
import { isDevMode } from "../stores/GeneralStores";
|
||||
|
||||
let menuData:Array<any> = $menuStore;
|
||||
let selectedMenuItem = null;
|
||||
let subMenu = null;
|
||||
|
||||
let subMenuTextColorOverride = {
|
||||
id: null, color: 'black'
|
||||
};
|
||||
let menuTextColorOverride = {
|
||||
id: null, color: 'black'
|
||||
};
|
||||
|
||||
function handleMenuSelection(selectedMenu) {
|
||||
selectedMenuItem = selectedMenu;
|
||||
|
||||
if(selectedMenu) {
|
||||
|
||||
if(!selectedMenu.subMenu && !isDevMode) {
|
||||
fetchNui('MenuSelect', {data :selectedMenu});
|
||||
closeInteractionMenu();
|
||||
} else {
|
||||
subMenu = selectedMenuItem.subMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleSubMenuSelection(selectedSubMenu) {
|
||||
const formData = {
|
||||
data:selectedSubMenu
|
||||
};
|
||||
if(!isDevMode) {
|
||||
fetchNui('MenuSelect', formData);
|
||||
closeInteractionMenu();
|
||||
}
|
||||
}
|
||||
|
||||
function handleItemHover(itemId, index, color, action='enter', isSubMenu = false) {
|
||||
const itemDom = document.getElementById(itemId);
|
||||
if(action === 'enter') {
|
||||
if(isSubMenu) {
|
||||
itemDom.style.backgroundColor = color || 'var(--color-green)';
|
||||
subMenuTextColorOverride.id = index;
|
||||
} else {
|
||||
itemDom.style.backgroundColor = color || 'var(--color-green)';
|
||||
menuTextColorOverride.id = index;
|
||||
}
|
||||
} else {
|
||||
itemDom.style.backgroundColor = 'var(--color-darkblue)';
|
||||
subMenuTextColorOverride.id = null;
|
||||
menuTextColorOverride.id = null;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="menu-base-wrapper">
|
||||
<div class="screen-base">
|
||||
{#if !selectedMenuItem}
|
||||
<div class="header-slot" style="border: 3px solid var(--color-green);">
|
||||
<img src="./images/ps-logo.png" alt="ps-logo" />
|
||||
</div>
|
||||
|
||||
<div class="screen-body">
|
||||
{#each menuData as menu, index}
|
||||
<div id={"menu-"+index} class="each-panel"
|
||||
on:mouseenter={() => handleItemHover("menu-"+index, index, menu.color, 'enter', false)}
|
||||
on:mouseleave={() => handleItemHover("menu-"+index, index, menu.color, 'leave', false)}
|
||||
on:click={() => handleMenuSelection(menu)}>
|
||||
<div class="menu-icon">
|
||||
<Icon icon={menu.icon} styleColor={menuTextColorOverride.id === index ? menuTextColorOverride.color : menu?.color || 'var(--color-green)'} />
|
||||
</div>
|
||||
<div class="menu-details">
|
||||
<p class="header" style="color: {menuTextColorOverride.id === index ? menuTextColorOverride.color : 'var(--color-white)'};">{menu.header}</p>
|
||||
{#if menu.hasOwnProperty('text')}
|
||||
<p class="text" style="color: {menuTextColorOverride.id === index ? menuTextColorOverride.color : 'var(--color-lightgrey)'};">{menu.text}</p>
|
||||
{/if}
|
||||
</div>
|
||||
{#if menu?.subMenu}
|
||||
<div class="chevron" style="color: {menuTextColorOverride.id === index ? menuTextColorOverride.color : 'var(--color-white)'};">
|
||||
<i class="fa-solid fa-chevron-right"></i>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:else if selectedMenuItem.hasOwnProperty('subMenu') && selectedMenuItem.subMenu}
|
||||
<div class="submenu-header-slot" on:click={() => handleMenuSelection(null)}>
|
||||
<i class="fa-solid fa-chevron-left left-chevron"></i>
|
||||
<p class="main-menu">Main Menu</p>
|
||||
</div>
|
||||
|
||||
<div class="screen-body">
|
||||
{#each subMenu as menu, index}
|
||||
<div id={"sub-menu-"+index} class="each-panel"
|
||||
on:mouseenter={() => handleItemHover("sub-menu-"+index, index, menu.color, 'enter', true)}
|
||||
on:mouseleave={() => handleItemHover("sub-menu-"+index, index, menu.color, 'leave', true)}
|
||||
on:click={() => handleSubMenuSelection(menu)}>
|
||||
<div id={"menu-icon-"+index} class="menu-icon">
|
||||
<Icon icon={menu.icon} styleColor={subMenuTextColorOverride.id === index ? subMenuTextColorOverride.color : menu.color || 'var(--color-green)'} />
|
||||
</div>
|
||||
<div class="menu-details">
|
||||
<p class="header" style="color: {subMenuTextColorOverride.id === index ? subMenuTextColorOverride.color : 'var(--color-white)'};">{menu.header}</p>
|
||||
{#if menu.hasOwnProperty('text')}
|
||||
<p class="text" style="color: {subMenuTextColorOverride.id === index ? subMenuTextColorOverride.color : 'var(--color-lightgrey)'};">{menu.text}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.menu-base-wrapper {
|
||||
/* centering the view */
|
||||
position: absolute;
|
||||
left: 70%;
|
||||
top: 40%;
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
width: 20vw;
|
||||
height: 30vw;
|
||||
/* min-height: 4vw;
|
||||
height: fit-content; */
|
||||
|
||||
overflow: hidden;
|
||||
/* border: 0.1px solid red; */
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base {
|
||||
height: 100%;
|
||||
/* border: 0.1px solid yellow; */
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .header-slot {
|
||||
background-color: var(--color-darkblue);
|
||||
border-radius: 0.3vw;
|
||||
|
||||
padding: 0.5vw 2vw;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
min-height: 3vw;
|
||||
height: fit-content;
|
||||
}
|
||||
.menu-base-wrapper > .screen-base > .header-slot > img {
|
||||
height: 4vw;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .submenu-header-slot {
|
||||
min-height: 4vw;
|
||||
height: max-content;
|
||||
|
||||
background-color: var(--color-darkblue);
|
||||
border-radius: 0.3vw;
|
||||
color: var(--color-white);
|
||||
|
||||
padding: 0.3vw 1vw;
|
||||
cursor: pointer;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.menu-base-wrapper > .screen-base > .submenu-header-slot > .left-chevron {
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
margin-right: 0.5vw;
|
||||
|
||||
width: 1.5vw;
|
||||
|
||||
font-size: 1.1vw;
|
||||
}
|
||||
.menu-base-wrapper > .screen-base > .submenu-header-slot > .main-menu {
|
||||
font-weight: 500;
|
||||
font-size: 1.25vw;
|
||||
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .screen-body {
|
||||
margin-top: 0.3vw;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
/* border: 0.1px solid blue; */
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .screen-body > .each-panel {
|
||||
min-height: 4vw;
|
||||
height: max-content;
|
||||
|
||||
background-color: var(--color-darkblue);
|
||||
border-radius: 0.3vw;
|
||||
|
||||
padding: 0.5vw 1vw;
|
||||
cursor: pointer;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.menu-base-wrapper > .screen-base > .screen-body > .each-panel:not(:last-child) {
|
||||
margin-bottom: 0.3vw;
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .screen-body > .each-panel > .menu-icon {
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
margin-right: 0.5vw;
|
||||
|
||||
width: 1.5vw;
|
||||
|
||||
font-size: 1vw;
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .screen-body > .each-panel > .menu-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .screen-body > .each-panel > .menu-details > .header {
|
||||
font-size: 0.8vw;
|
||||
white-space: nowrap;
|
||||
/* color: var(--color-white); */
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .screen-body > .each-panel > .menu-details > .text {
|
||||
font-size: 0.6vw;
|
||||
white-space: nowrap;
|
||||
/* color: var(--color-lightgrey); */
|
||||
}
|
||||
|
||||
.menu-base-wrapper > .screen-base > .screen-body > .each-panel > .chevron {
|
||||
margin-left: 72%;
|
||||
font-size: 1vw;
|
||||
/* color: var(--color-white); */
|
||||
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,27 @@
|
|||
<script lang="ts">
|
||||
import { notifications } from './../stores/NotificationStore';
|
||||
import { NotificationIcons, NotificationTypes } from './../enums/NotificationTypesEnum';
|
||||
</script>
|
||||
|
||||
<div class="flex justify-end min-h-screen">
|
||||
<div class="flex flex-col mr-4 mt-4 w-[200px]">
|
||||
{#each $notifications as notification}
|
||||
<div
|
||||
class="{notification.type} flex items-center px-4 py-3 mb-1 text-white min-w-full rounded"
|
||||
>
|
||||
<div class="text-2xl mt-1">
|
||||
{#if notification.type === NotificationTypes.Success}
|
||||
<i class={NotificationIcons.Success} />
|
||||
{:else if notification.type === NotificationTypes.Warning}
|
||||
<i class={NotificationIcons.Warning} />
|
||||
{:else if notification.type === NotificationTypes.Error}
|
||||
<i class={NotificationIcons.Error} />
|
||||
{:else if notification.type === NotificationTypes.Info}
|
||||
<i class={NotificationIcons.Info} />
|
||||
{/if}
|
||||
</div>
|
||||
<span class="ml-3">{notification.text}</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,195 @@
|
|||
<script lang="ts">
|
||||
import { hideStatusBar, hideStatusBarStore, statusBarStore } from "../stores/StatusBarStores";
|
||||
import { onMount } from "svelte";
|
||||
import Icon from "./Icon.svelte";
|
||||
import type { IStatusBarItem } from "src/interfaces/IStatusBar";
|
||||
import { isDevMode, showComponent, showUi } from "../stores/GeneralStores";
|
||||
|
||||
let statusData:any = $statusBarStore;
|
||||
let statusDataItems:[IStatusBarItem] = statusData.items;
|
||||
|
||||
statusBarStore.subscribe((value) => {
|
||||
statusData = value;
|
||||
statusDataItems = statusData.items;
|
||||
});
|
||||
|
||||
let hideStatusBarValue = false;
|
||||
hideStatusBarStore.subscribe(value => {
|
||||
hideStatusBarValue = value;
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
if(isDevMode) {
|
||||
setTimeout(() => {
|
||||
hideStatusBar();
|
||||
}, 10000);
|
||||
}
|
||||
});
|
||||
|
||||
function closeStatusBar() {
|
||||
const statusWrapperDom = document.getElementById('status-bar-wrapper');
|
||||
if(statusWrapperDom) {
|
||||
statusWrapperDom.style.animation = '2s hide-statusbar';
|
||||
|
||||
let keyFrames = document.createElement('style');
|
||||
|
||||
keyFrames.innerHTML = `
|
||||
@keyframes hide-statusbar {
|
||||
from {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.status-bar-wrapper {
|
||||
-moz-animation: 2s hide-statusbar;
|
||||
-webkit-animation: 2s hide-statusbar;
|
||||
animation: 2s hide-statusbar;
|
||||
}
|
||||
`;
|
||||
|
||||
statusWrapperDom.appendChild(keyFrames);
|
||||
|
||||
setTimeout(() => {
|
||||
showUi.set(false);
|
||||
showComponent.set(null);
|
||||
|
||||
statusBarStore.set({
|
||||
title: '',
|
||||
description: '',
|
||||
items: [],
|
||||
icon: '',
|
||||
});
|
||||
hideStatusBarStore.set(false);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
if(hideStatusBarValue) {
|
||||
// if(hideStatusBarValue || !hideStatusBarValue)
|
||||
closeStatusBar();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="status-bar-wrapper" class="status-bar-wrapper">
|
||||
<div class="status-title-wrapper">
|
||||
<div class="icon">
|
||||
<Icon icon={statusData.icon} color="ps-text-green" />
|
||||
</div>
|
||||
|
||||
<div class="title-info">
|
||||
<p class="title">
|
||||
{statusData.title}
|
||||
</p>
|
||||
<p class="title-description">
|
||||
{statusData.description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="items-wrapper">
|
||||
{#each statusDataItems as item}
|
||||
<div class="each-item">
|
||||
<p class="label">
|
||||
{item.key}:
|
||||
</p>
|
||||
<p class="value">
|
||||
{item.value}
|
||||
</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.status-bar-wrapper {
|
||||
-moz-animation: 2s display-status;
|
||||
-webkit-animation: 2s display-status;
|
||||
animation: 2s display-status;
|
||||
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 1%;
|
||||
transform: translateX(-50%);
|
||||
|
||||
width: 23vw;
|
||||
min-height: 8vw;
|
||||
height: fit-content;
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
background-color: var(--color-darkblue);
|
||||
border-radius: 0.3vw;
|
||||
|
||||
padding: 1vw 2vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@keyframes display-status {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.status-bar-wrapper > .status-title-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.status-bar-wrapper > .status-title-wrapper > .icon {
|
||||
width: 1.5vw;
|
||||
margin-right: 0.5vw;
|
||||
|
||||
font-size: 1.25vw;
|
||||
}
|
||||
.status-bar-wrapper > .status-title-wrapper > .title-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
text-transform: capitalize;
|
||||
}
|
||||
.status-bar-wrapper > .status-title-wrapper > .title-info > .title {
|
||||
font-size: 1.3vw;
|
||||
font-weight: 500;
|
||||
color: var(--color-white);
|
||||
}
|
||||
.status-bar-wrapper > .status-title-wrapper > .title-info > .title-description {
|
||||
font-size: 0.95vw;
|
||||
font-weight: 200;
|
||||
color: var(--color-lightgrey);
|
||||
|
||||
margin-top: -0.2vw;
|
||||
}
|
||||
|
||||
.status-bar-wrapper > .items-wrapper {
|
||||
margin-left: 2vw;
|
||||
margin-top: 0.5vw;
|
||||
}
|
||||
.status-bar-wrapper > .items-wrapper > .each-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
word-wrap: break-word;
|
||||
flex-wrap: wrap;
|
||||
|
||||
font-size: 0.95vw;
|
||||
}
|
||||
.status-bar-wrapper > .items-wrapper > .each-item:not(:last-child) {
|
||||
margin-bottom: 0.3vw;
|
||||
}
|
||||
|
||||
.status-bar-wrapper > .items-wrapper > .each-item > .label {
|
||||
color: var(--color-lightgrey);
|
||||
}
|
||||
.status-bar-wrapper > .items-wrapper > .each-item > .value {
|
||||
color: var(--color-green);
|
||||
margin-left: 0.3vw;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,4 @@
|
|||
export enum ConnectingGameMessageEnum {
|
||||
Connecting = 'CONNECTING TO INTERFACE',
|
||||
Connected = 'CONNECTED. GET READY.',
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
export enum GamesEnum {
|
||||
Scrambler = 'Scramber',
|
||||
NumberMaze = 'NumberMaze',
|
||||
Memory = 'MemoryGame',
|
||||
NumberPuzzle = 'NumberPuzzle',
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
export enum NotificationTypes {
|
||||
Success = 'ps-notification-success',
|
||||
Error = 'ps-notification-error',
|
||||
Warning = 'ps-notification-warning',
|
||||
Info = 'ps-notification-info',
|
||||
}
|
||||
|
||||
export enum NotificationIcons {
|
||||
Success = 'fa-solid fa-circle-check',
|
||||
Error = 'fa-solid fa-circle-exclamation',
|
||||
Warning = 'fa-solid fa-triangle-exclamation',
|
||||
Info = 'fa-solid fa-circle-info',
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
export enum UIComponentsEnum {
|
||||
StatusBar = 'StatusBar',
|
||||
Menu = 'Menu',
|
||||
Input = 'Input',
|
||||
Game = 'Game',
|
||||
MemoryGame = 'MemoryGame',
|
||||
Image = 'ShowImage',
|
||||
DrawText = 'DrawText',
|
||||
Notification = 'Notify',
|
||||
None = 'hideUi',
|
||||
}
|
139
resources/[freizeit]/[gym]/ps-ui/web/src/games/CircleGame.svelte
Normal file
|
@ -0,0 +1,139 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
let canvas;
|
||||
let ctx;
|
||||
let W, H, degrees = 0, new_degrees = 0, color = "#38D5AF";
|
||||
let txtcolor = "#ffffff", bgcolor = "#2B312B", bgcolor2 = "#068f6d", bgcolor3 = "#00ff00";
|
||||
let key_to_press, g_start, g_end, animation_loop;
|
||||
let needed = 4, streak = 0, circle_started = false, time = 2;
|
||||
|
||||
function getRandomInt(min, max) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
|
||||
function StartCircle() {
|
||||
ctx.clearRect(0, 0, W, H);
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = bgcolor;
|
||||
ctx.lineWidth = 20;
|
||||
ctx.arc(W / 2, H / 2, Math.min(W, H) / 2 - 10, 0, Math.PI * 2, false);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = correct === true ? bgcolor3 : bgcolor2;
|
||||
ctx.lineWidth = 20;
|
||||
ctx.arc(W / 2, H / 2, Math.min(W, H) / 2 - 10, g_start - 90 * Math.PI / 180, g_end - 90 * Math.PI / 180, false);
|
||||
ctx.stroke();
|
||||
let radians = degrees * Math.PI / 180;
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = color;
|
||||
ctx.lineWidth = 40;
|
||||
ctx.arc(W / 2, H / 2, Math.min(W, H) / 2 - 20, radians - 0.1 - 90 * Math.PI / 180, radians - 90 * Math.PI / 180, false);
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = txtcolor;
|
||||
ctx.font = "100px sans-serif";
|
||||
let text_width = ctx.measureText(key_to_press).width;
|
||||
ctx.fillText(key_to_press, W / 2 - text_width / 2, H / 2 + 35);
|
||||
}
|
||||
|
||||
function draw() {
|
||||
if (typeof animation_loop !== undefined) clearInterval(animation_loop);
|
||||
g_start = getRandomInt(20, 40) / 10;
|
||||
g_end = getRandomInt(5, 10) / 10;
|
||||
g_end = g_start + g_end;
|
||||
degrees = 0;
|
||||
new_degrees = 360;
|
||||
key_to_press = '' + getRandomInt(1, 4);
|
||||
animation_loop = setInterval(animate_to, time);
|
||||
}
|
||||
|
||||
function animate_to() {
|
||||
if (degrees >= new_degrees) {
|
||||
CircleFail();
|
||||
return;
|
||||
}
|
||||
degrees += 2;
|
||||
StartCircle();
|
||||
}
|
||||
|
||||
function correct() {
|
||||
streak += 1;
|
||||
if (streak == needed) {
|
||||
clearInterval(animation_loop);
|
||||
endGame(true);
|
||||
} else {
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
function CircleFail() {
|
||||
clearInterval(animation_loop);
|
||||
endGame(false);
|
||||
}
|
||||
|
||||
function startGame() {
|
||||
document.getElementById('circle').style.display = 'block';
|
||||
document.getElementById('circle').style.pointerEvents = 'auto';
|
||||
circle_started = true;
|
||||
draw();
|
||||
}
|
||||
|
||||
function endGame(status) {
|
||||
document.getElementById('circle').style.display = 'none';
|
||||
circle_started = false;
|
||||
let endResult = status ? true : false;
|
||||
fetch(`https://ps-ui/circle-result`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({endResult})
|
||||
});
|
||||
streak = 0;
|
||||
needed = 4;
|
||||
}
|
||||
|
||||
export function setupCircleGame(data: { circles?: number; time?: number }) {
|
||||
needed = data.circles ?? 4;
|
||||
time = data.time ?? 2;
|
||||
startGame();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
canvas = document.getElementById("circle");
|
||||
ctx = canvas.getContext("2d");
|
||||
W = window.innerWidth * 0.2;
|
||||
H = window.innerHeight * 0.2;
|
||||
canvas.width = W;
|
||||
canvas.height = H;
|
||||
|
||||
window.addEventListener("message", (event) => {
|
||||
if (event.data.action == "circle-start") {
|
||||
needed = event.data.circles ?? 4;
|
||||
time = event.data.time ?? 2;
|
||||
startGame();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function (ev) {
|
||||
let key_pressed = ev.key;
|
||||
let valid_keys = ['1', '2', '3', '4'];
|
||||
if (valid_keys.includes(key_pressed) && circle_started) {
|
||||
if (key_pressed === key_to_press) {
|
||||
let d_start = (180 / Math.PI) * g_start;
|
||||
let d_end = (180 / Math.PI) * g_end;
|
||||
if (degrees < d_start || degrees > d_end) {
|
||||
CircleFail();
|
||||
} else {
|
||||
correct();
|
||||
}
|
||||
} else {
|
||||
CircleFail();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="absolute inset-0 flex items-center justify-center" style="pointer-events: none; z-index: 100;">
|
||||
<canvas id="circle" class="w-auto h-auto" style="display: none;"></canvas>
|
||||
</div>
|
104
resources/[freizeit]/[gym]/ps-ui/web/src/games/GameBase.svelte
Normal file
|
@ -0,0 +1,104 @@
|
|||
<script lang="ts">
|
||||
import { currentActiveGameDetails, currentGameActive } from "../stores/GameLauncherStore";
|
||||
import Skull from "../assets/svgs/Skull.svelte";
|
||||
import { GamesEnum } from "../enums/GamesEnum";
|
||||
import NewMemoryGame from "./MemoryGame.svelte";
|
||||
import SuccessFailureScreen from "./SuccessFailureScreen.svelte";
|
||||
import NewScrambler from "./Scrambler.svelte";
|
||||
import NewNumberMaze from "./NumberMaze.svelte";
|
||||
import NewNumberPuzzle from "./NumberPuzzle.svelte";
|
||||
|
||||
const skullColor: string = 'var(--color-green)';
|
||||
|
||||
let showResultScreen = false, hackSuccess = false;
|
||||
</script>
|
||||
|
||||
{#if !showResultScreen}
|
||||
<div class="games-container">
|
||||
<div class="game-wrapper ps-bg-darkblue">
|
||||
<div class="skull-logo">
|
||||
<Skull color={skullColor} />
|
||||
</div>
|
||||
|
||||
<div class="game-heading">
|
||||
<p class="ps-font-arcade">
|
||||
{$currentActiveGameDetails?.gameName}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="game-description">
|
||||
<p>{$currentActiveGameDetails?.gameDescription}</p>
|
||||
</div>
|
||||
|
||||
<div class="main-game-body">
|
||||
{#if $currentGameActive === GamesEnum.Memory}
|
||||
<NewMemoryGame on:game-ended={(event) => {showResultScreen = true; hackSuccess = event.detail.hackSuccess; }} />
|
||||
{:else if $currentGameActive === GamesEnum.Scrambler}
|
||||
<NewScrambler on:game-ended={(event) => {showResultScreen = true; hackSuccess = event.detail.hackSuccess; }} />
|
||||
{:else if $currentGameActive === GamesEnum.NumberMaze}
|
||||
<NewNumberMaze on:game-ended={(event) => {showResultScreen = true; hackSuccess = event.detail.hackSuccess; }} />
|
||||
{:else if $currentGameActive === GamesEnum.NumberPuzzle}
|
||||
<NewNumberPuzzle on:game-ended={(event) => {showResultScreen = true; hackSuccess = event.detail.hackSuccess; }} />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<SuccessFailureScreen isSuccess={hackSuccess} />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.games-container {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
border-radius: 0.2vw;
|
||||
}
|
||||
|
||||
.games-container > .game-wrapper {
|
||||
width: 33vw;
|
||||
height: 45vw;
|
||||
border-radius: 0.3vw;
|
||||
overflow: hidden;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.games-container > .game-wrapper > .skull-logo {
|
||||
margin: 0 auto;
|
||||
padding-top: 1vw;
|
||||
width: 5vw;
|
||||
}
|
||||
|
||||
.games-container > .game-wrapper > .game-heading {
|
||||
font-size: 1.1vw;
|
||||
letter-spacing: 0.4vw;
|
||||
color: var(--color-lightgrey);
|
||||
|
||||
margin: 0.25vw auto;
|
||||
|
||||
width: 19vw;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.games-container > .game-wrapper > .game-description {
|
||||
font-size: 0.7vw;
|
||||
font-weight: normal;
|
||||
color: var(--color-lightgrey);
|
||||
text-align: center;
|
||||
|
||||
width: 33vw;
|
||||
margin: 1vw auto;
|
||||
}
|
||||
|
||||
.games-container > .game-wrapper > .main-game-body {
|
||||
margin: 0.75vw auto 2vw auto;
|
||||
width: 31vw;
|
||||
/* border: 0.1px solid yellow; */
|
||||
height: 30vw;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,79 @@
|
|||
<script lang="ts">
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import Skull from '../assets/svgs/Skull.svelte';
|
||||
('./../../utils/mockEvent');
|
||||
import { connectionText, showLoading } from '../stores/GameLauncherStore';
|
||||
import { ConnectingGameMessageEnum } from '../enums/GameConnectionMessages';
|
||||
import GameBase from './GameBase.svelte';
|
||||
|
||||
const skullColor: string = '#02f1b5';
|
||||
|
||||
let loadingBar: HTMLDivElement;
|
||||
let gameLoaded = false;
|
||||
|
||||
/** Asynchronously connects to a game and resolves the Promise when completed.
|
||||
* Uses a loading bar to show progress, incrementing by 1% every 30ms until it reaches 100%.
|
||||
*
|
||||
* @returns Promise that resolves when the loading bar reaches 100%.
|
||||
*/
|
||||
async function connectToGame(): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
let width = 0;
|
||||
let interval = setInterval(() => {
|
||||
width++;
|
||||
loadingBar.style.width = `${width}%`;
|
||||
|
||||
if (width === 100) {
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
}
|
||||
}, 30);
|
||||
});
|
||||
}
|
||||
|
||||
// Call init() on mount
|
||||
onMount(async () => {
|
||||
// Show a loading indicator while connecting to the game server
|
||||
connectionText.set(ConnectingGameMessageEnum.Connecting);
|
||||
showLoading.set(true);
|
||||
|
||||
// Connect to the game server
|
||||
await connectToGame();
|
||||
|
||||
// Hide loading indicator when completed connecting to the game server
|
||||
connectionText.set(ConnectingGameMessageEnum.Connected);
|
||||
setTimeout(() => {
|
||||
showLoading.set(false);
|
||||
gameLoaded = true;
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
onDestroy(async () => {
|
||||
gameLoaded = false
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if $showLoading}
|
||||
<div class="flex min-h-screen justify-center items-center">
|
||||
<div
|
||||
class="flex flex-col h-[400px] w-[700px] ps-bg-darkblue shadow-md shadow-black justify-center items-center"
|
||||
>
|
||||
<span class="w-40"><Skull color={skullColor} /></span>
|
||||
<p class="text-white text-3xl mt-2">{$connectionText}</p>
|
||||
|
||||
<!-- Loading wrapper -->
|
||||
<div class="flex mt-10 ps-border-green border-4 w-[80%] h-10">
|
||||
<!-- Loading bar progress -->
|
||||
<div
|
||||
bind:this={loadingBar}
|
||||
class="ps-bg-green opacity-40 will-change-auto w-0"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !$showLoading && gameLoaded}
|
||||
<GameBase />
|
||||
{/if}
|
269
resources/[freizeit]/[gym]/ps-ui/web/src/games/MemoryGame.svelte
Normal file
|
@ -0,0 +1,269 @@
|
|||
<script lang="ts">
|
||||
import { closeGame, currentActiveGameDetails, gameSettings } from "../stores/GameLauncherStore";
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import fetchNui from "../../utils/fetch";
|
||||
import { isDevMode } from "../stores/GeneralStores";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let gridSizesAcceptable = [
|
||||
{
|
||||
numberOfRowCol: 5,
|
||||
cubeSize: '4.2vw',
|
||||
gap: '1vw'
|
||||
},
|
||||
{
|
||||
numberOfRowCol: 6,
|
||||
cubeSize: '3.7vw',
|
||||
gap: '0.8vw'
|
||||
},
|
||||
{
|
||||
numberOfRowCol: 7,
|
||||
cubeSize: '2.9vw',
|
||||
gap: '1vw'
|
||||
},
|
||||
{
|
||||
numberOfRowCol: 8,
|
||||
cubeSize: '2.6vw',
|
||||
gap: '0.9vw'
|
||||
},
|
||||
{
|
||||
numberOfRowCol: 9,
|
||||
cubeSize: '2.4vw',
|
||||
gap: '0.75vw'
|
||||
},
|
||||
{
|
||||
numberOfRowCol: 10,
|
||||
cubeSize: '2.1vw',
|
||||
gap: '0.75vw'
|
||||
},
|
||||
];
|
||||
|
||||
let gameTimeRemaining = 0;
|
||||
|
||||
let numberOfCorrectCubesToDisplay = $gameSettings.amountOfAnswers; // how many cubes to remember for game - increment number based on difficulty level
|
||||
let gameTime = $gameSettings.gameTime * 100;
|
||||
let numberOfWrongClicksAllowed = $gameSettings.maxAnswersIncorrect;
|
||||
|
||||
let correctIndices = [], displayCorrectIndicesFor = $currentActiveGameDetails.displayInitialAnswersFor * 1000; // time in seconds
|
||||
let counter, gameStarted = false, gameEnded = false;
|
||||
let hackSuccess = false;
|
||||
let numberOfCubes = $currentActiveGameDetails.gridSize * $currentActiveGameDetails.gridSize;
|
||||
let allCubes = [];
|
||||
|
||||
onMount(() => {
|
||||
//generate random indices from number of cubes
|
||||
while(correctIndices.length < numberOfCorrectCubesToDisplay){
|
||||
const r = Math.floor(Math.random() * numberOfCubes);
|
||||
if(correctIndices.indexOf(r) === -1) correctIndices.push(r);
|
||||
}
|
||||
|
||||
//generating an array to maintain each cube data by index
|
||||
for(let i = 0; i < numberOfCubes; i++) {
|
||||
const cubeData = {
|
||||
cubeIndex: i,
|
||||
isCorrectAnswer: correctIndices.includes(i),
|
||||
isClicked: false
|
||||
};
|
||||
allCubes.push(cubeData);
|
||||
allCubes = allCubes;
|
||||
}
|
||||
|
||||
let cubeWidthHeightValue = gridSizesAcceptable.filter((accept) => {
|
||||
return accept.numberOfRowCol === $currentActiveGameDetails.gridSize;
|
||||
})[0];
|
||||
|
||||
setTimeout(() => {
|
||||
//assigning cube width and height
|
||||
allCubes.forEach((cube) => {
|
||||
const gameContainer = document.getElementById('memory-game-container');
|
||||
if(gameContainer) {
|
||||
gameContainer.style.gap = cubeWidthHeightValue.gap;
|
||||
}
|
||||
|
||||
const cubeDom = document.getElementById('each-cube-'+cube.cubeIndex);
|
||||
if(cubeDom) {
|
||||
cubeDom.style.width = cubeWidthHeightValue.cubeSize;
|
||||
cubeDom.style.height = cubeWidthHeightValue.cubeSize;
|
||||
cubeDom.style.border = "2px solid var(--color-green)";
|
||||
}
|
||||
});
|
||||
}, 1500);
|
||||
|
||||
//stop showing the correct cubes and start the guessing game
|
||||
setTimeout(() => {
|
||||
gameStarted = true;
|
||||
counter = setInterval(startTimer, 10);
|
||||
}, displayCorrectIndicesFor + 1500);
|
||||
|
||||
});
|
||||
|
||||
function startTimer() {
|
||||
if (gameTime <= 0)
|
||||
{
|
||||
gameEnded = true;
|
||||
hackSuccess = isSuccessful();
|
||||
clearInterval(counter);
|
||||
return;
|
||||
}
|
||||
gameTime--;
|
||||
gameTimeRemaining = gameTime/100;
|
||||
}
|
||||
|
||||
function isSuccessful() {
|
||||
//all correct cubes clicked and wrong clicks are within threshold then success
|
||||
|
||||
//all correct cubes clicked
|
||||
let allCorrectCubesClicked = false;
|
||||
allCubes.map((item) => {
|
||||
if(item.isCorrectAnswer && item.isClicked) {
|
||||
allCorrectCubesClicked = true;
|
||||
}
|
||||
if(item.isCorrectAnswer && !item.isClicked) {
|
||||
allCorrectCubesClicked = false;
|
||||
}
|
||||
});
|
||||
|
||||
//wrong clicks within threshold
|
||||
const wrongClickedCubes = getWrongClicks();
|
||||
const wrongClicksWithinThreshold = wrongClickedCubes.length < numberOfWrongClicksAllowed;
|
||||
|
||||
return allCorrectCubesClicked && wrongClicksWithinThreshold;
|
||||
}
|
||||
|
||||
function getWrongClicks() {
|
||||
return allCubes.filter((item) => {
|
||||
return item.isClicked && !item.isCorrectAnswer;
|
||||
});
|
||||
}
|
||||
|
||||
function guessAnswer(guessedCube) {
|
||||
if(!gameEnded) {
|
||||
const cubeIndexInArray = allCubes.findIndex((item) => item.cubeIndex === guessedCube.cubeIndex);
|
||||
|
||||
let updatedCube = guessedCube;
|
||||
updatedCube.isClicked = true;
|
||||
|
||||
allCubes[cubeIndexInArray] = updatedCube;
|
||||
|
||||
const wrongClickedCubes = getWrongClicks();
|
||||
|
||||
// if wrong clicks are done, end the game
|
||||
if(wrongClickedCubes.length >= numberOfWrongClicksAllowed) {
|
||||
clearInterval(counter);
|
||||
setTimeout(() => {
|
||||
hackSuccess = false;
|
||||
gameTimeRemaining = 0;
|
||||
gameEnded = true;
|
||||
return;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
hackSuccess = isSuccessful();
|
||||
|
||||
if(hackSuccess) {
|
||||
clearInterval(counter);
|
||||
gameTimeRemaining = 0;
|
||||
gameEnded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
if(gameEnded) {
|
||||
if(!isDevMode) {
|
||||
fetchNui('minigame:callback', hackSuccess);
|
||||
dispatch('game-ended', { hackSuccess });
|
||||
}
|
||||
|
||||
dispatch('closeUI', {hackSuccess})
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyEvent(event) {
|
||||
let key_pressed = event.key;
|
||||
let valid_keys = ['Escape'];
|
||||
|
||||
if(gameStarted && valid_keys.includes(key_pressed) && !gameEnded) {
|
||||
switch(key_pressed){
|
||||
case 'Escape':
|
||||
closeGame(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown|preventDefault={handleKeyEvent} />
|
||||
<div class="memory-game-base">
|
||||
<div class="time-left">
|
||||
<i class="fa-solid fa-clock ps-text-lightgrey clock-icon"></i>
|
||||
<p class="{gameTimeRemaining !== 0 ? 'game-timer-var' : 'mr-1'}">{gameTimeRemaining} </p> time remaining
|
||||
</div>
|
||||
|
||||
<div id="memory-game-container" class="memory-game-container" style="gap: 13px;">
|
||||
{#each allCubes as cube}
|
||||
<div
|
||||
id={'each-cube-'+cube.cubeIndex}
|
||||
on:click={() => guessAnswer(cube)}
|
||||
style="width: 0px; height: 0px; border: 0px;"
|
||||
class="each-cube {gameStarted ? 'cursor-pointer' : 'cursor-default'} {!gameStarted ? (cube.isCorrectAnswer ? 'ps-bg-green-cube' : '') : (cube.isClicked && cube.isCorrectAnswer ? 'ps-bg-green-cube' : (cube.isClicked && !cube.isCorrectAnswer ? 'ps-bg-wrong-cube' : ''))}">
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.memory-game-base {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
height: 30vw;
|
||||
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: var(--color-lightgrey);
|
||||
}
|
||||
|
||||
.memory-game-base > .time-left {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
font-size: 0.85vw;
|
||||
}
|
||||
.memory-game-base > .time-left > .clock-icon {
|
||||
padding-top: 0.17vw;
|
||||
margin-right: 0.3vw;
|
||||
}
|
||||
.memory-game-base > .time-left > .game-timer-var {
|
||||
width: 2.5vw;
|
||||
}
|
||||
|
||||
.memory-game-base > .memory-game-container {
|
||||
/* border: 0.1px solid red; */
|
||||
|
||||
margin-top: 1vw;
|
||||
width: 30vw;
|
||||
height: 29vw;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
/* gap: 1.5vw; */
|
||||
}
|
||||
.memory-game-base > .memory-game-container > .each-cube {
|
||||
/* width: 4.5vw;
|
||||
height: 4.5vw; */
|
||||
|
||||
background-color: var(--cube-bg-darkgreen);
|
||||
border: 2px solid var(--color-green);
|
||||
}
|
||||
|
||||
.ps-bg-green-cube {
|
||||
background-color: var(--color-green) !important;
|
||||
}
|
||||
.ps-bg-wrong-cube {
|
||||
background-color: var(--color-red) !important;
|
||||
}
|
||||
</style>
|
331
resources/[freizeit]/[gym]/ps-ui/web/src/games/NumberMaze.svelte
Normal file
|
@ -0,0 +1,331 @@
|
|||
<script lang="ts">
|
||||
import { closeGame, gameSettings } from "../stores/GameLauncherStore";
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import fetchNui from "../../utils/fetch";
|
||||
import { getRandomArbitrary, isDevMode } from "../stores/GeneralStores";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let gameTimeRemaining = 0;
|
||||
|
||||
let gameTime = $gameSettings.gameTime * 100;
|
||||
let numberOfWrongClicksAllowed = $gameSettings.maxAnswersIncorrect;
|
||||
|
||||
let counter, gameStarted = false, gameEnded = false;
|
||||
let numberOfCubes = 49, allCubes = [];
|
||||
let blinkingIndex, correctRoute = [], goodPositions = [], stopBlinking = false;
|
||||
let lastPos = 0, wrongAnswerCount = 0;
|
||||
let displayCubeNumbers = false;
|
||||
|
||||
onMount(() => {
|
||||
//get starting blinking index
|
||||
blinkingIndex = getRandomArbitrary(1,4); // 4 => highest index, => lowest index for blink
|
||||
|
||||
//generate the correct route
|
||||
correctRoute = generateBestRoute(blinkingIndex);
|
||||
|
||||
goodPositions = Object.keys(correctRoute);
|
||||
|
||||
//generating an array to maintain each cube data by index
|
||||
for(let i = 0; i < numberOfCubes; i++) {
|
||||
const cubeValue = [blinkingIndex, blinkingIndex * 7].includes(i) ? getRandomArbitrary(1,4) : getRandomArbitrary(1,5);
|
||||
|
||||
const cubeData = {
|
||||
cubeIndex: i,
|
||||
cubeValue: goodPositions.includes(i.toLocaleString()) ? correctRoute[i] : cubeValue,
|
||||
classList: ''
|
||||
};
|
||||
allCubes.push(cubeData);
|
||||
allCubes = allCubes;
|
||||
}
|
||||
|
||||
//stop showing the correct cubes and start the guessing game
|
||||
setTimeout(() => {
|
||||
gameStarted = true;
|
||||
counter = setInterval(startTimer, 10);
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
|
||||
function maxVertical(pos) {
|
||||
return Math.floor((48-pos)/7);
|
||||
}
|
||||
|
||||
function maxHorizontal(pos) {
|
||||
let max = (pos+1) % 7;
|
||||
if(max > 0) return 7-max;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
function generateNextPosition(pos) {
|
||||
let maxV = maxVertical(pos);
|
||||
let maxH = maxHorizontal(pos);
|
||||
if(maxV === 0 ){
|
||||
let new_pos = getRandomArbitrary(getRandomArbitrary(1,maxH), maxH);
|
||||
return [new_pos, pos+new_pos];
|
||||
}
|
||||
if(maxH === 0 ){
|
||||
let new_pos = getRandomArbitrary(getRandomArbitrary(1,maxV), maxV);
|
||||
return [new_pos, pos+(new_pos*7)];
|
||||
}
|
||||
if(Math.floor(Math.random() * 1000 + 1) % 2 === 0 ){
|
||||
let new_pos = getRandomArbitrary(getRandomArbitrary(1,maxH), maxH);
|
||||
return [new_pos, pos+new_pos];
|
||||
} else {
|
||||
let new_pos = getRandomArbitrary(getRandomArbitrary(1,maxV), maxV);
|
||||
return [new_pos, pos+(new_pos*7)];
|
||||
}
|
||||
}
|
||||
|
||||
function generateBestRoute(start_pos) {
|
||||
let route = [];
|
||||
if(getRandomArbitrary(1,1000) % 2 === 0 ){
|
||||
start_pos *= 7;
|
||||
}
|
||||
while(start_pos < 48){
|
||||
let new_pos = generateNextPosition(start_pos);
|
||||
route[start_pos] = new_pos[0];
|
||||
start_pos = new_pos[1];
|
||||
}
|
||||
|
||||
return route;
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
if (gameTime <= 0)
|
||||
{
|
||||
wrongAnswerCount = numberOfWrongClicksAllowed;
|
||||
checkMazeAnswer();
|
||||
return;
|
||||
}
|
||||
gameTime--;
|
||||
gameTimeRemaining = gameTime/100;
|
||||
}
|
||||
|
||||
function updateAllCubesArrayWithClassListOfClickedCube(isGood, clickedCube) {
|
||||
const additionClassString = isGood ? ' ps-bg-green-cube' : ' ps-bg-wrong-cube';
|
||||
const newClassList = clickedCube.classList + additionClassString;
|
||||
clickedCube.classList = newClassList;
|
||||
|
||||
//replace the clicked cube data in allCubes array
|
||||
allCubes[clickedCube.cubeIndex] = clickedCube;
|
||||
allCubes = allCubes;
|
||||
}
|
||||
|
||||
|
||||
function handleCubeClick(clickedCube) {
|
||||
if(!gameEnded && clickedCube.cubeIndex !== 0) {
|
||||
let posClicked = clickedCube.cubeIndex;
|
||||
//game just started and user made first click
|
||||
if(lastPos === 0) {
|
||||
//stop the blinking and hide numbers on cubes
|
||||
stopBlinking = true;
|
||||
if([blinkingIndex, blinkingIndex * 7].includes(posClicked)) {
|
||||
lastPos = posClicked;
|
||||
|
||||
//display good cube click and update allCubes array
|
||||
updateAllCubesArrayWithClassListOfClickedCube(true, clickedCube);
|
||||
} else {
|
||||
wrongAnswerCount++;
|
||||
//display bad cube click and update allCubes array
|
||||
updateAllCubesArrayWithClassListOfClickedCube(false, clickedCube);
|
||||
}
|
||||
} else {
|
||||
let posJumps = allCubes[lastPos].cubeValue;
|
||||
let maxV = maxVertical(lastPos);
|
||||
let maxH = maxHorizontal(lastPos);
|
||||
|
||||
if(posJumps <= maxH && posClicked === lastPos + posJumps) {
|
||||
lastPos = posClicked;
|
||||
//display good cube click and update allCubes array
|
||||
updateAllCubesArrayWithClassListOfClickedCube(true, clickedCube);
|
||||
} else if (posJumps <= maxV && posClicked === lastPos + (posJumps * 7)) {
|
||||
lastPos = posClicked;
|
||||
//display good cube click and update allCubes array
|
||||
updateAllCubesArrayWithClassListOfClickedCube(true, clickedCube);
|
||||
} else {
|
||||
wrongAnswerCount++;
|
||||
//display bad cube click and update allCubes array
|
||||
updateAllCubesArrayWithClassListOfClickedCube(false, clickedCube);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkMazeAnswer();
|
||||
}
|
||||
|
||||
function checkMazeAnswer() {
|
||||
// check if wrong answers exceeded / game ended - both with same condition
|
||||
// if yes, end the game, clear counter and display correct answers and then stop game
|
||||
// else, end the game within few seconds
|
||||
if(wrongAnswerCount === numberOfWrongClicksAllowed) {
|
||||
clearInterval(counter);
|
||||
|
||||
displayCubeNumbers = true;
|
||||
|
||||
allCubes = allCubes.map((cube) => {
|
||||
cube.classList = goodPositions.includes(cube.cubeIndex.toLocaleString()) ? 'ps-bg-green-cube' : '';
|
||||
return cube;
|
||||
});
|
||||
allCubes = allCubes;
|
||||
|
||||
setTimeout(() => {
|
||||
gameEnded = true;
|
||||
if(!isDevMode) {
|
||||
fetchNui('minigame:callback', false);
|
||||
dispatch('game-ended', { hackSuccess: false });
|
||||
}
|
||||
dispatch('closeUI', {hackSuccess: false});
|
||||
}, 3000);
|
||||
|
||||
return;
|
||||
} else if(lastPos === 48){
|
||||
clearInterval(counter);
|
||||
|
||||
displayCubeNumbers = true;
|
||||
|
||||
setTimeout(() => {
|
||||
gameEnded = true;
|
||||
if(!isDevMode) {
|
||||
fetchNui('minigame:callback', true);
|
||||
dispatch('game-ended', { hackSuccess: true });
|
||||
}
|
||||
dispatch('closeUI', {hackSuccess: true});
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyEvent(event) {
|
||||
let key_pressed = event.key;
|
||||
let valid_keys = ['Escape'];
|
||||
|
||||
if(gameStarted && valid_keys.includes(key_pressed) && !gameEnded) {
|
||||
switch(key_pressed){
|
||||
case 'Escape':
|
||||
closeGame(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown|preventDefault={handleKeyEvent} />
|
||||
<div class="maze-game-base">
|
||||
<div class="time-left">
|
||||
<i class="fa-solid fa-clock ps-text-lightgrey clock-icon"></i>
|
||||
<p class="{gameTimeRemaining !== 0 ? 'game-timer-var' : 'mr-1'}">{gameTimeRemaining} </p> time remaining
|
||||
</div>
|
||||
<div id="maze-game-container" class="maze-game-container">
|
||||
{#each allCubes as cube}
|
||||
<div
|
||||
id={'each-cube-'+cube.cubeIndex} on:click={() => handleCubeClick(cube)}
|
||||
class="each-cube {cube.classList}
|
||||
{[0, numberOfCubes - 1].includes(cube.cubeIndex) ? 'start-dest-cube' : ''}
|
||||
{!stopBlinking && [blinkingIndex, blinkingIndex * 7].includes(cube.cubeIndex) ? 'blinking-cube' : ''}
|
||||
"
|
||||
>
|
||||
{#if cube.cubeIndex === 0}
|
||||
<i class="fa-solid fa-ethernet"></i>
|
||||
{:else if cube.cubeIndex === numberOfCubes - 1}
|
||||
<i class="fa-solid fa-network-wired"></i>
|
||||
{:else}
|
||||
{#if !stopBlinking || displayCubeNumbers}
|
||||
<p>{ cube.cubeValue }</p>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.maze-game-base {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
height: 28vw;
|
||||
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: var(--color-lightgrey);
|
||||
}
|
||||
|
||||
.maze-game-base > .time-left {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
font-size: 0.85vw;
|
||||
}
|
||||
.maze-game-base > .time-left > .clock-icon {
|
||||
padding-top: 0.17vw;
|
||||
margin-right: 0.3vw;
|
||||
}
|
||||
.maze-game-base > .time-left > .game-timer-var {
|
||||
width: 2.5vw;
|
||||
}
|
||||
|
||||
.maze-game-base > .maze-game-container {
|
||||
/* border: 0.1px solid red; */
|
||||
|
||||
margin-top: 0.5vw;
|
||||
width: 30vw;
|
||||
height: 29vw;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.9vw;
|
||||
}
|
||||
.maze-game-base > .maze-game-container > .start-dest-cube {
|
||||
background-color: var(--color-green) !important;
|
||||
color: var(--color-darkblue);
|
||||
|
||||
font-size: 1.65vw;
|
||||
text-align: center;
|
||||
}
|
||||
.maze-game-base > .maze-game-container > .start-dest-cube > i {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.maze-game-base > .maze-game-container > .each-cube {
|
||||
width: 3vw;
|
||||
height: 3vw;
|
||||
|
||||
background-color: var(--cube-bg-darkgreen);
|
||||
border: 2px solid var(--color-green);
|
||||
text-align: center;
|
||||
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.maze-game-base > .maze-game-container > .each-cube > p {
|
||||
font-size: 1.5vw;
|
||||
font-weight: bold;
|
||||
margin-top: 0.2vw
|
||||
}
|
||||
|
||||
.blinking-cube {
|
||||
animation: blink 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
0%,
|
||||
100% {
|
||||
background-color: var(--color-green);
|
||||
/* background-color: var(--cube-bg-darkgreen); */
|
||||
}
|
||||
|
||||
50% {
|
||||
background-color: var(--cube-bg-darkgreen);
|
||||
}
|
||||
}
|
||||
|
||||
.ps-bg-green-cube {
|
||||
background-color: var(--color-green) !important;
|
||||
}
|
||||
.ps-bg-wrong-cube {
|
||||
background-color: var(--color-red) !important;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
|
@ -0,0 +1,240 @@
|
|||
<script lang="ts">
|
||||
import { gameSettings, currentActiveGameDetails, closeGame } from "../stores/GameLauncherStore";
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import fetchNui from "../../utils/fetch";
|
||||
import mojs from '@mojs/core';
|
||||
import { convertVwToPx, getRandomArbitrary, isDevMode } from "../stores/GeneralStores";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let gameTimeRemaining = 0;
|
||||
|
||||
let blocksInput = $gameSettings.amountOfAnswers; // how many cubes to remember for game - increment number based on difficulty level
|
||||
let gameTime = $gameSettings.gameTime * 100;
|
||||
let numberOfWrongClicksAllowed = $gameSettings.maxAnswersIncorrect;
|
||||
let displayNumbersOnCubesFor = $currentActiveGameDetails.timeForNumberDisplay * 100;
|
||||
|
||||
let counter, gameStarted = false, gameEnded = false;
|
||||
let allCubes = [];
|
||||
let order = 0, wrongClicks = 0;
|
||||
let cubeBgColors = ['var(--color-green)', 'var(--color-palegreen)', 'var(--color-blue)'];
|
||||
|
||||
// let topLowerBound = 290, topHigherBound = 660; px
|
||||
// let leftLowerBound = 77, leftHigherBound = 459;
|
||||
let topLowerBound = 18, topHigherBound = 40; //vw
|
||||
let leftLowerBound = 2, leftHigherBound = 28;
|
||||
|
||||
onMount(() => {
|
||||
//generate shuffled cubes indices
|
||||
let cubeIndicesList = [];
|
||||
while(cubeIndicesList.length < blocksInput){
|
||||
const r = Math.floor(Math.random() * blocksInput);
|
||||
if(cubeIndicesList.indexOf(r) === -1) cubeIndicesList.push(r);
|
||||
}
|
||||
|
||||
//generating an array to maintain each cube data by index
|
||||
for(let i = 0; i < cubeIndicesList.length; i++) {
|
||||
//height between 290 and 660 px
|
||||
//horizontal between 77 and 459 px
|
||||
const cubeData = {
|
||||
cubeIndex: cubeIndicesList[i],
|
||||
cubeValue: cubeIndicesList[i],
|
||||
bgColor: cubeBgColors[Math.floor(Math.random() * cubeBgColors.length)],
|
||||
top: getRandomArbitrary(topLowerBound, topHigherBound),
|
||||
left: getRandomArbitrary(leftLowerBound, leftHigherBound)
|
||||
};
|
||||
allCubes.push(cubeData);
|
||||
allCubes = allCubes;
|
||||
}
|
||||
|
||||
//stop showing the correct cubes and start the guessing game
|
||||
setTimeout(() => {
|
||||
gameStarted = true;
|
||||
|
||||
let eachCube = document.querySelectorAll('.each-cube');
|
||||
eachCube.forEach(el => { newPos(el) });
|
||||
|
||||
counter = setInterval(startTimer, 10);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
function newPos(element) {
|
||||
let top = element.offsetTop;
|
||||
let left = element.offsetLeft;
|
||||
|
||||
let new_top_vw = getRandomArbitrary(topLowerBound,topHigherBound);
|
||||
let new_left_vw = getRandomArbitrary(leftLowerBound,leftHigherBound);
|
||||
|
||||
let new_top = convertVwToPx(new_top_vw);
|
||||
let new_left = convertVwToPx(new_left_vw);
|
||||
|
||||
let diff_top = new_top - top;
|
||||
let diff_left = new_left - left;
|
||||
|
||||
let duration = getRandomArbitrary(10,40)*100;
|
||||
|
||||
new mojs.Html({
|
||||
el: '#'+element.id,
|
||||
x: {
|
||||
0:diff_left,
|
||||
duration: duration,
|
||||
easing: 'linear.none'
|
||||
},
|
||||
y: {
|
||||
0:diff_top,
|
||||
duration: duration,
|
||||
easing: 'linear.none'
|
||||
},
|
||||
duration: duration+50,
|
||||
onComplete() {
|
||||
if(element.offsetTop === 0 && element.offsetLeft === 0) {
|
||||
this.pause();
|
||||
return;
|
||||
}
|
||||
const bgColor = element.style.backgroundColor;
|
||||
element.style = 'background-color: '+bgColor+'; top: '+new_top_vw+'vw; left: '+new_left_vw+'vw; transform: none;';
|
||||
newPos(element);
|
||||
},
|
||||
onUpdate() {
|
||||
if(gameStarted === false) this.pause();
|
||||
}
|
||||
}).play();
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
if (gameTime <= 0)
|
||||
{
|
||||
endGame(false);
|
||||
return;
|
||||
}
|
||||
displayNumbersOnCubesFor--;
|
||||
gameTime--;
|
||||
gameTimeRemaining = gameTime/100;
|
||||
}
|
||||
|
||||
function handleClick(clickedCube) {
|
||||
if(gameStarted && !gameEnded && displayNumbersOnCubesFor <= 0) {
|
||||
//correct click
|
||||
if(order === clickedCube.cubeIndex) {
|
||||
let clickedCubeDom = document.getElementById('each-cube-'+clickedCube.cubeIndex);
|
||||
clickedCubeDom.style.backgroundColor = 'var(--color-darkgrey)';
|
||||
order = order + 1;
|
||||
} else {
|
||||
wrongClicks = wrongClicks + 1;
|
||||
}
|
||||
checkGameStatus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkGameStatus() {
|
||||
if(order === allCubes.length - 1 && wrongClicks < numberOfWrongClicksAllowed) {
|
||||
endGame(true);
|
||||
} else if(order < allCubes.length - 1 && wrongClicks >= numberOfWrongClicksAllowed) {
|
||||
endGame(false);
|
||||
}
|
||||
}
|
||||
|
||||
function endGame(isSuccess) {
|
||||
if(!gameEnded) {
|
||||
gameEnded = true;
|
||||
clearInterval(counter);
|
||||
|
||||
setTimeout(() => {
|
||||
if(!isDevMode) {
|
||||
fetchNui('minigame:callback', isSuccess);
|
||||
dispatch('game-ended', { hackSuccess: isSuccess });
|
||||
}
|
||||
dispatch('minigame:callback', {hackSuccess: isSuccess});
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyEvent(event) {
|
||||
let key_pressed = event.key;
|
||||
let valid_keys = ['Escape'];
|
||||
|
||||
if(gameStarted && valid_keys.includes(key_pressed) && !gameEnded) {
|
||||
switch(key_pressed){
|
||||
case 'Escape':
|
||||
closeGame(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown|preventDefault={handleKeyEvent} />
|
||||
<div class="var-game-base">
|
||||
<div class="time-left">
|
||||
<i class="fa-solid fa-clock ps-text-lightgrey clock-icon"></i>
|
||||
<p class="{gameTimeRemaining !== 0 ? 'game-timer-var' : 'mr-1'}">{gameTimeRemaining} </p> time remaining
|
||||
</div>
|
||||
|
||||
<div id="var-game-container" class="var-game-container">
|
||||
{#each allCubes as cube}
|
||||
<div
|
||||
id={'each-cube-'+cube.cubeIndex}
|
||||
class="each-cube"
|
||||
style="background-color:{cube.bgColor}; top: {cube.top}vw; left: {cube.left}vw;"
|
||||
on:click={() => handleClick(cube)}
|
||||
>
|
||||
{#if displayNumbersOnCubesFor > 0}
|
||||
<p>{cube.cubeValue + 1}</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.var-game-base {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
height: 28vw;
|
||||
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: var(--color-lightgrey);
|
||||
}
|
||||
|
||||
.var-game-base > .time-left {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
font-size: 0.85vw;
|
||||
}
|
||||
.var-game-base > .time-left > .clock-icon {
|
||||
padding-top: 0.17vw;
|
||||
margin-right: 0.3vw;
|
||||
}
|
||||
.var-game-base > .time-left > .game-timer-var {
|
||||
width: 2.5vw;
|
||||
}
|
||||
|
||||
.var-game-base > .var-game-container {
|
||||
border: 2px solid var(--color-green);
|
||||
background-color: var(--cube-bg-darkgreen);
|
||||
|
||||
margin-top: 1vw;
|
||||
width: 30vw;
|
||||
height: 28vw;
|
||||
}
|
||||
.var-game-base > .var-game-container > .each-cube {
|
||||
width: 3vw;
|
||||
height: 3vw;
|
||||
|
||||
border: 2px solid var(--color-lightgrey);
|
||||
position: absolute;
|
||||
|
||||
text-align: center;
|
||||
cursor: default;
|
||||
}
|
||||
.var-game-base > .var-game-container > .each-cube > p {
|
||||
font-size: 1.5vw;
|
||||
font-weight: bold;
|
||||
margin-top: 0.2vw;
|
||||
color: var(--color-black);
|
||||
}
|
||||
</style>
|
321
resources/[freizeit]/[gym]/ps-ui/web/src/games/Scrambler.svelte
Normal file
|
@ -0,0 +1,321 @@
|
|||
<script lang="ts">
|
||||
import { closeGame, currentActiveGameDetails, gameSettings } from "../stores/GameLauncherStore";
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import fetchNui from "../../utils/fetch";
|
||||
import { getRandomArbitrary, isDevMode } from "../stores/GeneralStores";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
const randomSetChar = () => {
|
||||
let str='?';
|
||||
switch($currentActiveGameDetails.sets) {
|
||||
case 'numeric':
|
||||
str="0123456789";
|
||||
break;
|
||||
case 'alphabet':
|
||||
str="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
break;
|
||||
case 'alphanumeric':
|
||||
str="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
break;
|
||||
case 'greek':
|
||||
str="ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ";
|
||||
break;
|
||||
case 'braille':
|
||||
str="⡀⡁⡂⡃⡄⡅⡆⡇⡈⡉⡊⡋⡌⡍⡎⡏⡐⡑⡒⡓⡔⡕⡖⡗⡘⡙⡚⡛⡜⡝⡞⡟⡠⡡⡢⡣⡤⡥⡦⡧⡨⡩⡪⡫⡬⡭⡮⡯⡰⡱⡲⡳⡴⡵⡶⡷⡸⡹⡺⡻⡼⡽⡾⡿"+
|
||||
"⢀⢁⢂⢃⢄⢅⢆⢇⢈⢉⢊⢋⢌⢍⢎⢏⢐⢑⢒⢓⢔⢕⢖⢗⢘⢙⢚⢛⢜⢝⢞⢟⢠⢡⢢⢣⢤⢥⢦⢧⢨⢩⢪⢫⢬⢭⢮⢯⢰⢱⢲⢳⢴⢵⢶⢷⢸⢹⢺⢻⢼⢽⢾⢿"+
|
||||
"⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿";
|
||||
break;
|
||||
case 'runes':
|
||||
str="ᚠᚥᚧᚨᚩᚬᚭᚻᛐᛑᛒᛓᛔᛕᛖᛗᛘᛙᛚᛛᛜᛝᛞᛟᛤ";
|
||||
break;
|
||||
}
|
||||
return str.charAt(getRandomArbitrary(0, str.length));
|
||||
}
|
||||
|
||||
let gameTimeRemaining = 0;
|
||||
|
||||
let amountOfAnswers = $gameSettings.amountOfAnswers; // how many numbers for game
|
||||
let gameTime = $gameSettings.gameTime * 100; // seconds
|
||||
|
||||
let correctIndices = [], correctAnswers = [];
|
||||
let changeBoardAfter = $currentActiveGameDetails.changeBoardAfter * 100; //3 seconds
|
||||
let originalChangeBoardAfter = changeBoardAfter;
|
||||
let counter, gameStarted = false, gameEnded = false;
|
||||
let hackSuccess = false;
|
||||
let numberOfCubes = 80, allCubes = [];
|
||||
let totalNumberOfColumns = 10;
|
||||
|
||||
let cursorIndices = [], cursorStartIndex = 43;
|
||||
|
||||
onMount(() => {
|
||||
//generating an array to maintain each cube data by index
|
||||
for(let i = 0; i < numberOfCubes; i++) {
|
||||
const cubeData = {
|
||||
cubeIndex: i,
|
||||
cubeValue: randomSetChar() + randomSetChar(),
|
||||
};
|
||||
allCubes.push(cubeData);
|
||||
allCubes = allCubes;
|
||||
}
|
||||
|
||||
//generate correct answer values - column number - has to be Number of cols - 4 to have straight 4 answers
|
||||
const columnNumber = Math.floor(Math.random() * 5);
|
||||
//generate correct answer values - row number
|
||||
const rowNumber = Math.floor(Math.random() * 7);
|
||||
|
||||
const startIndex = rowNumber * totalNumberOfColumns + columnNumber;
|
||||
correctAnswers = [];
|
||||
for(let i = 0; i < amountOfAnswers; i++) {
|
||||
correctAnswers.push(allCubes[i + startIndex]);
|
||||
correctIndices.push(i+startIndex);
|
||||
}
|
||||
|
||||
getCursorIndices();
|
||||
|
||||
//start game
|
||||
setTimeout(() => {
|
||||
gameStarted = true;
|
||||
counter = setInterval(startTimer, 10);
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
|
||||
function getCursorIndices() {
|
||||
cursorIndices = [cursorStartIndex];
|
||||
for(let i=1; i<4; i++){
|
||||
if( cursorStartIndex+i >= 80 ){
|
||||
cursorIndices.push( (cursorStartIndex+i) - 80 );
|
||||
}else{
|
||||
cursorIndices.push( cursorStartIndex+i );
|
||||
}
|
||||
}
|
||||
// return group;
|
||||
}
|
||||
|
||||
function endTheGame() {
|
||||
clearInterval(counter);
|
||||
gameEnded = true;
|
||||
|
||||
setTimeout(() => {
|
||||
if(!isDevMode) {
|
||||
fetchNui('minigame:callback', hackSuccess);
|
||||
dispatch('game-ended', { hackSuccess });
|
||||
}
|
||||
dispatch('minigame:callback', hackSuccess);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
if (gameTime <= 0)
|
||||
{
|
||||
hackSuccess = false;
|
||||
endTheGame();
|
||||
return;
|
||||
} else if (changeBoardAfter <= 0) {
|
||||
scrambleBoard();
|
||||
}
|
||||
|
||||
gameTime--;
|
||||
changeBoardAfter--;
|
||||
|
||||
gameTimeRemaining = gameTime/100;
|
||||
}
|
||||
|
||||
function scrambleBoard() {
|
||||
changeBoardAfter = originalChangeBoardAfter;
|
||||
|
||||
//generating an array to maintain each cube data by index
|
||||
let newCubeData = [];
|
||||
for(let i = 0; i < numberOfCubes; i++) {
|
||||
let cubeValue;
|
||||
|
||||
if(i === numberOfCubes - 1) {
|
||||
cubeValue = allCubes[0].cubeValue;
|
||||
} else {
|
||||
cubeValue = allCubes[i+1].cubeValue;
|
||||
}
|
||||
const cubeData = {
|
||||
cubeIndex: i,
|
||||
cubeValue: cubeValue,
|
||||
};
|
||||
newCubeData.push(cubeData);
|
||||
newCubeData = newCubeData;
|
||||
}
|
||||
getCursorIndices();
|
||||
|
||||
allCubes = newCubeData;
|
||||
}
|
||||
|
||||
function checkAnswer() {
|
||||
let selectedValues = cursorIndices.map((currentCursorIndex) => {
|
||||
return allCubes[currentCursorIndex];
|
||||
});
|
||||
|
||||
const selectedValuesData = selectedValues.map((item) => {
|
||||
return item.cubeValue;
|
||||
});
|
||||
|
||||
const correctAnswerValues = correctAnswers.map((item) => {
|
||||
return item.cubeValue;
|
||||
});
|
||||
|
||||
if(JSON.stringify(selectedValuesData) === JSON.stringify(correctAnswerValues)) {
|
||||
hackSuccess = true;
|
||||
} else {
|
||||
hackSuccess = false;
|
||||
}
|
||||
|
||||
endTheGame();
|
||||
}
|
||||
|
||||
function handleKeyEvent(event) {
|
||||
let key_pressed = event.key;
|
||||
let valid_keys = ['a','w','s','d', 'A','W','S','D' ,'ArrowUp','ArrowDown','ArrowRight','ArrowLeft','Enter', 'Escape'];
|
||||
|
||||
if(gameStarted && valid_keys.includes(key_pressed) && !gameEnded) {
|
||||
switch(key_pressed){
|
||||
case 'w':
|
||||
case 'ArrowUp':
|
||||
cursorStartIndex -= 10;
|
||||
if(cursorStartIndex < 0) {
|
||||
cursorStartIndex += 80;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
case 'ArrowDown':
|
||||
cursorStartIndex += 10;
|
||||
cursorStartIndex %= 80;
|
||||
break;
|
||||
case 'a':
|
||||
case 'ArrowLeft':
|
||||
cursorStartIndex--;
|
||||
if(cursorStartIndex < 0) {
|
||||
cursorStartIndex = 79;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
case 'ArrowRight':
|
||||
cursorStartIndex++;
|
||||
cursorStartIndex %= 80;
|
||||
break;
|
||||
case 'Enter':
|
||||
clearInterval(counter);
|
||||
checkAnswer();
|
||||
return;
|
||||
case 'Escape':
|
||||
closeGame(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
if(cursorStartIndex) {
|
||||
getCursorIndices();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown|preventDefault={handleKeyEvent} />
|
||||
<div class="scrambler-game-base">
|
||||
<div class="game-info-container">
|
||||
<div class="scrambler-find-data">
|
||||
<p>Match the numbers underneath.</p>
|
||||
<div class="original-data-wrapper">
|
||||
{#each correctAnswers as value}
|
||||
<p class="original-digits">{value.cubeValue}</p>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="time-left">
|
||||
<i class="fa-solid fa-clock ps-text-lightgrey clock-icon"></i>
|
||||
<p class="{gameTimeRemaining !== 0 ? 'game-timer-var' : 'mr-1'}">{gameTimeRemaining} </p> time remaining
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="scrambler-game-container" class="scrambler-game-container">
|
||||
{#each allCubes as cube}
|
||||
<div id={'each-cube-'+cube.cubeIndex} class="each-cube">
|
||||
<p class="{!gameEnded && cursorIndices.includes(cube.cubeIndex) ? 'ps-text-red' : ''}">{cube.cubeValue}</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.scrambler-game-base {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 28vw;
|
||||
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: var(--color-lightgrey);
|
||||
}
|
||||
|
||||
.scrambler-game-base > .game-info-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.scrambler-game-base > .game-info-container > .scrambler-find-data {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.scrambler-game-base > .game-info-container > .scrambler-find-data > .original-data-wrapper {
|
||||
width: max-content;
|
||||
border: 2px solid var(--color-green);
|
||||
border-radius: 0.2vw;
|
||||
background-color: var(--cube-bg-darkgreen);
|
||||
color: var(--color-green);
|
||||
|
||||
margin: 0.5vw auto;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.scrambler-game-base > .game-info-container > .scrambler-find-data > .original-data-wrapper > .original-digits {
|
||||
font-size: 1vw;
|
||||
padding: 0.3vw 0.5vw;
|
||||
}
|
||||
|
||||
.scrambler-game-base > .game-info-container > .time-left {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
font-size: 0.85vw;
|
||||
}
|
||||
.scrambler-game-base > .game-info-container > .time-left > .clock-icon {
|
||||
padding-top: 0.17vw;
|
||||
margin-right: 0.3vw;
|
||||
}
|
||||
.scrambler-game-base > .game-info-container > .time-left > .game-timer-var {
|
||||
width: 2.5vw;
|
||||
}
|
||||
|
||||
.scrambler-game-base > .scrambler-game-container {
|
||||
/* border: 0.1px solid red; */
|
||||
|
||||
margin-top: 1vw;
|
||||
width: 30vw;
|
||||
height: 24vw;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5vw;
|
||||
}
|
||||
.scrambler-game-base > .scrambler-game-container > .each-cube {
|
||||
width: 2.5vw;
|
||||
height: 2.5vw;
|
||||
|
||||
font-size: 1.75vw;
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,61 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import Skull from "../assets/svgs/Skull.svelte";
|
||||
import { closeUi } from "../stores/GameLauncherStore";
|
||||
|
||||
export let isSuccess = false;
|
||||
const skullColor: string = 'var(--color-green)';
|
||||
|
||||
onMount(() => {
|
||||
setTimeout(() => {
|
||||
closeUi();
|
||||
}, 2000);
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="result-container">
|
||||
<div class="result-wrapper ps-bg-darkblue">
|
||||
<div class="skull-logo">
|
||||
<Skull color={skullColor} />
|
||||
</div>
|
||||
{#if isSuccess}
|
||||
<h1 class="text-white text-3xl uppercase">
|
||||
Access granted
|
||||
</h1>
|
||||
{:else}
|
||||
<h1 class="text-white text-3xl uppercase">
|
||||
Access denied
|
||||
</h1>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.result-container {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
border-radius: 0.2vw;
|
||||
}
|
||||
|
||||
.result-container > .result-wrapper {
|
||||
width: 30vw;
|
||||
height: 15vw;
|
||||
border-radius: 0.3vw;
|
||||
overflow: hidden;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.result-container > .result-wrapper > .skull-logo {
|
||||
margin: 0 auto 1vw auto;
|
||||
width: 6vw;
|
||||
}
|
||||
</style>
|