diff --git a/__resource.lua b/__resource.lua deleted file mode 100644 index 314c431..0000000 --- a/__resource.lua +++ /dev/null @@ -1,10 +0,0 @@ -resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' - -client_scripts { - 'main.lua' -} - -server_scripts { - '@mysql-async/lib/MySQL.lua', - 'server.lua' -} diff --git a/client/cl_main.lua b/client/cl_main.lua new file mode 100644 index 0000000..bcf1a98 --- /dev/null +++ b/client/cl_main.lua @@ -0,0 +1,42 @@ +QBCore = exports['qb-core']:GetCoreObject() +local box = nil +local animlib = 'anim@mp_fireworks' + +RegisterNetEvent('frp-fireworks:client:UseFirework') +AddEventHandler('frp-fireworks:client:UseFirework', function() + print("[frp-fireworks:client] Preparing to use firework...") + lib.requestAnimDict(animlib, 2000) + lib.requestNamedPtfxAsset("scr_indep_fireworks", 2000) + + print("[frp-fireworks:client] Starting firework...") + + local ped = GetPlayerPed(-1) + local pedcoords = GetEntityCoords(ped) + local times = 20 + + TaskPlayAnim(ped, animlib, 'place_firework_3_box', -1, -8.0, 3000, 0, 0, false, false, false) + Citizen.Wait(4000) + ClearPedTasks(ped) + + box = CreateObject(GetHashKey('ind_prop_firework_03'), pedcoords, true, false, false) + PlaceObjectOnGroundProperly(box) + FreezeEntityPosition(box, true) + local firecoords = GetEntityCoords(box) + + print("[frp-fireworks:client] Firework placed at: " .. firecoords) + print("[frp-fireworks:client] Starting firework sequence...") + + Citizen.Wait(10000) + repeat + UseParticleFxAssetNextCall("scr_indep_fireworks") + StartNetworkedParticleFxNonLoopedAtCoord("scr_indep_firework_trailburst", firecoords, 0.0, 0.0, 0.0, 1.0, false, false, false, false) + times = times - 1 + Citizen.Wait(2000) + until(times == 0) + + print("[frp-fireworks:client] Firework sequence complete! Cleaning up...") + DeleteEntity(box) + box = nil + + print("[frp-fireworks:client] Cleanup complete. Firework finished!") +end) diff --git a/fxmanifest.lua b/fxmanifest.lua new file mode 100644 index 0000000..c3aee53 --- /dev/null +++ b/fxmanifest.lua @@ -0,0 +1,20 @@ +fx_version 'cerulean' +game 'gta5' + +author 'SticksDev ' +description 'Fireworks script for FamilyRP' +version '1.0.0' +lua54 'yes' -- Required for ox_lib compatibility + +client_scripts { + 'client/cl_*.lua', +} + +server_scripts { + 'server/sv_*.lua', +} + +shared_scripts { + '@ox_lib/init.lua', +} + diff --git a/main.lua b/main.lua deleted file mode 100644 index b410103..0000000 --- a/main.lua +++ /dev/null @@ -1,47 +0,0 @@ - -ESX = nil - -local box = nil -local animlib = 'anim@mp_fireworks' - - -RegisterNetEvent('frobski-fireworks:start') -AddEventHandler('frobski-fireworks:start', function() - - RequestAnimDict(animlib) - - while not HasAnimDictLoaded(animlib) do - Citizen.Wait(10) - end - - if not HasNamedPtfxAssetLoaded("scr_indep_fireworks") then - RequestNamedPtfxAsset("scr_indep_fireworks") - while not HasNamedPtfxAssetLoaded("scr_indep_fireworks") do - Wait(10) - end - end - - local pedcoords = GetEntityCoords(GetPlayerPed(-1)) - local ped = GetPlayerPed(-1) - local times = 20 - - TaskPlayAnim(ped, animlib, 'place_firework_3_box', -1, -8.0, 3000, 0, 0, false, false, false) - Citizen.Wait(4000) - ClearPedTasks(ped) - - box = CreateObject(GetHashKey('ind_prop_firework_03'), pedcoords, true, false, false) - PlaceObjectOnGroundProperly(box) - FreezeEntityPosition(box, true) - local firecoords = GetEntityCoords(box) - - Citizen.Wait(10000) - repeat - UseParticleFxAssetNextCall("scr_indep_fireworks") - local part1 = StartNetworkedParticleFxNonLoopedAtCoord("scr_indep_firework_trailburst", firecoords, 0.0, 0.0, 0.0, 1.0, false, false, false, false) - times = times - 1 - Citizen.Wait(2000) - until(times == 0) - DeleteEntity(box) - box = nil -end) - diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..8dc052b --- /dev/null +++ b/readme.md @@ -0,0 +1,19 @@ +# frp-fireworks + +A simple fireworks script for the 4th of July in Family Roleplay. + +## Installation + +1. Download the script by using the green "Code" button and selecting "Download ZIP". +2. Extract the ZIP and ensure it's name is `frp-fireworks` when placed in your `resources` folder. +3. Ensure this resource using `ensure frp-fireworks` in your `server.cfg` or place it in a resource group and ensure the group. +4. Start your server and enjoy! + +## Usage + +1. Use the command `/fireworks` to launch fireworks at your location. Anyone with the `qbcore.admin` permission can use this command. + +## Changing permissions + +1. Open the `server/sv_main.lua` file. +2. Change the permission in the `QBCore.Commands.Add` function to your desired permission. The default is `qbcore.admin`. diff --git a/server.lua b/server.lua deleted file mode 100644 index 680f50b..0000000 --- a/server.lua +++ /dev/null @@ -1,11 +0,0 @@ -ESX = nil - -TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) - -ESX.RegisterUsableItem('firebox', function(source) - local xPlayer = ESX.GetPlayerFromId(source) - - xPlayer.removeInventoryItem('firebox', 1) - - TriggerClientEvent('frobski-fireworks:start', source) -end) diff --git a/server/sv_main.lua b/server/sv_main.lua new file mode 100644 index 0000000..cef3a7a --- /dev/null +++ b/server/sv_main.lua @@ -0,0 +1,18 @@ +print("[frp-fireworks] Starting resource...") +QBCore = exports['qb-core']:GetCoreObject() + +if QBCore == nil then + print("[!] QBCore is not installed (failed to get core object). This resource requires QBCore to function properly. Shutting down resource...") + Citizen.Wait(5000) + StopResource(GetCurrentResourceName()) +end + +-- Create our command to use fireworks. Only allow people with the frp.useFireworks permission to use this command. +QBCore.Commands.Add("fireworks", "Trigger a firework show!", {}, false, function(source, args) + local Player = QBCore.Functions.GetPlayer(source) + TriggerClientEvent('frp-fireworks:client:UseFirework', source) + TriggerClientEvent('QBCore:Notify', source, "Starting the show...", "success") +end, 'admin') + +print("[frp-fireworks] Done!") +print("[frp-fireworks] Resource started successfully!")