Development
Use the available framework type definitions and extend the Aquiver server player class.
Type definitions
Integration notes
Available definitions
Some type definitions are still missing, but the definitions currently required by the module are included.
01 / 02
Extending Player class to access all methods
Extending Aquiver.ServerPlayer gives you access to the methods implemented by the class.
Configuration
Extend ServerPlayer
Create a custom player class and use the inherited server player methods.
TypeScript example
class MyPlayer extends Aquiver.ServerPlayer {
constructor(source: number | string) {
super(source);
this.addItem("bread", 1, {
QBCore: {
slot: 2,
metadata: {
yeeey: true
}
}
});
}
}
Configuration
Framework-specific addItem implementation
Example implementation from version 1.5; newer versions may differ.
Framework-specific addItem example (version 1.5)
/**
* This function adds an item.
* @param item
* @param amount
* @param extra Additional framework-specific arguments.
*/
addItem(
item: string,
amount: number,
extra?: {
QBCore?: { slot?: number; metadata?: Record<string, any> };
}
) {
switch (Config.Framework) {
case 'ESX_LEGACY': {
const Player = Frameworks.ESX.GetPlayerFromId(this.source);
Player.addInventoryItem(item, amount);
break;
}
case 'QBCORE': {
const Player = Frameworks.QBCore.Functions.GetPlayer(this.source);
Player.Functions.AddItem(item, amount, extra?.QBCore?.slot, extra?.QBCore?.metadata);
break;
}
case 'CUSTOM': {
globalThis.exports[GetCurrentResourceName()].addItem(this.source, item, amount);
break;
}
}
}