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 1 of 1
  1. #1
    Join Date
    November 2011
    Posts
    11

    Getting Started...

    I have converted the sample "test_plugin" to Visual Studio 2010 and successfully compiled it (although the release is missing a header file called "public_errors_rare.h", after a forum search I found the temp solution).

    I quickly found my mistake of compiling it for Win32 rather then x64 and now the plug-in shows properly under Settings/Plugins with the modified changes to the title.

    Nothing special...

    So, I took a look at where I think there would likely be a function call at the start of the plugin loading, and is only called once. I added a function there:

    Code:
    int ts3plugin_init() {
        char appPath[PATH_BUFSIZE];
        char resourcesPath[PATH_BUFSIZE];
        char configPath[PATH_BUFSIZE];
    	char pluginPath[PATH_BUFSIZE];
    
        /* Your plugin init code here */
        printf("PLUGIN: init\n");
    
    	/* Show API versions */
    	printf("PLUGIN: Client API Version: %d, Plugin API Version: %d\n", ts3Functions.getAPIVersion(), ts3plugin_apiVersion());
    	LogThis(StrFormat("Hello").c_str());
    I've now noticed that I can start TS3 with the -console param and the function is being called. My function does work in other projects, I wonder why it is not working here...


    Code:
    //Logging.cpp
    #include <fstream>
    #include <time.h>
    #include <string>
    #include "Logging.h"
    
    #define va_start _crt_va_start
    #define va_end _crt_va_end
    
    std::string StrFormat(const char* Format,...) {
       char Buf[2048];
       va_list va;
       va_start(va,Format);
       vsnprintf(Buf,sizeof(Buf),Format,va);
       va_end(va);
       return Buf;
    }
    
    void LogThis(const char *message)
    {
    	printf("%s\n", message);
    	std::ofstream FP;
    	time_t rawtime;
    	tm *timeinfo;
    	time(&rawtime);
    	timeinfo = localtime(&rawtime);
    
    	FP.open("Log.txt",std::ios::app);
    	FP << StrFormat("[%02d/%02d/%02d][%02d:%02d:%02d]: %s\n", timeinfo->tm_wday, timeinfo->tm_mon, timeinfo->tm_year,timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, message) << std::endl;
    	FP.close();
    }
    
    //Logging.h
    #include <iostream>
    
    std::string StrFormat(const char* Format,...);
    void LogThis(const char *message);
    //Edit

    Silly me, it needs to run as Admin to create a text file in that directory...

    Anyone have any advice on this? I tried setting the UAC Execution level appropriately, but this had no effect (I guess as it is loaded after the event...). I could store th text file some other place, but there are likely other functions that I will want to call that require admin.
    Last edited by Spencer E; November 7th, 2011 at 08:44 PM.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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