This commit is contained in:
Nordi98 2025-08-06 16:37:06 +02:00
parent 510e3ffcf2
commit f43cf424cf
305 changed files with 34683 additions and 0 deletions

View file

@ -0,0 +1,19 @@
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
Bridge.Cache.OnChange("Ped", function(newValue, oldValue)
print("Ped changed from " .. tostring(oldValue) .. " to " .. tostring(newValue))
end)
end
end)
RegisterCommand("testcache", function(source, args, rawCommand)
-- local cache = Bridge.Cache.Get("Ped")
Bridge.Cache.Create("TestCache", function()
return math.random(1, 100)
end, 1000)
Bridge.Cache.OnChange("TestCache", function(newValue, oldValue)
print("TestCache changed from " .. tostring(oldValue) .. " to " .. tostring(newValue))
end)
end)

View file

@ -0,0 +1,40 @@
-- ▄▀▀ ▄▀▄ █ █ ██▄ ▄▀▄ ▄▀▀ █▄▀ ▄▀▀ ▄▀▀ █▄█ ▄▀▄ █▀▄ ██▀ █▀▄ █ █ █▄ █ █ ▀█▀ ▀█▀ ██▀ ▄▀▀ ▀█▀
-- ▀▄▄ █▀█ █▄▄ █▄▄ █▄█ █▀█ ▀▄▄ █ █ ▄█▀ ▄█▀ █ █ █▀█ █▀▄ █▄▄ █▄▀ ▀▄█ █ ▀█ █ █ █ █▄▄ ▄█▀ █
-- -- -- -- -- -- -- -- -- --
-- ▄▀▀ ██▀ █▀▄ █ █ ██▀ █▀▄
-- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄
-- -- -- -- -- -- -- -- -- --
if not IsDuplicityVersion() then goto client end
Bridge.Callbacks.Register('callback_test1_name_here', function(src, var1)
if var1 == "herpaderpa" then
print("this is a test")
end
return 'some random string', "some other string"
end)
RegisterCommand('callback_test2', function(source)
local someData, other = Bridge.Callbacks.Trigger('callback_test2_name_here', source, "herpaderpa")
print("Data From Client: ", someData, other)
end)
-- -- -- -- -- -- -- -- -- --
-- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀
-- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █
-- -- -- -- -- -- -- -- -- --
if IsDuplicityVersion() then return end
::client::
RegisterCommand('callback_test1', function()
local somerandomstring, someotherrandomstring = Bridge.Callbacks.Trigger('callback_test1_name_here', "herpaderpa")
print("Data From Server: ", somerandomstring, someotherrandomstring)
end)
-- exports.community_bridge:RegisterRebound('callback_test1', function(src, cb, ftpcsftug)
-- print("this is a rebound to all players")
-- end)
Bridge.Callbacks.Register('callback_test2_name_here', function(ftpcsftug)
return ftpcsftug, 'TestyMcTesterton'
end)

View file

