-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: useWeapon, useState, some sync stuff, saving stuff, etc.
- Loading branch information
Showing
25 changed files
with
1,079 additions
and
196 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
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,17 @@ | ||
# Weapon | ||
|
||
Used to synchronize or apply weapons to a player. | ||
|
||
```ts | ||
import { useRebar } from '@Server/index.js'; | ||
|
||
const Rebar = useRebar(); | ||
|
||
const playerState = Rebar.player.useState(somePlayer); | ||
|
||
// Use character document for weapons | ||
playerState.sync(); | ||
|
||
// Override and apply some state to a player | ||
playerWeapons.apply({ pos: alt.Vector3.zero }); | ||
``` |
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,44 @@ | ||
# Weapon | ||
|
||
Used to synchronize or apply weapons to a player. | ||
|
||
```ts | ||
import { useRebar } from '@Server/index.js'; | ||
|
||
const Rebar = useRebar(); | ||
|
||
const playerWeapons = Rebar.player.useWeapon(somePlayer); | ||
|
||
// Use character document for weapons | ||
playerWeapons.sync(); | ||
|
||
// Save weapons & ammo | ||
await playerWeapons.save(); | ||
|
||
// Save just ammo | ||
await playerWeapons.saveAmmo(); | ||
|
||
// Add a weapon, and save to the database, and re-apply weapons | ||
await playerWeapons.add('WEAPON_MINIGUN', 100); | ||
|
||
// Add ammo for specific gun | ||
await playerWeapons.addAmmo('WEAPON_MINIGUN', 100); | ||
|
||
// Clear all weapons & ammo | ||
await playerWeapons.clear(); | ||
|
||
// Remove a weapon and all ammo for the weapon | ||
await playerWeapons.clearWeapon('WEAPON_MINIGUN'); | ||
|
||
// Override and apply weapons to a player | ||
const weapons = [ | ||
{ hash: alt.hash('WEAPON_MINIGUN'), components: [], tintIndex: 0 }, | ||
{ hash: alt.hash('WEAPON_RPG'), components: [], tintIndex: 0 }, | ||
]; | ||
const ammo = { | ||
[alt.hash('WEAPON_MINIGUN')]: 999, | ||
[alt.hash('WEAPON_RPG')]: 5, | ||
}; | ||
|
||
playerWeapons.apply(weapons, ammo); | ||
``` |
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,27 @@ | ||
# useVehicle | ||
|
||
Used to create a new vehicle document, repair vehicles, apply vehicle documents, etc. | ||
|
||
```ts | ||
import { useRebar } from '@Server/index.js'; | ||
|
||
const Rebar = useRebar(); | ||
|
||
// Used to apply mods, health, etc. to a vehicle if it has a document bound | ||
Rebar.vehicle.useVehicle(vehicle).sync(); | ||
|
||
// Use a document template to any given vehicle, does not save data | ||
Rebar.vehicle.useVehicle(vehicle).apply({ pos: new alt.Vector3(0, 0, 0) }); | ||
|
||
// Save all current damage, position, rotation etc. | ||
// This does not create a new document for the given vehicle | ||
Rebar.vehicle.useVehicle(vehicle).save(); | ||
|
||
// Correctly repairs the vehicle and returns the new vehicle instance | ||
// Players will be removed from the vehicle on repair | ||
await Rebar.vehicle.useVehicle(vehicle).repair(); | ||
|
||
// Creating a vehicle and assigning it to a character id, or some other identifier | ||
const newVehicle = new alt.Vehicle('infernus', alt.Vector3.zero, alt.Vector3.zero); | ||
const document = await Rebar.vehicle.useVehicle(newVehicle).create(someCharacterIdOrSomethingElse); | ||
``` |
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
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.