• 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 How to "target" servergroup in script ?

Status
Not open for further replies.
Hey guys,

Is there a smart way to "target" servergroup with code like this ?

chatPrivate(clientId, text)

So, what i want to "develop" is a bot, that messages users at a specific time if the day. But how can i select online users of a specific servergroup to be messaged ?

Thanks ^^

Best regards,
Opossum_LP
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Please refer to the new Scripting Engine which is documented here.
What do you mean exactly? You want to send a message to all clients in a server group which are online right?
 
Last edited:

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Okay, link is fixed ;)
Something like this should work for example with server group id 6:
Code:
var backend = require('backend');
var onlineClients = backend.getClients();
onlineClients.forEach(function(client) {
    client.getServerGroups().forEach(function(group) {
        if (group.id() == "6") {
            client.chat('Hello ', +client.Name() + ". I' m a SinusBot!");
            return true;
        }
    });
});
But untested, the rest you figure out yourself if it is not working^^ Try to use only the new Scriptengine from the link above.
 
Status
Not open for further replies.
Top