Skip to content

Commit

Permalink
Baun Improvement
Browse files Browse the repository at this point in the history
Just starting to change for video capture
  • Loading branch information
DreamXZE committed Feb 23, 2024
1 parent 92b5633 commit aae568b
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 16 deletions.
50 changes: 50 additions & 0 deletions resources/[soz]/soz-core/src/client/job/baun/baun.cofe.provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { TargetFactory } from '../../target/target.factory';
import { JobType } from '@public/shared/job';
import { ServerEvent } from '../../../shared/event';

import { Once, OnceStep } from '../../../core/decorators/event';
import { Inject } from '../../../core/decorators/injectable';
import { Provider } from '../../../core/decorators/provider';
import { PlayerService } from '../../player/player.service';
import { ProgressService } from '../../progress.service';

@Provider()
export class BaunCofeProvider {
@Inject(TargetFactory)
private targetFactory: TargetFactory;

@Inject(PlayerService)
private playerService: PlayerService;

@Inject(ProgressService)
private progressService: ProgressService;

@Once(OnceStep.PlayerLoaded)
public setupBaunCraftZone() {
this.targetFactory.createForBoxZone(`baun:bahama:cofe:1`, {
center: [-1386.60, -605.19, 30.32],
length: 0.60,
width: 1.20,
heading: 211.43,
minZ: 30.32,
maxZ: 30.92,
}, [
{
label: 'Faire des cafés',
icon: 'c:food/cafe.png',
blackoutGlobal: true,
job: JobType.Baun,
canInteract: () => {
return this.playerService.isOnDuty();
},
action: () => {
this.makeCofe();
},
},
]);
}

async makeCofe() {
TriggerServerEvent(ServerEvent.BAUN_COFE);
}
}
3 changes: 2 additions & 1 deletion resources/[soz]/soz-core/src/client/job/baun/baun.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { Module } from '../../../core/decorators/module';
import { BaunCraftProvider } from './baun.craft.provider';
import { BaunProvider } from './baun.provider';
import { BaunResellProvider } from './baun.resell.provider';
import { BaunCofeProvider } from './baun.cofe.provider';

@Module({
providers: [BaunProvider, BaunCraftProvider, BaunResellProvider],
providers: [BaunProvider, BaunCraftProvider, BaunResellProvider, BaunCofeProvider],
})
export class BaunModule {}
92 changes: 92 additions & 0 deletions resources/[soz]/soz-core/src/server/job/baun/baun.cofe.provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { OnEvent } from '@core/decorators/event';
import { Inject } from '@core/decorators/injectable';
import { Provider } from '@core/decorators/provider';
import { FieldProvider } from '@public/server/farm/field.provider';
import { InventoryManager } from '@public/server/inventory/inventory.manager';
import { ItemService } from '@public/server/item/item.service';
import { Notifier } from '@public/server/notifier';
import { ProgressService } from '@public/server/player/progress.service';
import { ServerEvent } from '@public/shared/event';

const EasterHarvestDrop: Record<string, number> = {
golden_egg: 0.01,
chocolat_egg: 0.5,
chocolat_milk_egg: 1,
};

@Provider()
export class BaunCofeProvider {
@Inject(ProgressService)
private progressService: ProgressService;

@Inject(InventoryManager)
private inventoryManager: InventoryManager;

@Inject(FieldProvider)
private fieldService: FieldProvider;

@Inject(ItemService)
private itemService: ItemService;

@Inject(Notifier)
private notifier: Notifier;

@OnEvent(ServerEvent.BAUN_COFE)
async onMakeCofe(source: number) {
this.notifier.notify(source, 'Vous ~g~commencez~s~ à faire du café.');

while (await this.doMakeCofe(source)) {
/* empty */
}
this.notifier.notify(source, 'Vous avez ~r~terminé~s~ de faire du café.', 'success');
}

async doMakeCofe(source: number) {
const { completed } = await this.progressService.progress(
source,
'dispenser_buy',
'Vous faites du café.',
1000,
{
dictionary: 'mini@sprunk',
name: 'plyr_buy_drink_pt1',
flags: 16,
options: {
repeat: true,
},
},
{
useAnimationService: true,
disableMovement: true,
disableCarMovement: false,
disableMouse: false,
disableCombat: true,
}
);
if (!completed) {
return false;
}

if (!this.inventoryManager.canCarryItem(source, 'coffee', 1)) {
this.notifier.notify(
source,
`Vous ne possédez pas suffisamment de place dans votre inventaire pour faire un café.`
);
return false;
}

const { success, reason } = this.inventoryManager.addItemToInventory(source, 'coffee', 1);
if (success) {
this.notifier.notify(source, `Vous avez récolté un ~b~${this.itemService.getItem('coffee').label}.`);
} else if (reason == 'invalid_weight') {
this.notifier.notify(source, 'Vos poches sont pleines...', 'error');
return false;
} else {
this.notifier.notify(source, `Il y a eu une erreur: ${'coffee'} ${reason}`, 'error');
return false;
}
return true;
}
}


