ed
This commit is contained in:
parent
600d79af31
commit
5d11084641
136 changed files with 12007 additions and 584 deletions
35
resources/[freizeit]/[gym]/ps-ui/client/circle.lua
Normal file
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
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
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
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
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
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
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
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
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
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
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
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
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)
|
Loading…
Add table
Add a link
Reference in a new issue