-
-
Notifications
You must be signed in to change notification settings - Fork 19
How to add settings to a pp counter
cyperdark edited this page May 5, 2024
·
5 revisions
- Download this file and put to your counter folder
- Next step add
type="module"
to your script tag. Example: link - Now we can import script and have autocomplete, add this line to your script file. Example: link
import WebSocketManager from 'PATH_TO_DOWNLOADED_SCRIPT';
// example
import WebSocketManager from './js/socket.js';
- After that we can initialize out websocket thing, to receive ingame data, or counter settings
const socket = new WebSocketManager('127.0.0.1:24050');
- Okay, now we can add code to listen for commands response, such as
getSettings
// Listen to command updates
socket.commands((data) => {
try {
const { command, message } = data;
// get updates for "getSettings" command
if (command == 'getSettings') {
console.log(command, message); // print out settings for debug
};
} catch (error) {
console.log(error);
};
});
- So, once settings will be updated in dashboard, we will receive realtime updates. But we also want to get settings on startup, to do so, we need to add this line of code somewhere (you need to call it only once)
window.COUNTER_PATH WILL WORK ONLY IF YOU OPEN COUNTER VIA URL LIKE THIS: http://127.0.0.1:24050/quickstart/
socket.sendCommand('getSettings', encodeURI(window.COUNTER_PATH));
I hope thats all you need to setup it, if you have any questions feel free to ask them in discord: link
- First of all download tosu
- And open dashboard, you can find url in tosu console:
- Enable DevMode:
- Click this button to start creating/editing settings
- Here you can add variety off settings, and implement them in your pp counter
- You should always specify uniqueID, you'll use it to get it inside pp counter
- After you added options, click "Update settings"