Skip to content

Commit

Permalink
FRAMEWORK v1.0_f
Browse files Browse the repository at this point in the history
FRAMEWORK 1.0 IS OUT!!!!!!!
  • Loading branch information
Pyth3rEx committed Feb 24, 2019
1 parent bc12bed commit 9871cdb
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 910 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# esx_fireDispatch
Fire script for RP servers in FiveM

The script is not functional right now. Check #release for working versions
This script intorduces a fully-functional Fire Departement System with Fire Callouts

Features:
- Fire Calls
- Dynamic Fires
- Fire Particles Management System
- Fire Alarm Sytem
- Server-sided calculations (all clients see the same thing)

Check the Wiki for all infos on how to setup this script for your server, help us out in the development, or just more data I don't really know how to fit here ;)
2 changes: 1 addition & 1 deletion __resource.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource_manifest_version "77731fab-63ca-442c-a67b-abc70f28dfa5"

client_scripts {
"client.lua",
"vars/variables.lua",
"client.lua",
}


Expand Down
74 changes: 27 additions & 47 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ local fireHornLocation = {
}

local fireSpawnLocation = {
{ x = 1161.0, y = -1452.53, z = 34.72, name = "El Burro Station", id = 1, isFuel = false}, --fire // id = type of fire
{ x = 1161.0, y = -1450.53, z = 34.72, name = "El Burro Station - Testing Fire 1", id = 1, isFuel = false}, --fire // id = type of fire
{ x = 1161.0, y = -1440.53, z = 34.72, name = "El Burro Station - Testing Fire 2", id = 1, isFuel = false}, --fire // id = type of fire
}

