Skip to content

Commit

Permalink
add loadVoiceServer config option (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxshady authored Oct 24, 2023
1 parent f5c3fc7 commit 0aa1067
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ altv-server
altv-server.exe
altv-crash-handler
altv-crash-handler.exe
altv-voice-server.exe
modules/
data/
libnode.dll
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ Create a `.altvpkgrc.json` file in your root directory and add the following JSO

**Note:** The `loadJSV2Module` configuration allows you to include the experimental JavaScript V2 (JSV2) module when downloading binaries. Please be aware that as of the current release, the JSV2 module is exclusively available in the dev branch.

**Note** The `loadVoiceServer` configuration allows you to include [external voice server](https://docs.altv.mp/articles/external_voice_server.html) when downloading binaries.

```
{
"loadBytecodeModule": true,
"loadCSharpModule": true,
"loadJSV2Module": true
"loadJSV2Module": true,
"loadVoiceServer": true
}
```
19 changes: 17 additions & 2 deletions bin/altv-pkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const rootPath = process.cwd();
let platform = process.platform == 'win32' ? 'x64_win32' : 'x64_linux';
let branch = null;

const { loadBytecodeModule, loadCSharpModule, loadJSV2Module } = loadRuntimeConfig();
const { loadBytecodeModule, loadCSharpModule, loadJSV2Module, loadVoiceServer } = loadRuntimeConfig();

function authorizeDiscord() {
console.log(chalk.greenBright('===== Authorizing via Discord ====='));
Expand Down Expand Up @@ -212,8 +212,21 @@ async function start() {
linuxUpdates.push(`https://${CDN_ADDRESS}/js-module-v2/${branch}/x64_linux/update.json`);
windowsUpdates.push(`https://${CDN_ADDRESS}/js-module-v2/${branch}/x64_win32/update.json`);
}
}

if (loadVoiceServer) {
res = await axios.get(`https://${CDN_ADDRESS}/voice-server/${branch}/x64_linux/update.json`, { responseType: 'json', headers });
for ([file, hash] of Object.entries(res.data.hashList)) {
linuxFiles[file] = `https://${CDN_ADDRESS}/voice-server/${branch}/x64_linux/${file}`;
}

res = await axios.get(`https://${CDN_ADDRESS}/voice-server/${branch}/x64_win32/update.json`, { responseType: 'json', headers });
for ([file, hash] of Object.entries(res.data.hashList)) {
windowsFiles[file] = `https://${CDN_ADDRESS}/voice-server/${branch}/x64_win32/${file}`;
}

linuxUpdates.push(`https://${CDN_ADDRESS}/voice-server/${branch}/x64_linux/update.json`);
windowsUpdates.push(`https://${CDN_ADDRESS}/voice-server/${branch}/x64_win32/update.json`);
}

const [filesUpdate, filesToUse] = (platform == 'x64_win32')
Expand Down Expand Up @@ -334,6 +347,7 @@ function loadRuntimeConfig() {
let loadBytecodeModule = false;
let loadCSharpModule = false;
let loadJSV2Module = false;
let loadVoiceServer = false;

try {
const data = fs.readFileSync(`./${RC_FILE_NAME}`, { encoding: 'utf8' });
Expand All @@ -342,11 +356,12 @@ function loadRuntimeConfig() {
loadBytecodeModule = !!parsedData.loadBytecodeModule;
loadCSharpModule = !!parsedData.loadCSharpModule;
loadJSV2Module = !!parsedData.loadJSV2Module;
loadVoiceServer = !!parsedData.loadVoiceServer;
} catch (e) {
console.log(chalk.gray(`Configuration file '${RC_FILE_NAME}' could not be read. Continuing without...`));
}

return { loadBytecodeModule, loadCSharpModule, loadJSV2Module };
return { loadBytecodeModule, loadCSharpModule, loadJSV2Module, loadVoiceServer };
}

start();

0 comments on commit 0aa1067

Please sign in to comment.