• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN Welcome Sound for each selected server group

Status
Not open for further replies.

ZanKfx

Donor
is awesome!
A script similar to the welcome sound but where you can choose the welcome sound for each selected server group.
I can make the form but I'm not able to make the "core" of the script. @TS3index
 

ZanKfx

Donor
is awesome!
Code:
registerPlugin({
    name: 'Welcome Sound by Server Groups',
    version: '1.0',
    description: 'Play a sound on joining of selected server groups',
    author: 'Nobody',
    vars: {
        Tracks: {
            title: 'Add New',
            type: 'array',
            vars: [
                {
                    name: 'channelId',
                    title: 'Default Channel (Channel(s) Id(s)):',
                    type: 'channel',
                    placeholder: '44,137,256 (Comma Separated)'
                },
                {
                    name: 'track',
                    title: 'Sound File:',
                    type: 'track',
                    placeholder: 'Search for track...'
                },
                {
                    name: 'resume',
                    title: 'Resume last track or stream after welcomesound:',
                    type: 'select',
                    options:     [
                                'Disabled',
                                'Enabled'
                                 ]
                },
                {
                    name: 'servergroup',
                    title: 'Servergroup Ids (Comma seperated):',
                    type: 'string',
                    placeholder: '9,15,42'
                }
            ]
        }
    }
   
    //Funzione Di Ripresa di una traccia musicale
   
}, function(sinusbot, config) {
    if (!config || !config.channelId || !config.track) {
      sinusbot.log("Settings invalid.");
      return;
    }

    var resumePlayback = false;
    var resumeTrack = false;
    var resumePos = 0;
   
    var securejoin = true;

    var getUUID = function (url) {
        var match = url.match(/track:\/\/(\.)?(.[^/:]+)/i);
        if (match != null && match.length > 2 && typeof match[2] === 'string' && match[2].length > 0) {
          return match[2];
        }
        else {
            return null;
        }
    }
   
    // Permette di far partire la traccia quando un utente entra nella stanza
   
    sinusbot.on('clientMove', function(ev) {
        if (ev.newChannel == config.channelId && sinusbot.getCurrentChannelId() == config.channelId) {
            sinusbot.log("Welcome-Sound starting...");
            if (config.resume && sinusbot.playing() && (sinusbot.getCurrentTrack().uuid != "" || sinusbot.getCurrentTrack().type == 'url') && (sinusbot.getCurrentTrack().uuid != getUUID(config.track.url))) {
                resumePlayback = true;
                resumeTrack = sinusbot.getCurrentTrack();
                resumePos = sinusbot.getPos();
                sinusbot.play(config.track.url + '&callback=welcomesound&copy=true');
            } else if (resumePlayback) {
                securejoin = false;
                sinusbot.play(config.track.url + '&callback=welcomesound&copy=true');
            } else {
                sinusbot.play(config.track.url);
            }
        }
    });
   
    // Permette di far riprendere la musica precende alla riproduzione del suono di benvenuto
   
    sinusbot.on('trackEnd', function(cb) {
        if (cb == 'welcomesound' && resumePlayback) {
            if (securejoin) {
                sinusbot.log("Resume last track: " + resumeTrack.title);
                resumePlayback = false;
                if (resumeTrack.type == 'url') {
                  sinusbot.play(resumeTrack.filename);
                } else {
                  sinusbot.setMute(true);
                  sinusbot.play("track://" + resumeTrack.uuid);
                  sinusbot.seek(resumePos);
                  sinusbot.setMute(false);
                }
            }
            securejoin = true;
        }
    });
});


Help very appreciated :)
 
Status
Not open for further replies.
Top