/* Teamspeak³ Connect ver. 2 2014 by Beavis */ #if defined TS_CONNECT_INCLUDED #endinput #endif #define TS_CONNECT_INCLUDED #include a_samp #include a_http /* native ts_connect(const url[], code); native ts_close(connection = 0); native ts_kick(const uid[], const reason[], connection = 0); native ts_ban(const uid[], const reason[], connection = 0); native ts_unban(const uid[], connection = 0); native ts_sendusermessage(const uid[], const message[], connection = 0); native ts_poke(const uid[], const message[], connection = 0); native ts_clients(connection = 0); native ts_setbeschreibung(const uid[], const beschreibung[], connection = 0); native ts_moveclient(const uid[], const channelname[], connection = 0); native ts_channelcreate(const channelname[], const beschreibung[]="", const passwort[]="", connection = 0); native ts_subchannelcreate(const channelname[], const tochannel[], const beschreibung[]="", const passwort[]="", connection = 0); native ts_channelremove(const channelname[], connection = 0); native ts_setusertoservergroup(const uid[], const servergroup[], connection = 0); native ts_removeuserfromservergruop(const uid[], const servergroup[], connection = 0); native ts_sendservermsg(const message[], connection = 0); native ts_sendchannelmsg(const channelname[], const message[], connection = 0); native ts_setusertochannelgroup(const uid[], const channelgroup[], const channel[], connection = 0); */ forward OnTsUsers(tsname[], tsuID[]); enum tsnu{tshost[50],tscode}; new TS[3][tsnu],TSi = 0,ActiveCon = -1,bool:tsusers=false; /* ts_connect url = Der Host wo das php Script liegt (ohne http oder www!) code = Der Code den man nach der Installation bekommen hat returnt die ConnectionID */ stock ts_connect(const url[], code){ for(new i=0;i<3;i++){ if(TS[i][tscode] != 0)continue; format(TS[i][tshost],50,url); TS[i][tscode] = code; TSi = 0; ActiveCon = -1; tsusers=false; return i; } return -1; } /* ts_close connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt 1 bei erfolg, 0 bei kein erfolg */ stock ts_close(connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return 0; TS[connection][tscode] = 0; format(TS[connection][tshost],50,""); return 1; } /* ts_kick uid = Die Eindeutige ID des users reason = Der Grund für den Kick connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_kick(const uid[], const reason[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&kick=%s", TS[connection][tscode], uid, reason); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_ban uid = Die Eindeutige ID des users reason = Der Grund für den Ban connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_ban(const uid[], const reason[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&ban=%s", TS[connection][tscode], uid, reason); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_unban uid = Die Eindeutige ID des users connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_unban(const uid[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&unban=true", TS[connection][tscode], uid); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_sendusermessage uid = Die Eindeutige ID des users message = nachicht die der User bekommen soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_sendusermessage(const uid[], const message[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&pm=%s", TS[connection][tscode], uid, message); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_poke uid = Die Eindeutige ID des users message = nachicht die der User bekommen soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_poke(const uid[], const message[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&poke=%s", TS[connection][tscode], uid, message); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_clients connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt Callback "OnTsUsers(tsname[], tsuID[])" */ stock ts_clients(connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection;tsusers=true; format(post, sizeof(post), "code=%d&listclients=true", TS[connection][tscode]); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_setbeschreibung uid = Die Eindeutige ID des users beschreibung = Die beschreibung des Users connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_setbeschreibung(const uid[], const beschreibung[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&beschreibung=%s", TS[connection][tscode], uid, beschreibung); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_moveclient uid = Die Eindeutige ID des users channelname = Name des Channels wo der User rein soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_moveclient(const uid[], const channelname[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&move=%s", TS[connection][tscode], uid, channelname); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_channelcreate channelname = Name des Channels beschreibung = Beschreibung des Channels passwort = Das Passwort den der channel erhalten soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_channelcreate(const channelname[], const beschreibung[]="", const passwort[]="", connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&channel=%s&tophic=%s&pw=%s", TS[connection][tscode], channelname, beschreibung, passwort); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_subchannelcreate channelname = Name des Channels tochannel = Der Channel wo der neue erstellt werden soll beschreibung = Beschreibung des Channels passwort = Das Passwort den der channel erhalten soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_subchannelcreate(const channelname[], const tochannel[], const beschreibung[]="", const passwort[]="", connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&subchannel=%s&tophic=%s&pw=%s&to=%s", TS[connection][tscode], channelname, beschreibung, passwort, tochannel); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_channelremove channelname = Name des Channels connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_channelremove(const channelname[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&remchannel=%s", TS[connection][tscode], channelname); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_setusertoservergroup uid = Die Eindeutige ID des users servergroup = Name der Servergruppe wo der User rein soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_setusertoservergroup(const uid[], const servergroup[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&svrgrpadd=%s", TS[connection][tscode], uid, servergroup); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_removeuserfromservergruop uid = Die Eindeutige ID des users servergroup = Name der Servergruppe die der User verlieren soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_removeuserfromservergruop(const uid[], const servergroup[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&svrgrprem=%s", TS[connection][tscode], uid, servergroup); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_sendservermsg message = Nachicht die gesendet werden soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_sendservermsg(const message[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&svrmsg=%s", TS[connection][tscode], message); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_sendchannelmsg channelname = Der name des Channels message = Nachicht die gesendet werden soll connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_sendchannelmsg(const channelname[], const message[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&sendchannel=%s&channelmsg=%s", TS[connection][tscode], channelname, message); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* ts_setusertochannelgroup uid = Die Eindeutige ID des users channelgroup = Name der Channelgruppe wo der User rein soll channel = Der name des Channels connection = Die ConnectioID die ts_connect wiedergibt (standart 0) returnt nix */ stock ts_setusertochannelgroup(const uid[], const channelgroup[], const channel[], connection = 0){ if((connection == -1) || (TS[connection][tscode] == 0))return printf("[Teamspeak Connect] Keine Verbindung (Connectionid: %d)",connection) & 0; new post[250]; TSi++;ActiveCon = connection; format(post, sizeof(post), "code=%d&uid=%s&changrp=%s&grpchan=%s", TS[connection][tscode], uid, channelgroup, channel); return HTTP(TSi, HTTP_POST, TS[connection][tshost], post, "TS_HTTP_Response"); } /* Callback Nix abändern! */ forward TS_HTTP_Response(index , response_code, data[]); public TS_HTTP_Response(index , response_code, data[]){ if(response_code == 200){ if(tsusers){ if(funcidx("OnTsUsers") == -1){ printf("[Teamspeak Connect] Callback OnTsUsers(tsname[], tsuID[]) exestiert nicht (Connectionid: %d)", ActiveCon); } else{ /*----- Function von Jeffry danke dafür -----*/ new name[32], ident[64], a = 1, idx; while(a){ if(a == 1){ idx = strfind(data, ","); if(idx == -1) break; strmid(name, data, 0, idx); strdel(data, 0, idx+1); a = 2; } else{ idx = strfind(data, "|"); if(idx == -1) break; strmid(ident, data, 0, idx); strdel(data, 0, idx+1); a = 1; CallLocalFunction("OnTsUsers","ss",name,ident); } } /*----- Function von Jeffry danke dafür -----*/ } } else{ printf("[Teamspeak Connect] %s (Connectionid: %d)", data, ActiveCon); } } else{ printf("[Teamspeak Connect] Fehler %d (Connectionid: %d)",response_code, ActiveCon); } TSi--; tsusers=false; return 1; }