-
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.
- Loading branch information
Showing
6 changed files
with
158 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Console Commands | ||
|
||
Console commands are commands that can be ran by opening your client-side `F8` console menu and typing a command. | ||
|
||
```sh | ||
pos # Get local player position | ||
floorpos # Get floor position at local player position | ||
vehpos # Get vehicle position | ||
rot # Get local player rotation | ||
vehrot # Get vehicle rotation | ||
dimension # Get local player dimension | ||
weapons # Get local player equipped weapon hashes | ||
weapon # Get local player weapon | ||
id # Get local player id | ||
remoteid # Get local player remote id | ||
resources # Get loaded resources | ||
ping # Get local player ping | ||
fps # Get local player fps | ||
debug #Check if debug is on | ||
players # Get closest players | ||
objects # Get closest objects | ||
entities # Get closeset entities (Like virtual entities) | ||
vehicles # Get closest vehicles | ||
``` |
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,3 @@ | ||
expanded: true | ||
label: 'Utilities' | ||
order: -1001 |
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,3 @@ | ||
expanded: false | ||
label: 'Composables' | ||
order: -1000 |
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,124 @@ | ||
import * as alt from 'alt-client'; | ||
import { distance2d } from '../../shared/utility/vector.js'; | ||
|
||
const Commands = { | ||
pos: () => { | ||
return alt.Player.local.pos; | ||
}, | ||
floorpos: () => { | ||
return alt.Player.local.pos.sub(0, 0, 1); | ||
}, | ||
vehpos: () => { | ||
return alt.Player.local.vehicle ? alt.Player.local.vehicle.pos : 'Not in a vehicle.'; | ||
}, | ||
rot: () => { | ||
return alt.Player.local.rot; | ||
}, | ||
vehrot: () => { | ||
return alt.Player.local.vehicle ? alt.Player.local.vehicle.rot : 'Not in a vehicle.'; | ||
}, | ||
dimension: () => { | ||
return alt.Player.local.dimension; | ||
}, | ||
weapons: () => { | ||
return alt.Player.local.weapons; | ||
}, | ||
weapon: () => { | ||
return alt.Player.local.currentWeapon; | ||
}, | ||
id: () => { | ||
return alt.Player.local.id; | ||
}, | ||
remoteid: () => { | ||
return alt.Player.local.remoteID; | ||
}, | ||
resources: () => { | ||
if (!alt.debug) { | ||
return 'Unavailable'; | ||
} | ||
|
||
return alt.getAllResources(); | ||
}, | ||
ping: () => { | ||
return alt.getPing(); | ||
}, | ||
fps: () => { | ||
return alt.getFps(); | ||
}, | ||
debug: () => { | ||
return alt.debug; | ||
}, | ||
players: () => { | ||
if (!alt.debug) { | ||
return 'Unavailable'; | ||
} | ||
|
||
return alt.Player.all.map((x) => { | ||
const dist = distance2d(alt.Player.local.pos, x.pos); | ||
return { id: x.id, dimension: x.dimension, dist, pos: x.pos }; | ||
}); | ||
}, | ||
objects: () => { | ||
if (!alt.debug) { | ||
return 'Unavailable'; | ||
} | ||
|
||
return alt.Object.all.map((x) => { | ||
const dist = distance2d(alt.Player.local.pos, x.pos); | ||
return { id: x.id, dimension: x.dimension, dist, pos: x.pos, model: x.model }; | ||
}); | ||
}, | ||
entities: () => { | ||
if (!alt.debug) { | ||
return 'Unavailable'; | ||
} | ||
|
||
return JSON.stringify( | ||
alt.VirtualEntity.all.map((x) => { | ||
const dist = distance2d(alt.Player.local.pos, x.pos); | ||
const keys = x.getStreamSyncedMetaKeys(); | ||
|
||
const data = {}; | ||
for (let key of keys) { | ||
data[key] = x.getStreamSyncedMeta(key); | ||
} | ||
|
||
return { id: x.id, dimension: x.dimension, dist, pos: x.pos, data }; | ||
}), | ||
null, | ||
'\t' | ||
); | ||
}, | ||
vehicles: () => { | ||
if (!alt.debug) { | ||
return 'Unavailable'; | ||
} | ||
|
||
return alt.Vehicle.all.map((x) => { | ||
const dist = distance2d(alt.Player.local.pos, x.pos); | ||
return { id: x.id, dimension: x.dimension, dist, pos: x.pos, model: x.model }; | ||
}); | ||
}, | ||
}; | ||
|
||
function handleConsoleCommand(name: string, ...args: string[]) { | ||
name = name.toLowerCase(); | ||
if (!Commands[name]) { | ||
alt.log(`That command does not exist.`); | ||
alt.log(`Here are the supported commands:`); | ||
for (let key of Object.keys(Commands)) { | ||
alt.log(key); | ||
} | ||
return; | ||
} | ||
|
||
const result = Commands[name](...args); | ||
if (!result) { | ||
return; | ||
} | ||
|
||
alt.log(`${name} - Command Result`); | ||
alt.log(result); | ||
} | ||
|
||
alt.on('consoleCommand', handleConsoleCommand); |
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