------------------------------ ------------------------------
------------------------------ Dispatch ------------------------------
------------------------------ ------------------------------
RegisterNetEvent("triggerSound")
AddEventHandler("triggerSound", function()
ShowNotification("You have triggered the ~r~alarm~w~!")
local plX, plY, plZ = table.unpack(GetEntityCoords(GetPlayerPed(-1), true)) --Gets player XYZ
local nearestStation

for i = 1, #fireHornLocation, 1 do
ShowNotification(fireHornLocation[i].name.." responding!")

local distDiff = Vdist(plX, plY, plZ, fireHornLocation[i].x, fireHornLocation[i].y, fireHornLocation[i].z) --Gets distance between player and firestation[i]
local nearestStationDiff
Expand All @@ -40,7 +39,6 @@ AddEventHandler("triggerSound", function()

if distDiff <= nearestStationDiff then -- if new station is the closest yet
nearestStation = i -- assign new closest station
print(nearestStation)
end
end

Expand Down Expand Up @@ -83,7 +81,7 @@ AddEventHandler("syncCallback", function()
end


-- particles stuff
-- particles stuff, don't touch that
if not HasNamedPtfxAssetLoaded("core") then
RequestNamedPtfxAsset("core")
while not HasNamedPtfxAssetLoaded("core") do
Expand All @@ -93,25 +91,18 @@ AddEventHandler("syncCallback", function()
SetPtfxAssetNextCall("core")

if(fireSpawnLocation[i].id == 0) then
--[[
CreateVehicle(model,fireSpawnLocation[i].x, fireSpawnLocation[i].y, fireSpawnLocation[i].z, 0.0, true, false)--Spawns vehicle
StartScriptFire(fireSpawnLocation[i].x, fireSpawnLocation[i].y+1.5, fireSpawnLocation[i].z-1, 25, fireSpawnLocation[i].isFuel) --spawn fire
table.insert(scriptData.firePositionsX, fireSpawnLocation[i].x) -- stores X
table.insert(scriptData.firePositionsY, fireSpawnLocation[i].y) -- stores Y
table.insert(scriptData.firePositionsZ, fireSpawnLocation[i].z) -- stores Z
--]]

--Car fire
else
scriptData.fires = StartScriptFire(fireSpawnLocation[i].x, fireSpawnLocation[i].y, fireSpawnLocation[i].z-1, 25, fireSpawnLocation[i].isFuel) --spawn fire

local rmd = math.random(1000) -- Gets random number between 1 and 1000
if rmd <= 500 then
scriptData.particles = StartParticleFxLoopedAtCoord("ent_ray_heli_aprtmnt_h_fire", fireSpawnLocation[i].x, fireSpawnLocation[i].y, fireSpawnLocation[i].z-0.7, 0.0, 0.0, 0.0, 1.0, false, false, false, false)
local rmd = math.random(2) -- Gets random number between 1 and 2
if rmd == 1 then
table.insert(scriptData.particles, StartParticleFxLoopedAtCoord("ent_ray_heli_aprtmnt_h_fire", fireSpawnLocation[i].x, fireSpawnLocation[i].y, fireSpawnLocation[i].z-0.7, 0.0, 0.0, 0.0, 1.0, false, false, false, false))
table.insert(scriptData.firePositionsX, fireSpawnLocation[i].x) -- stores X
table.insert(scriptData.firePositionsY, fireSpawnLocation[i].y) -- stores Y
table.insert(scriptData.firePositionsZ, fireSpawnLocation[i].z-0.7) -- stores Z
else
scriptData.particles = StartParticleFxLoopedAtCoord("ent_ray_heli_aprtmnt_l_fire", fireSpawnLocation[i].x, fireSpawnLocation[i].y, fireSpawnLocation[i].z-0.7, 0.0, 0.0, 0.0, 1.0, false, false, false, false)
table.insert(scriptData.particles, StartParticleFxLoopedAtCoord("ent_ray_heli_aprtmnt_l_fire", fireSpawnLocation[i].x, fireSpawnLocation[i].y, fireSpawnLocation[i].z-0.7, 0.0, 0.0, 0.0, 1.0, false, false, false, false))
table.insert(scriptData.firePositionsX, fireSpawnLocation[i].x) -- stores X
table.insert(scriptData.firePositionsY, fireSpawnLocation[i].y) -- stores Y
table.insert(scriptData.firePositionsZ, fireSpawnLocation[i].z-0.7) -- stores Z
Expand All @@ -127,49 +118,38 @@ end, false)
RegisterNetEvent("fireRemover")
AddEventHandler("fireRemover", function()
for i = 1, #scriptData.firePositionsX, 1 do
RemoveScriptFire(scriptData.fires)
-- table.remove(scriptData.fires[i]) -- FIND A WAY TO REMOVE VALUE FROM TABLE

RemoveParticleFx(scriptData.particles, true)
print("Removed Fire: " .. scriptData.firePositionsX[i] .. " " .. scriptData.firePositionsY[i] .. " " .. scriptData.firePositionsZ[i])
RemoveScriptFire(scriptData.fires[i])
RemoveParticleFx(scriptData.particles[i], true)
end
end)


-- Handeling spreading of fires
Citizen.CreateThread(function()
--[[
Wait(500)
if scriptData.firePositionsX == nil then
else
for i=1, #scriptData.firePositionsX, 1 do
local x = table.unpack(scriptData.firePositionsX)
local y = table.unpack(scriptData.firePositionsY)
local z = table.unpack(scriptData.firePositionsZ)
GetClosestFirePos(x, y, z)
local fireX = GetClosestFirePos(x, y, z).x
local fireY = GetClosestFirePos(x, y, z).y
local fireZ = GetClosestFirePos(x, y, z).z
local distToClosestFire = Vdist(x, y, z, fireX, fireY, fireZ)
if distToClosestFire <= 2 then
print("fire still burning")
else
print("no fires")
end
end
end
--]]

-- Stuff for particles
if not HasNamedPtfxAssetLoaded("core") then
RequestNamedPtfxAsset("core")
RequestNamedPtfxAsset("core")
while not HasNamedPtfxAssetLoaded("core") do
Wait(1)
end
end

while true do
-- Handeling spreading of fires
Wait(1000)
if #scriptData.firePositionsX == 0 then
else
for i=1, #scriptData.firePositionsX, 1 do
local isFirePresent = GetNumberOfFiresInRange(scriptData.firePositionsX[i], scriptData.firePositionsY[i], scriptData.firePositionsZ[i], 1)

if isFirePresent ~= 0 then
--Deal with fire spreading
else
RemoveParticleFx(scriptData.particles[i], true)
end
end
end
end
end)

------------------------------ ------------------------------
Expand Down
46 changes: 39 additions & 7 deletions flowchart-c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ fireSpawnLocation (locations of fires, where will the first flame spawn?) - X(in
------------------------------ ------------------------------

Registers the command
Shows a notification (debug)
Assigns Variables
locates player
introduces the variable "nearestStation"
Expand Down Expand Up @@ -45,28 +44,61 @@ Registers the command
Recives back the sync (runs on all clients)
Finds a random number between 1 and the number of entities in the array "fireSpawnLocation"

Used for calls wich a vehicle:
Used for calls with a vehicle:
Does stuff to spawn car

A bunch of stuff to avoid crashing

Still figuring out what that does

If the type of fire is "1"
Spawns car
Starts fire under the engine (that's why fire is slightly away from car coords)

If the type of fire is anything else
Starts fire on location

Gets a random number
Half the times:
Spawns awsome looking particles1 (not acctual fire but still deals damage?)
Stores init in scriptData.particles // Spawns awsome looking particles1
Stores X of fire to scriptData.firePositions X
Stores Y of fire to scriptData.firePositions Y
Stores Z of fire to scriptData.firePositions Z
other half:
Spawns awsome looking particles2 (not acctual fire but still deals damage?)

Stores init in scriptData.particles // Spawns awsome looking particles2
Stores X of fire to scriptData.firePositions X
Stores Y of fire to scriptData.firePositions Y
Stores Z of fire to scriptData.firePositions Z
End
End

Registers the command
Sends the data over to the server which will send it back to every client to process on their own

Recives back the sync (runs on all clients)
For all fires stores in the variables file
Remove fire entity
Remove fire particles
end
end

Citizen thread

Still figuring out what that does

Always do
wait 1000ms
if no fires are stored
otherwise
introduces isFirePresent

if fire is present
otherwise
Remove fire particles
end
end
end
end
end

------------------------------ ------------------------------
------------------------------ Seperate functions ------------------------------
------------------------------ ------------------------------
Expand Down
11 changes: 10 additions & 1 deletion flowchart-s.txt
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
stuff to sync fire between clients (not done)
FIREMANAGER ---------
syncFire = Used to sync the /startFire command to all clients

removeFire = Used to sync the /stopFires command to all clients

POTATO ---------
syncedAlarm = Used to trigger the fire alarm in the fire stations on all clients

OTHERS // COMMANDS---------
fireAlarm = "Start the fire alarm" command
5 changes: 5 additions & 0 deletions flowchart-vars.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
firePositionsX = X position of fire
firePositionsY = Y position of fire
firePositionsZ = Z position of fire
fires = ini value of spawned fire intities
particles = ini value of spawned fire particles
12 changes: 0 additions & 12 deletions other firescript/__resource.lua

This file was deleted.

Loading

0 comments on commit 9871cdb

Please sign in to comment.