3 changes: 2 additions & 1 deletion resources/[soz]/soz-core/src/server/job/baun/baun.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Module } from '../../../core/decorators/module';
import { BaunResellProvider } from './baun.resell.provider';
import { BaunCofeProvider } from './baun.cofe.provider';

@Module({
providers: [BaunResellProvider],
providers: [BaunResellProvider, BaunCofeProvider],
})
export class BaunModule {}
1 change: 1 addition & 0 deletions resources/[soz]/soz-core/src/shared/event/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export enum ServerEvent {
BASE_CHANGE_VEHICLE_SEAT = 'baseevents:changeVehicleSeat',

BAUN_RESELL = 'soz-core:server:job:baun:resell',
BAUN_COFE = 'soz-core:server:job:baun:cofe',

BENNYS_ESTIMATE_VEHICLE = 'soz-core:server:job:bennys:estimate-vehicle',
BENNYS_SELL_VEHICLE = 'soz-core:server:job:bennys:sell-vehicle',
Expand Down
18 changes: 9 additions & 9 deletions resources/[soz]/soz-inventory/html/assets/index.js

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions resources/[soz]/soz-jobs/client/jobs/baun/_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,3 @@ RegisterNetEvent("soz-jobs:client:baun:createCocktailBox", function()
QBCore.Functions.TriggerCallback("soz-jobs:server:baun:createCocktailBox", function()
end)
end)

RegisterNetEvent("soz-jobs:client:baun:createIceCubes", function()
QBCore.Functions.TriggerCallback("soz-jobs:server:baun:createIceCubes", function()
end)
end)
37 changes: 37 additions & 0 deletions resources/[soz]/soz-jobs/client/jobs/baun/icecube.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
RegisterNetEvent("soz-jobs:client:baun:createIceCubes", function(data)
QBCore.Functions.TriggerCallback("soz-jobs:server:baun:can-createIceCubes", function(canRestock)
if canRestock then
createIceCubes(data)
end
end, data.item)
end)

function createIceCubes(data)
local action_message = "Vous commencez à fabriquer des glaçons."
local stopped_message = "Vous avez arrêté de fabriquer des glaçons."
local finished_message = "Vous avez terminé de fabriquer des glaçons."
QBCore.Functions.Progressbar("restock", action_message, BaunConfig.Durations.Icecube, false, true,
{
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {animDict = "rcmextreme3", anim = "idle", flags = 1}, {}, {}, function()
QBCore.Functions.TriggerCallback("soz-jobs:server:baun:createIceCubes", function(success, reason)
if success then
TriggerEvent("soz-jobs:client:baun:createIceCubes", data)
else
if reason == "missing_ingredient" then
exports["soz-core"]:DrawNotification(finished_message)
elseif reason == "invalid_weight" then
exports["soz-core"]:DrawNotification("Le stockage est plein... ", "error")
else
exports["soz-core"]:DrawNotification(string.format("Une erreur est survenue: %s.", reason), "error")
end
end
end, data.storage, data.item)
end, function()
exports["soz-core"]:DrawNotification(stopped_message)
end)
end

1 change: 1 addition & 0 deletions resources/[soz]/soz-jobs/config/jobs/baun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,5 @@ BaunConfig.Durations = {
Crafting = 4000, -- in ms
Restocking = 4000, -- in ms
Harvesting = 2000, -- in ms
Icecube = 1000, -- in ms
}
6 changes: 6 additions & 0 deletions resources/[soz]/soz-jobs/server/jobs/baun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ QBCore.Functions.CreateCallback("soz-jobs:server:baun:createCocktailBox", functi
end)
end)

QBCore.Functions.CreateCallback("soz-jobs:server:baun:can-createIceCubes", function(source, cb)
local canCreateIceCubes = exports["soz-inventory"]:GetItem(source, "water_bottle", nil, true) > 0
cb(canCreateIceCubes)
end)


QBCore.Functions.CreateCallback("soz-jobs:server:baun:createIceCubes", function(source, cb)
local player = QBCore.Functions.GetPlayer(source)
local bottleToRemove = 1
Expand Down

0 comments on commit aae568b

Please sign in to comment.