Skip to content

Commit

Permalink
Merge pull request #787 from bitpredator/dev
Browse files Browse the repository at this point in the history
refactor:  converted esx_society to bpt_society
  • Loading branch information
bitpredator authored Aug 12, 2024
2 parents a37ea79 + 4b276ab commit ca6f6ee
Show file tree
Hide file tree
Showing 75 changed files with 858 additions and 891 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function OpenAmbulanceActionsMenu()
if element.value == "cloakroom" then
OpenCloakroomMenu()
elseif element.value == "boss_actions" then
TriggerEvent("esx_society:openBossMenu", "ambulance", function(_, menu)
TriggerEvent("bpt_society:openBossMenu", "ambulance", function(_, menu)
menu.close()
end, { wash = false })
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Config.Locale = "it"
Config.EarlyRespawnTimer = 60000 * 1 -- time til respawn is available
Config.BleedoutTimer = 60000 * 10 -- time til the player bleeds out

Config.EnablePlayerManagement = true -- Enable society managing (If you are using esx_society).
Config.EnablePlayerManagement = true -- Enable society managing (If you are using bpt_society).

Config.RemoveWeaponsAfterRPDeath = false
Config.RemoveCashAfterRPDeath = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local playersHealing, deadPlayers = {}, {}

ESX = exports["es_extended"]:getSharedObject()

TriggerEvent("esx_society:registerSociety", "ambulance", "Ambulance", "society_ambulance", "society_ambulance", "society_ambulance", {
TriggerEvent("bpt_society:registerSociety", "ambulance", "Ambulance", "society_ambulance", "society_ambulance", "society_ambulance", {
type = "public",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function OpenVehicleSpawnerMenu()
}

if Config.EnableSocietyOwnedVehicles then
ESX.TriggerServerCallback("esx_society:getVehiclesInGarage", function(vehicles)
ESX.TriggerServerCallback("bpt_society:getVehiclesInGarage", function(vehicles)
if #vehicles == 0 then
ESX.ShowNotification(TranslateCap("empty_garage"))
return
Expand Down Expand Up @@ -103,7 +103,7 @@ function OpenVehicleSpawnerMenu()
ESX.TriggerServerCallback("bpt_ammujob:SpawnVehicle", function()
return
end, vehicleProps.model, vehicleProps)
TriggerServerEvent("esx_society:removeVehicleFromGarage", "ammu", vehicleProps)
TriggerServerEvent("bpt_society:removeVehicleFromGarage", "ammu", vehicleProps)
end, function()
CurrentAction = "vehicle_spawner"
CurrentActionMsg = TranslateCap("spawner_prompt")
Expand Down Expand Up @@ -150,7 +150,7 @@ end
function DeleteJobVehicle()
if Config.EnableSocietyOwnedVehicles then
local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle)
TriggerServerEvent("esx_society:putVehicleInGarage", "ammu", vehicleProps)
TriggerServerEvent("bpt_society:putVehicleInGarage", "ammu", vehicleProps)
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
else
if IsInAuthorizedVehicle() then
Expand Down Expand Up @@ -189,7 +189,7 @@ function OpenAmmuActionsMenu()
elseif element.value == "get_stock" then
OpenGetStocksMenu()
elseif element.value == "boss_actions" then
TriggerEvent("esx_society:openBossMenu", "ammu", function(_, menu)
TriggerEvent("bpt_society:openBossMenu", "ammu", function(_, menu)
menu.close()
end)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TriggerEvent("esx_society:registerSociety", "ammu", "Ammu", "society_ammu", "society_ammu", "society_ammu", {
TriggerEvent("bpt_society:registerSociety", "ammu", "Ammu", "society_ammu", "society_ammu", "society_ammu", {
type = "public",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function OpenVehicleSpawnerMenu()
}

if Config.EnableSocietyOwnedVehicles then
ESX.TriggerServerCallback("esx_society:getVehiclesInGarage", function(vehicles)
ESX.TriggerServerCallback("bpt_society:getVehiclesInGarage", function(vehicles)
if #vehicles == 0 then
ESX.ShowNotification(TranslateCap("empty_garage"))
return
Expand Down Expand Up @@ -103,7 +103,7 @@ function OpenVehicleSpawnerMenu()
ESX.TriggerServerCallback("bpt_bakerjob:SpawnVehicle", function()
return
end, vehicleProps.model, vehicleProps)
TriggerServerEvent("esx_society:removeVehicleFromGarage", "baker", vehicleProps)
TriggerServerEvent("bpt_society:removeVehicleFromGarage", "baker", vehicleProps)
end, function()
CurrentAction = "vehicle_spawner"
CurrentActionMsg = TranslateCap("spawner_prompt")
Expand Down Expand Up @@ -150,7 +150,7 @@ end
function DeleteJobVehicle()
if Config.EnableSocietyOwnedVehicles then
local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle)
TriggerServerEvent("esx_society:putVehicleInGarage", "baker", vehicleProps)
TriggerServerEvent("bpt_society:putVehicleInGarage", "baker", vehicleProps)
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
else
if IsInAuthorizedVehicle() then
Expand Down Expand Up @@ -185,7 +185,7 @@ function OpenbakerActionsMenu()
elseif element.value == "get_stock" then
OpenGetStocksMenu()
elseif element.value == "boss_actions" then
TriggerEvent("esx_society:openBossMenu", "baker", function(_, menu)
TriggerEvent("bpt_society:openBossMenu", "baker", function(_, menu)
menu.close()
end)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TriggerEvent("esx_society:registerSociety", "baker", "Baker", "society_baker", "society_baker", "society_baker", {
TriggerEvent("bpt_society:registerSociety", "baker", "Baker", "society_baker", "society_baker", "society_baker", {
type = "public",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function OpenballasActionsMenu()
elseif element.value == "get_stock" then
OpenGetStocksMenu()
elseif element.value == "boss_actions" then
TriggerEvent("esx_society:openBossMenu", "ballas", function(_, menu)
TriggerEvent("bpt_society:openBossMenu", "ballas", function(_, menu)
menu.close()
end)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TriggerEvent("esx_society:registerSociety", "ballas", "ballas", "society_ballas", "society_ballas", "society_ballas", {
TriggerEvent("bpt_society:registerSociety", "ballas", "ballas", "society_ballas", "society_ballas", "society_ballas", {
type = "public",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function OpenVehicleSpawnerMenu()
}

if Config.EnableSocietyOwnedVehicles then
ESX.TriggerServerCallback("esx_society:getVehiclesInGarage", function(vehicles)
ESX.TriggerServerCallback("bpt_society:getVehiclesInGarage", function(vehicles)
if #vehicles == 0 then
ESX.ShowNotification(TranslateCap("empty_garage"))
return
Expand Down Expand Up @@ -103,7 +103,7 @@ function OpenVehicleSpawnerMenu()
ESX.TriggerServerCallback("bpt_fishermanjob:SpawnVehicle", function()
return
end, vehicleProps.model, vehicleProps)
TriggerServerEvent("esx_society:removeVehicleFromGarage", "fisherman", vehicleProps)
TriggerServerEvent("bpt_society:removeVehicleFromGarage", "fisherman", vehicleProps)
end, function()
CurrentAction = "vehicle_spawner"
CurrentActionMsg = TranslateCap("spawner_prompt")
Expand Down Expand Up @@ -150,7 +150,7 @@ end
function DeleteJobVehicle()
if Config.EnableSocietyOwnedVehicles then
local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle)
TriggerServerEvent("esx_society:putVehicleInGarage", "fisherman", vehicleProps)
TriggerServerEvent("bpt_society:putVehicleInGarage", "fisherman", vehicleProps)
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
else
if IsInAuthorizedVehicle() then
Expand Down Expand Up @@ -185,7 +185,7 @@ function OpenFishermanActionsMenu()
elseif element.value == "get_stock" then
OpenGetStocksMenu()
elseif element.value == "boss_actions" then
TriggerEvent("esx_society:openBossMenu", "fisherman", function(_, menu)
TriggerEvent("bpt_society:openBossMenu", "fisherman", function(_, menu)
menu.close()
end)
end
Expand Down
128 changes: 58 additions & 70 deletions server-data/resources/[bpt_addons]/bpt_fisherman/server/main.lua
Original file line number Diff line number Diff line change
@@ -1,92 +1,80 @@
TriggerEvent(
"esx_society:registerSociety",
"fisherman",
"Fisherman",
"society_fisherman",
"society_fisherman",
"society_fisherman",
{
type = "public",
}
)
TriggerEvent("bpt_society:registerSociety", "fisherman", "Fisherman", "society_fisherman", "society_fisherman", "society_fisherman", {
type = "public",
})

if Config.MaxInService ~= -1 then
TriggerEvent("esx_service:activateService", "fisherman", Config.MaxInService)
TriggerEvent("esx_service:activateService", "fisherman", Config.MaxInService)
end

ESX.RegisterServerCallback("bpt_fishermanjob:SpawnVehicle", function(source, cb, model, props)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)

if xPlayer.job.name ~= "fisherman" then
print(("[^3WARNING^7] Player ^5%s^7 attempted to Exploit Vehicle Spawing!!"):format(source))
return
end
local SpawnPoint = vector3(
Config.Zones.VehicleSpawnPoint.Pos.x,
Config.Zones.VehicleSpawnPoint.Pos.y,
Config.Zones.VehicleSpawnPoint.Pos.z
)
ESX.OneSync.SpawnVehicle(joaat(model), SpawnPoint, Config.Zones.VehicleSpawnPoint.Heading, props, function()
local vehicle = NetworkGetEntityFromNetworkId()
while GetVehicleNumberPlateText(vehicle) ~= props.plate do
Wait(0)
end
TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1)
end)
cb()
if xPlayer.job.name ~= "fisherman" then
print(("[^3WARNING^7] Player ^5%s^7 attempted to Exploit Vehicle Spawing!!"):format(source))
return
end
local SpawnPoint = vector3(Config.Zones.VehicleSpawnPoint.Pos.x, Config.Zones.VehicleSpawnPoint.Pos.y, Config.Zones.VehicleSpawnPoint.Pos.z)
ESX.OneSync.SpawnVehicle(joaat(model), SpawnPoint, Config.Zones.VehicleSpawnPoint.Heading, props, function()
local vehicle = NetworkGetEntityFromNetworkId()
while GetVehicleNumberPlateText(vehicle) ~= props.plate do
Wait(0)
end
TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1)
end)
cb()
end)

RegisterNetEvent("bpt_fishermanjob:getStockItem")
AddEventHandler("bpt_fishermanjob:getStockItem", function(itemName, count)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)

if xPlayer.job.name == "fisherman" then
TriggerEvent("bpt_addoninventory:getSharedInventory", "society_fisherman", function(inventory)
local item = inventory.getItem(itemName)
if xPlayer.job.name == "fisherman" then
TriggerEvent("bpt_addoninventory:getSharedInventory", "society_fisherman", function(inventory)
local item = inventory.getItem(itemName)

-- is there enough in the society?
if count > 0 and item.count >= count then
-- can the player carry the said amount of x item?
if xPlayer.canCarryItem(itemName, count) then
inventory.removeItem(itemName, count)
xPlayer.addInventoryItem(itemName, count)
xPlayer.showNotification(TranslateCap("have_withdrawn", count, item.label))
else
xPlayer.showNotification(TranslateCap("player_cannot_hold"))
end
else
xPlayer.showNotification(TranslateCap("quantity_invalid"))
end
end)
else
print(("[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_fishermanjob:getStockItem^7 (cheating)"):format(source))
end
-- is there enough in the society?
if count > 0 and item.count >= count then
-- can the player carry the said amount of x item?
if xPlayer.canCarryItem(itemName, count) then
inventory.removeItem(itemName, count)
xPlayer.addInventoryItem(itemName, count)
xPlayer.showNotification(TranslateCap("have_withdrawn", count, item.label))
else
xPlayer.showNotification(TranslateCap("player_cannot_hold"))
end
else
xPlayer.showNotification(TranslateCap("quantity_invalid"))
end
end)
else
print(("[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_fishermanjob:getStockItem^7 (cheating)"):format(source))
end
end)

ESX.RegisterServerCallback("bpt_fishermanjob:getStockItems", function(_, cb)
TriggerEvent("bpt_addoninventory:getSharedInventory", "society_fisherman", function(inventory)
cb(inventory.items)
end)
TriggerEvent("bpt_addoninventory:getSharedInventory", "society_fisherman", function(inventory)
cb(inventory.items)
end)
end)

RegisterNetEvent("bpt_fishermanjob:putStockItems")
AddEventHandler("bpt_fishermanjob:putStockItems", function(itemName, count)
local xPlayer = ESX.GetPlayerFromId(source)
local sourceItem = xPlayer.getInventoryItem(itemName)
local xPlayer = ESX.GetPlayerFromId(source)
local sourceItem = xPlayer.getInventoryItem(itemName)

if xPlayer.job.name == "fisherman" then
TriggerEvent("bpt_addoninventory:getSharedInventory", "society_fisherman", function(inventory)
local item = inventory.getItem(itemName)
if xPlayer.job.name == "fisherman" then
TriggerEvent("bpt_addoninventory:getSharedInventory", "society_fisherman", function(inventory)
local item = inventory.getItem(itemName)

if sourceItem.count >= count and count > 0 then
xPlayer.removeInventoryItem(itemName, count)
inventory.addItem(itemName, count)
xPlayer.showNotification(TranslateCap("have_deposited", count, item.label))
else
xPlayer.showNotification(TranslateCap("quantity_invalid"))
end
end)
else
print(("[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_fishermanjob:putStockItems^7 (cheating)"):format(source))
end
if sourceItem.count >= count and count > 0 then
xPlayer.removeInventoryItem(itemName, count)
inventory.addItem(itemName, count)
xPlayer.showNotification(TranslateCap("have_deposited", count, item.label))
else
xPlayer.showNotification(TranslateCap("quantity_invalid"))
end
end)
else
print(("[^3WARNING^7] Player ^5%s^7 attempted ^5bpt_fishermanjob:putStockItems^7 (cheating)"):format(source))
end
end)
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function OpenVehicleSpawnerMenu()
}

if Config.EnableSocietyOwnedVehicles then
ESX.TriggerServerCallback("esx_society:getVehiclesInGarage", function(vehicles)
ESX.TriggerServerCallback("bpt_society:getVehiclesInGarage", function(vehicles)
if #vehicles == 0 then
ESX.ShowNotification(TranslateCap("empty_garage"))
return
Expand Down Expand Up @@ -103,7 +103,7 @@ function OpenVehicleSpawnerMenu()
ESX.TriggerServerCallback("bpt_importjob:SpawnVehicle", function()
return
end, vehicleProps.model, vehicleProps)
TriggerServerEvent("esx_society:removeVehicleFromGarage", "import", vehicleProps)
TriggerServerEvent("bpt_society:removeVehicleFromGarage", "import", vehicleProps)
end, function()
CurrentAction = "vehicle_spawner"
CurrentActionMsg = TranslateCap("spawner_prompt")
Expand Down Expand Up @@ -150,7 +150,7 @@ end
function DeleteJobVehicle()
if Config.EnableSocietyOwnedVehicles then
local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle)
TriggerServerEvent("esx_society:putVehicleInGarage", "import", vehicleProps)
TriggerServerEvent("bpt_society:putVehicleInGarage", "import", vehicleProps)
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
else
if IsInAuthorizedVehicle() then
Expand Down Expand Up @@ -189,7 +189,7 @@ function OpenImportActionsMenu()
elseif element.value == "get_stock" then
OpenGetStocksMenu()
elseif element.value == "boss_actions" then
TriggerEvent("esx_society:openBossMenu", "import", function(_, menu)
TriggerEvent("bpt_society:openBossMenu", "import", function(_, menu)
menu.close()
end)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TriggerEvent("esx_society:registerSociety", "import", "Import", "society_import", "society_import", "society_import", {
TriggerEvent("bpt_society:registerSociety", "import", "Import", "society_import", "society_import", "society_import", {
type = "public",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function OpenMechanicActionsMenu()
{ unselectable = true, icon = "fas fa-car", title = TranslateCap("service_vehicle") },
}

ESX.TriggerServerCallback("esx_society:getVehiclesInGarage", function(vehicles)
ESX.TriggerServerCallback("bpt_society:getVehiclesInGarage", function(vehicles)
for i = 1, #vehicles, 1 do
elements2[#elements2 + 1] = {
icon = "fas fa-car",
Expand All @@ -94,7 +94,7 @@ function OpenMechanicActionsMenu()
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
end)

TriggerServerEvent("esx_society:removeVehicleFromGarage", "mechanic", vehicleProps)
TriggerServerEvent("bpt_society:removeVehicleFromGarage", "mechanic", vehicleProps)
end)
end, "mechanic")
else
Expand Down Expand Up @@ -156,7 +156,7 @@ function OpenMechanicActionsMenu()
elseif element.value == "get_stock" then
OpenGetStocksMenu()
elseif element.value == "boss_actions" then
TriggerEvent("esx_society:openBossMenu", "mechanic", function()
TriggerEvent("bpt_society:openBossMenu", "mechanic", function()
ESX.CloseContext()
end)
end
Expand Down Expand Up @@ -702,7 +702,7 @@ CreateThread(function()
elseif CurrentAction == "delete_vehicle" then
if Config.EnableSocietyOwnedVehicles then
local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle)
TriggerServerEvent("esx_society:putVehicleInGarage", "mechanic", vehicleProps)
TriggerServerEvent("bpt_society:putVehicleInGarage", "mechanic", vehicleProps)
else
local entityModel = GetEntityModel(CurrentActionData.vehicle)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ server_scripts({

dependencies({
"es_extended",
"esx_society",
"bpt_society",
"bpt_billing",
})
Loading

0 comments on commit ca6f6ee

Please sign in to comment.