-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just starting to change for video capture
- Loading branch information
Showing
10 changed files
with
200 additions
and
16 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
resources/[soz]/soz-core/src/client/job/baun/baun.cofe.provider.ts
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 |
---|---|---|
@@ -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); | ||
} | ||
} |
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
92 changes: 92 additions & 0 deletions
92
resources/[soz]/soz-core/src/server/job/baun/baun.cofe.provider.ts
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 |
---|---|---|
@@ -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; | ||
} | ||
} | ||
|
||
|
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,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 {} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -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 | ||
|
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