-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancements and Fixes: Improved Aging Logic, Menu UI, Database Updat…
…es, and More (#97) ## Changelog ### Fixed: - **Aging**: Animals will now only age once their condition has been reached. - **Ranch State Update**: Fixed issue where ranch was being updated incorrectly after a resource restart; `is_any_animals_out` now correctly updated. - **Server Events**: Removed duplicate server events. ### Improvements: - **VORP Utils**: Removed unnecessary VORP utilities. - **BCCUtils RPC**: Replaced with `bccutils` RPC for better performance and flexibility. - **Database Updates**: Added `dbupdater` to automatically insert new data into the database. - **MySQL Queries**: Updated to follow the latest oxmysql documentation. - **Versioning**: Added versioning to track updates and changes. - **Versioner Check**: Replaced release check with a check file for version control. - **Menu UI**: Improved menu elements for better visual presentation. - **Inventory Docs**: Updated to the latest VORP inventory documentation. ### TODO: - Finish implementing RPC. - Add additional checks for each task. - Finalize API integration.
- Loading branch information
1 parent
82e8897
commit ce644b4
Showing
35 changed files
with
1,467 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,35 @@ | ||
local agingActive = false | ||
---@param firstIteration boolean | ||
RegisterNetEvent('bcc-ranch:AgingTriggered', function(firstIteration, resetAging) | ||
if not firstIteration then | ||
if not agingActive then | ||
agingActive = true | ||
else | ||
agingActive = false | ||
end | ||
else --done as on first iteration it will always stop aging and restart it so we make a dif if for it | ||
if not agingActive then | ||
agingActive = true | ||
end | ||
end | ||
if resetAging then --done so we can allow the RanchData time to update before we start aging again (Used to sync when we buy new animals) | ||
agingActive = false | ||
Wait(1000) | ||
agingActive = true | ||
end | ||
end) | ||
RanchData = {} | ||
|
||
-- Cow Thread | ||
CreateThread(function() | ||
while true do | ||
if not agingActive or RanchData.cows ~= "true" or IsInMission then | ||
-- Check if aging is active and if we're not in a mission | ||
if not agingActive or IsInMission then | ||
Wait(2000) | ||
else | ||
Wait(Config.animalSetup.cows.ageTimer) | ||
TriggerServerEvent('bcc-ranch:IncreaseAnimalAge', RanchData.ranchid, 'cows', Config.animalSetup.cows.ageIncrease) | ||
end | ||
end | ||
end) | ||
|
||
-- Pig Thread | ||
CreateThread(function() | ||
while true do | ||
if not agingActive or RanchData.pigs ~= 'true' or IsInMission then | ||
Wait(2000) | ||
else | ||
Wait(Config.animalSetup.pigs.ageTimer) | ||
TriggerServerEvent('bcc-ranch:IncreaseAnimalAge', RanchData.ranchid, 'pigs', Config.animalSetup.pigs.ageIncrease) | ||
end | ||
end | ||
end) | ||
-- Loop through all animal types (cows, pigs, sheep, goats, chickens) | ||
for animalType, config in pairs(Config.animalSetup) do | ||
if RanchData[animalType] == "true" then | ||
devPrint(animalType .. " aging thread: Waiting for ageTimer") | ||
Wait(config.ageTimer) -- Wait for the specified timer for the current animal | ||
|
||
-- Sheep Thread | ||
CreateThread(function() | ||
while true do | ||
if not agingActive or RanchData.sheeps ~= "true" or IsInMission then | ||
Wait(2000) | ||
else | ||
Wait(Config.animalSetup.sheeps.ageTimer) | ||
TriggerServerEvent('bcc-ranch:IncreaseAnimalAge', RanchData.ranchid, 'sheeps', Config.animalSetup.sheeps.ageIncrease) | ||
-- Trigger the RPC to increase the animal age | ||
BccUtils.RPC:Call("bcc-ranch:IncreaseAnimalAge", { | ||
ranchId = RanchData.ranchid, | ||
animalType = animalType, | ||
incAmount = config.ageIncrease | ||
}, function(success) | ||
if success then | ||
devPrint("Successfully increased age for " .. animalType .. " in ranch: " .. RanchData.ranchid) | ||
else | ||
devPrint("Failed to increase age for " .. animalType .. " in ranch: " .. RanchData.ranchid) | ||
end | ||
end) | ||
end | ||
end | ||
end | ||
end) | ||
|
||
-- Goat Thread | ||
CreateThread(function() | ||
while true do | ||
if not agingActive or RanchData.goats ~= "true" or IsInMission then | ||
Wait(2000) | ||
else | ||
Wait(Config.animalSetup.goats.ageTimer) | ||
TriggerServerEvent('bcc-ranch:IncreaseAnimalAge', RanchData.ranchid, 'goats', Config.animalSetup.goats.ageIncrease) | ||
end | ||
-- Wait before checking again | ||
Wait(1000) -- Check again every second for any changes | ||
end | ||
end) | ||
|
||
-- Chicken Thread | ||
CreateThread(function() | ||
while true do | ||
if not agingActive or RanchData.chickens ~= "true" or IsInMission then | ||
Wait(2000) | ||
else | ||
Wait(Config.animalSetup.chickens.ageTimer) | ||
TriggerServerEvent('bcc-ranch:IncreaseAnimalAge', RanchData.ranchid, 'chickens', Config.animalSetup.chickens.ageIncrease) | ||
end | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.