Hello, I'm trying to dynamically change the amount of slots that clients are allowed in in each virtual server for the game I'm working on. We are currently live. I'm working with a test server in order to make necessary changes.

My plan to set in motion is that whenever someone enters the virtual server, then the following function will be called and an extra slot will be created in case someone else tries to join. Once I get this working I will set up a similar function to remove unused slots.

static void addClientSlot(uint64 serverID){

	unsigned int error; // error checking

	int theMaxClients;  // Holds the number of client slots in this virtual server

        // This function works flawlessly by passing in a reference to theMaxClients I get the max amount
        // of clients allowed in this virtual server
	ts3server_getVirtualServerVariableAsInt(serverID, VIRTUALSERVER_MAXCLIENTS, &theMaxClients);

        // Print the number of max clients
	cout << "The Max clients are: " << theMaxClients << endl;

	cout << "Adding 1 to the list" << endl;
        // Add one to the max Clients (as this function is called when someone joins the server)

        // This is where the code breaks! In theory by passing theMaxClients variable, which has been incremented 
        // by one, the max clients should go up by one (I would later implement a check to see how high this is
        // number is getting) The server instead crashes and I get the following error:
        // 2013-05-09 21:17:58.424079|CRITICAL|Variables       |   | isValidItem() on unregistered variable | Index:5
	if((error = ts3server_setVirtualServerVariableAsInt(serverID, VIRTUALSERVER_MAXCLIENTS, theMaxClients)) != ERROR_ok)
		printf("Error setting the new capacity: %d\n\n", error);

	ts3server_flushVirtualServerVariable(serverID);   // Flush value
        // just to prove that it's working properly (which it isn't)
        ts3server_getVirtualServerVariableAsInt(serverID, VIRTUALSERVER_MAXCLIENTS, &theMaxClients);

	cout << "The Max clients are now: " << theMaxClients << endl;
I can't seem to find any information on this error, Hopefully someone here can shed some light on my situation.

I am using c++, and working with Visual Studio 2010 Please let me know if you need any more information, and thank you in advance!