rewrite to qbcore
This commit is contained in:
parent
a599a81677
commit
53577c533d
@ -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'
|
||||
}
|
42
client/cl_main.lua
Normal file
42
client/cl_main.lua
Normal file
@ -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)
|
20
fxmanifest.lua
Normal file
20
fxmanifest.lua
Normal file
@ -0,0 +1,20 @@
|
||||
fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
|
||||
author 'SticksDev <sticks@teamhydra.dev>'
|
||||
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',
|
||||
}
|
||||
|
47
main.lua
47
main.lua
@ -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)
|
||||
|
19
readme.md
Normal file
19
readme.md
Normal file
@ -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`.
|
11
server.lua
11
server.lua
@ -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)
|
18
server/sv_main.lua
Normal file
18
server/sv_main.lua
Normal file
@ -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!")
|
Loading…
x
Reference in New Issue
Block a user