Skip to content

How to add settings to a pp counter

cyperdark edited this page May 5, 2024 · 5 revisions

First of all you need to have tosu above 2.6.0 version


Developers guide

  1. Download this file and put to your counter folder
  2. Next step add type="module" to your script tag. Example: link
  3. 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';

  1. After that we can initialize out websocket thing, to receive ingame data, or counter settings
const socket = new WebSocketManager('127.0.0.1:24050');

  1. 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);
  };
});

  1. 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



How to add new settings

  1. First of all download tosu
  2. And open dashboard, you can find url in tosu console:

1714853982_Wk8286GH6L

  1. Enable DevMode:

1714927056_pLva1vpsfD

  1. Click this button to start creating/editing settings

image

  1. Here you can add variety off settings, and implement them in your pp counter
    1. You should always specify uniqueID, you'll use it to get it inside pp counter

1714854338_wdFrpKUOZP

  1. After you added options, click "Update settings"