Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 9 of 9
  1. #1
    Join Date
    February 2014
    Posts
    24

    [Help/Request] Plugin that sends a message to specified server group.

    I am trying to make a plugin where i can send a message to a specified server group without having to find the ids of each person or individually message them. Can anyone help?

  2. #2
    Join Date
    September 2012
    Posts
    6,079
    In that case you'd be SOL.

    You'd need to do something like this:
    Code:
    // Get a list of clients in the specified server group. 
    ts3.requestServerGroupClientList(ts3.getCurrentServerConnectionHandlerID(), GROUP_ID, 0, NULL);
    
    // Called for every client in that server group
    void ts3plugin_onServerGroupClientListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, uint64 clientDatabaseID, const char* clientNameIdentifier, const char* clientUniqueID) {
        // You should make sure that you actually requested this information, as this event will also be called whenever you open the permission dialog
        // and possibly other instances without being explicitly requested.
        ts3.requestClientIDs(serverConnectionHandlerID, clientUniqueID, NULL); // Expensive; Get current Client IDs for User (onClientIDsEvent will be called at least once if client is online)
    }
    
    // Called once for every connected client with the UID requested by requestClientIDs
    void ts3plugin_onClientIDsEvent(uint64 serverConnectionHandlerID, const char* uniqueClientIdentifier, anyID clientID, const char* clientName) {
        // Send the message to the client here. 
        // You may want to make sure you don't send the message to the same UID twice.
        // You should make sure that you don't send messages to clients you did not request, as this event might be called without being explicitly requested.
        ts3.requestSendPrivateTextMsg(serverConnectionHandlerID, "My Message", clientID, NULL);
    }
    
    // Called when all client IDs for the requested UID have been received (onClientIDsEvent has been called for each of them)
    void ts3plugin_onClientIDsFinishedEvent(uint64 serverConnectionHandlerID) {
    }
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  3. #3
    Join Date
    February 2014
    Posts
    24
    Quote Originally Posted by Chris View Post
    In that case you'd be SOL.

    You'd need to do something like this:
    Code:
    // Get a list of clients in the specified server group. 
    ts3.requestServerGroupClientList(ts3.getCurrentServerConnectionHandlerID(), GROUP_ID, 0, NULL);
    
    // Called for every client in that server group
    void ts3plugin_onServerGroupClientListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, uint64 clientDatabaseID, const char* clientNameIdentifier, const char* clientUniqueID) {
        // You should make sure that you actually requested this information, as this event will also be called whenever you open the permission dialog
        // and possibly other instances without being explicitly requested.
        ts3.requestClientIDs(serverConnectionHandlerID, clientUniqueID, NULL); // Expensive; Get current Client IDs for User (onClientIDsEvent will be called at least once if client is online)
    }
    
    // Called once for every connected client with the UID requested by requestClientIDs
    void ts3plugin_onClientIDsEvent(uint64 serverConnectionHandlerID, const char* uniqueClientIdentifier, anyID clientID, const char* clientName) {
        // Send the message to the client here. 
        // You may want to make sure you don't send the message to the same UID twice.
        // You should make sure that you don't send messages to clients you did not request, as this event might be called without being explicitly requested.
        ts3.requestSendPrivateTextMsg(serverConnectionHandlerID, "My Message", clientID, NULL);
    }
    
    // Called when all client IDs for the requested UID have been received (onClientIDsEvent has been called for each of them)
    void ts3plugin_onClientIDsFinishedEvent(uint64 serverConnectionHandlerID) {
    }
    i tried to add this to make it too where if a person joined a certain channel a server group was messaged and i got this error:
    1>c:\users\*\desktop\pluginsdk\src\plugin.c(297) : error C2143: syntax error : missing ';' before 'type'
    1>c:\users\*\desktop\pluginsdk\src\plugin.c(304) : error C2143: syntax error : missing ';' before 'type'
    1>c:\users\*\desktop\pluginsdk\src\plugin.c(314) : error C2059: syntax error : '}'
    Code:
    void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage) {
    	if (newChannelID == 198) {
    	// Get a list of clients in the specified server group. 
    	ts3Functions.requestServerGroupClientList(serverConnectionHandlerID, 39, 0, NULL);
    
    	// Called for every client in that server group
    Line 297 -->	void ts3plugin_onServerGroupClientListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, uint64 clientDatabaseID, const char* clientNameIdentifier, const char* clientUniqueID) {
        // You should make sure that you actually requested this information, as this event will also be called whenever you open the permission dialog
        // and possibly other instances without being explicitly requested.
        ts3Functions.requestClientIDs(serverConnectionHandlerID, clientUniqueID, NULL); // Expensive; Get current Client IDs for User (onClientIDsEvent will be called at least once if client is online)
    	}
    
    	// Called once for every connected client with the UID requested by requestClientIDs
    Line 304 -->	void ts3plugin_onClientIDsEvent(uint64 serverConnectionHandlerID, const char* uniqueClientIdentifier, anyID clientID, const char* clientName) {
        // Send the message to the client here. 
        // You may want to make sure you don't send the message to the same UID twice.
        // You should make sure that you don't send messages to clients you did not request, as this event might be called without being explicitly requested.
        ts3Functions.requestSendPrivateTextMsg(serverConnectionHandlerID, "My Message", clientID, NULL);
    	}
    
    	// Called when all client IDs for the requested UID have been received (onClientIDsEvent has been called for each of them)
    	void ts3plugin_onClientIDsFinishedEvent(uint64 serverConnectionHandlerID) {
    	}
    } <-- Line 314
    i dont see whats wrong.

  4. #4
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    Well, that looks somewhat like you pasted the whole thing, including function definitions for the event handling functions declared in plugin.h inside that clientMoveEvent. This wouldn't be recommended

    You'll only want to have
    Code:
    ts3.requestServerGroupClientList(ts3.getCurrentServerConnectionHandlerID(), GROUP_ID, 0, NULL);
    inside your clientmoveEvent there. This sends a request to the server, the reply will cause the
    Code:
    void ts3plugin_onServerGroupClientListEvent
    to be called, which again requests the client ids from the server, resulting in the calls of
    Code:
    void ts3plugin_onClientIDsEvent
    and
    Code:
    ts3plugin_onClientIDsFinishedEvent
    .

    Note that this is the basic principle, as Chris pointed out in the comments, it's far from effective to redundantly ask the server those things such often.

  5. #5
    Join Date
    February 2014
    Posts
    24
    Quote Originally Posted by Philosound View Post
    Well, that looks somewhat like you pasted the whole thing, including function definitions for the event handling functions declared in plugin.h inside that clientMoveEvent. This wouldn't be recommended

    You'll only want to have
    Code:
    ts3.requestServerGroupClientList(ts3.getCurrentServerConnectionHandlerID(), GROUP_ID, 0, NULL);
    inside your clientmoveEvent there. This sends a request to the server, the reply will cause the
    Code:
    void ts3plugin_onServerGroupClientListEvent
    to be called, which again requests the client ids from the server, resulting in the calls of
    Code:
    void ts3plugin_onClientIDsEvent
    and
    Code:
    ts3plugin_onClientIDsFinishedEvent
    .

    Note that this is the basic principle, as Chris pointed out in the comments, it's far from effective to redundantly ask the server those things such often.
    ahh i see now thanks

    Edit: i took evything out but what you said stays in and i still get a syntax error : missing ';' before 'type

  6. #6
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    Check if ts3. is actually the struct, e.g. in the example plugin it's
    Code:
    struct TS3Functions ts3Functions;
    hence it'd be
    Code:
    ts3Functions.requestServerGroupClientList(ts3Functions.getCurrentServerConnectionHandlerID(), GROUP_ID, 0, NULL);

  7. #7
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    Oh well, before I forget, it might be worth mentioning there are server query bots out there having the on-that-server-group-enters-there-notify-servergroup-such-and-such functionality, like JTS3ServerBot. If server query and a running environment are in reach, that'd be the better implementation, since no (normal) client would've to be connected to provide said functionality.

  8. #8
    Join Date
    February 2014
    Posts
    24
    Quote Originally Posted by Philosound View Post
    Oh well, before I forget, it might be worth mentioning there are server query bots out there having the on-that-server-group-enters-there-notify-servergroup-such-and-such functionality, like JTS3ServerBot. If server query and a running environment are in reach, that'd be the better implementation, since no (normal) client would've to be connected to provide said functionality.
    nvm i got it to work but now the out put says.
    onServerErrorEvent: database empty result set 1281.

    and yes i know about JTS3 but the server im on i dont have access to the servey query so thats why im doing it through a plugin.

    Edit: NVM fixed the problem.
    Last edited by Tylerjet; February 27th, 2014 at 11:07 PM.

  9. #9
    Join Date
    September 2012
    Posts
    6,079
    Well obviously I didn't write the entire code out for you and as mentioned this is far from effective or good style. In fact apart from the checks I mentioned in the code comments you might want to cache the client IDs for each unique ID once you have them to avoid the expensive calls to requestClientIDs. You can then use the onClientMoveEvent to track clients out of the cache disconnecting and remove them from your cache.
    You may also want to request clients in the servergroup (requestServerGroupClientList) once when you connect/initialize the plugin and then use the ts3plugin_onServerGroupClientAddedEvent and ts3plugin_onServerGroupClientDeletedEvent Events to stay up to date on the desired server group.

    And yes, at some point I got tired of typing ts3Functions all the time, so I just changed it to ts3.

    As for that error in the client log, it happens when there are no clients in the server group and possibly when none of them is online. You can suppress those errors by using return Codes.

    for an example see the demo plugin's ts3plugin_processCommand and ts3plugin_onServerErrorEvent and the comments there.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Request] Welcome Popup Message based on server groups
    By MuerteInHell in forum Tools / Web Based
    Replies: 5
    Last Post: September 7th, 2018, 06:32 AM
  2. [REQUEST]Plugin sends message to specified server group
    By ahmedkoki in forum Client Plugins / Lua Scripts
    Replies: 7
    Last Post: August 8th, 2014, 10:33 AM
  3. Server group add/remove Plugin
    By ReloadedMichi in forum Client Plugins / Lua Scripts
    Replies: 0
    Last Post: April 18th, 2014, 02:31 PM
  4. [Request] Plugin That Allows Users To Request Songs and Spotify to Queue Them
    By loganweaver15 in forum Client Plugins / Lua Scripts
    Replies: 4
    Last Post: March 7th, 2014, 03:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •