Dear NimdaTS3, Diffrence with Query Libraries. RE: Teamspeak Query PHP Scripts

tagKnife

Well-Known Member
Oct 2, 2015
343
270
146
Hi everyone, Im here to tell you about NimdaTS3 which is a TeamSpeak 3 bot library that I really like (JK I wrote it #ad) and I want to share with everyone. I saw a post: https://r4p3.net/threads/teamspeak-query-php-scripts.5432/ by @XRV-Webix about some performance stuff, I am going to extend on this.

So Nimda is TeamSpeak Query library, So let's review how Query libraries work. I'm going to talk about 2 query methods. The first one is a retained mode query. So when you write a retained mode query typically your program will look like this:
PHP:
$server = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987&blocking=0");
Signal::getInstance()->subscribe("serverqueryWaitTimeout", "onWaitTimeout");
$server->getAdapter()->wait();
function onWaitTimeout($time, AbstractAdapter $adapter)
{
    $adapter->getHost()->message('hello');
}
Where you setup a connection, some events and maybe some classes. you'll hook them up all together, create some callbacks and some fancy stuff. and after you set everything up, you run and it just goes. After that everything is handled by events and callbacks and any other logic you add.

The second way to write a query library is immediate mode, so this is an example of immediate mode.

PHP:
$server =TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987&blocking=0");
while(true){
    $server->message('hello');
}
You see the main difference the code in immediate mode gets called constantly, all the time, forever. every iteration of the program you would do stuff. that might sound kind of weird at first, but actually, it turns out 70% of bots I have seen have been coded like this. Because its easy and fast to code. But not in terms of performance.

So here's some pros and cons
Retained mode:
  1. Power efficient (interrupt based)
  2. Mostly static (Constructed once)
  3. Long-term design
  4. Everyday use case
Immediate mode:
  1. Power inefficient (polling based)
  2. Very dynamic (always rebuilt)
  3. Fast prototyping
  4. Real-time result use case
Retained mode, Since its interrupt based, means you are only doing work when events happen, so when a client joins the server or when the server checks if the connection is still active. That makes it more efficient with power for the query library and the server. So if you have a program which runs for a long time you will want to go with retained mode. Retained mode is mostly static, so you build everything upfront and it doesn't change much after that, and if things do change after that, well you need to update your code or handle the events correctly.

However, Immediate mode is power in power inefficient since it polling based, meaning its doing work no matter what, even when nothing is happening. Immediate mode is very dynamic because every loop you can completely change how the program acts depending whats going on in your program.

So NimdaTS3 is a library that implements this retained mode query paradigm in PHP. If you want to use NimdaTS3 in for your bots today there are only a few steps you need to do first go to the NimdaTS3 GitHub (which ill link at the bottom of this thread) and download the library this includes some premade plugins, Plugins like Jail, Seen and Quotes. You have a few callbacks available to use, so not very much work to get starts. just define what callbacks to want to use and the library will capture events and pass them to your plugin to process them. then after that just write your code and use Teamspeak calls. Like message a client or change server description.

Heres a link to the library: https://github.com/JABirchall/NimdaTS3
And a video demonstration how easy it is tostart writting a plugin:
 
Top