@ -0,0 +1,234 @@
-- Test QB Format Input
RegisterCommand('input_test_qb', function()
local qbFormatData = {
inputs = {
{
text = "Player Name",
name = "playername",
type = "text",
isRequired = true,
default = "John Doe"
},
{
text = "Player ID",
name = "playerid",
type = "number",
isRequired = true
},
{
text = "Password",
name = "password",
type = "password",
isRequired = false
},
{
text = "Vehicle Type",
name = "vehicle",
type = "select",
isRequired = true,
options = {
{value = "car", text = "Car"},
{value = "bike", text = "Motorcycle"},
{value = "truck", text = "Truck"}
}
},
{
text = "Enable Notifications",
name = "notifications",
type = "checkbox",
isRequired = false,
options = {
{value = "email", text = "Email", checked = true},
{value = "sms", text = "SMS", checked = false}
}
}
}
}
local result = Input.Open("QB Format Test", qbFormatData, true, "Submit")
if result then
print("QB Format Result:")
for k, v in pairs(result) do
print(k .. ": " .. tostring(v))
end
else
print("QB Format: User cancelled or no input")
end
end, false)
-- Test Ox Format Input
RegisterCommand('input_test_ox', function()
local oxFormatData = {
{
type = "input",
label = "Character Name",
name = "charname",
required = true,
default = "Jane Smith"
},
{
type = "number",
label = "Age",
name = "age",
required = true,
min = 18,
max = 100
},
{
type = "select",
label = "Job Category",
name = "jobcat",
required = true,
options = {
{value = "civ", label = "Civilian"},
{value = "leo", label = "Law Enforcement"},
{value = "ems", label = "Emergency Medical"}
}
},
{
type = "checkbox",
label = "Has License",
name = "license",
required = false
},
{
type = "color",
label = "Favorite Color",
name = "color",
default = "#ff0000"
},
{
type = "date",
label = "Birth Date",
name = "birthdate",
format = "DD/MM/YYYY"
}
}
local result = Input.Open("Ox Format Test", oxFormatData, false)
if result then
print("Ox Format Result:")
for k, v in pairs(result) do
print(k .. ": " .. tostring(v))
end
else
print("Ox Format: User cancelled or no input")
end
end, false)
-- Test Simple Text Input
RegisterCommand('input_test_simple', function()
local simpleData = {
inputs = {
{
text = "Enter your message",
name = "message",
type = "text",
isRequired = true
}
}
}
local result = Input.Open("Simple Input", simpleData, true, "Send")
if result then
print("Simple Input Result: " .. (result.message or "No message"))
else
print("Simple Input: Cancelled")
end
end, false)
-- Test All Input Types (QB Format)
RegisterCommand('input_test_all_types', function()
local allTypesData = {
inputs = {
{
text = "Text Input",
name = "text_field",
type = "text",
isRequired = false,
default = "Sample text"
},
{
text = "Number Input",
name = "number_field",
type = "number",
isRequired = false,
default = 42
},
{
text = "Password Input",
name = "password_field",
type = "password",
isRequired = false
},
{
text = "Radio Selection",
name = "radio_field",
type = "radio",
isRequired = false,
options = {
{value = "option1", text = "Option 1"},
{value = "option2", text = "Option 2"},
{value = "option3", text = "Option 3"}
}
},
{
text = "Checkbox Options",
name = "checkbox_field",
type = "checkbox",
isRequired = false,
options = {
{value = "check1", text = "Check 1", checked = true},
{value = "check2", text = "Check 2", checked = false},
{value = "check3", text = "Check 3", checked = false}
}
},
{
text = "Select Dropdown",
name = "select_field",
type = "select",
isRequired = false,
options = {
{value = "val1", text = "Value 1"},
{value = "val2", text = "Value 2"},
{value = "val3", text = "Value 3"}
}
}
}
}
local result = Input.Open("All Input Types Test", allTypesData, true, "Test Submit")
if result then
print("All Types Result:", json.encode(result))
else
print("All Types: User cancelled")
end
end, false)
-- Test Error Handling
RegisterCommand('input_test_error', function()
-- Test with invalid data
local result = Input.Open("Error Test", nil, true)
if result then
print("Error test unexpectedly succeeded")
else
print("Error test correctly handled nil data")
end
-- Test with empty inputs
local emptyData = {inputs = {}}
local result2 = Input.Open("Empty Test", emptyData, true)
if result2 then
print("Empty test result: " .. json.encode(result2))
else
print("Empty test: No result")
end
end, false)
-- print("Input unit tests loaded. Available commands:")
-- print(" /input_test_qb - Test QB format input")
-- print(" /input_test_ox - Test Ox format input")
-- print(" /input_test_simple - Test simple text input")
-- print(" /input_test_all_types - Test all input types")
-- print(" /input_test_error - Test error handling")

View file

@ -0,0 +1,16 @@
-- if outside this resource, use local whatever = Require("modules/locales/shared.lua")
-- whatever.Locales("some-index-in-language-.json-file")
-- Files must be stored in "locales" folder, within the resource.
-- Instead of using Require you can also import it via the manifest.
-- The Lang variable is available globally, which tells you what the server is using.
-- print("Language: ", Lang)
-- print("Locale: ", Language.Locale("UNITTEST.locale-unit-test"))
-- Example outside community bridge resource:
-- local Language = Require('modules/locales/shared.lua')
-- print("Language: ", Lang)
-- print("Locale: ", Language.Locale("UNITTEST.locale-unit-test"))
RegisterCommand("lang", function(source, args, raw)
print( "Oh also this works", Language.Locale("placeable_object.place_object_scroll_down"))
end, false)

View file

@ -0,0 +1,7 @@
RegisterCommand("test_particle", function(source, args, rawCommand)
local playerPed = PlayerPedId()
local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 1.0, 0.0)
local heading = GetEntityHeading(playerPed)
Particle.Create("core", "ent_dst_concrete_large", coords, vector3(0.0, 0.0, heading), 1.0, vector3(1.0, 1.0, 1.0), false)
end)

View file

@ -0,0 +1,38 @@
local isPlacing = false
RegisterCommand('startplacer', function(source, args, rawCommand)
if Bridge.PlaceableObject.IsPlacing() then
print("Already placing an object.")
return
end
local model = args[1] or 'prop_barrel_01a' -- Default model if none provided
local position = GetEntityCoords(PlayerPedId())
local result = Bridge.PlaceableObject.Create(model, {
allowMovement = true, -- Enable movement mode
allowNormal = true, -- Enable normal mode
allowVertical = false, -- Allow vertical movement in normal mode
startMode = 'normal', -- Start in normal mode
depthMin = 2.0,
depthMax = 15.0,
heightStep = 0.2, -- Height adjustment step
boundary = {min = vector3(position.x - 5, position.y - 5, position.z - 1.5), max = vector3(position.x + 5, position.y + 5, position.z + 10)},
showInstructionalButtons = true, -- Show instructional buttons
})
if result then
print("Object placed!")
print("Position:", result.position)
print("Heading:", result.heading)
else
print("Placement cancelled")
end
end)
RegisterCommand("startplacerold", function(source, args, rawCommand)
local model = args[1] or 'prop_barrel_01a' -- Default model if none provided
local distance = tonumber(args[2]) or 5.0 -- Default distance if not provided
local snapToGround = true
local offset = vector3(0.0, 0.0, 0.0) -- No offset
local obj = Bridge.Placeable.PlaceObject(model, distance, snapToGround, {}, offset)
end)