Moja przygoda z php zaczęła się parę dni temu.
Nie do końca wszystko ogarniam.
W sumie to wszystko zaczęło się od pomysłu, który zamierzam zrealizować.
A więc do rzeczy.
Chcę zintegrować Teamspeaka z grą League of Legends.
Skrypt ma za zadanie sprawdzać czy dany użytkownik rozgrywa mecz w grze
i jeśli tak stworzyć kanał na TS i przenieść tam użytkownika.
Skrypt jest tylko dla mnie i dla moich znajomych.
Nie jest to jakiś komercyjny produkt więc jeśli ktoś
chciałby skorzystać nie mam nic przeciwko.
Mam nadzieję, że nie pojawią się zaraz komentarze typu:
Zleć to komuś kto się na tym zna i zapłać mu odpowiednią sumę.
$LoLsgname = "LOL"; $lolmainCHid = "156"; $region = "eune"; $botname = "Test-RIOT"; $TSaddress = "127.0.0.1"; $TSqueryport = "10011"; $TSport = "9987"; $TSadminNickname = "serveradmin"; $TSpassword = "g87bRsLJ"; // ERROR REPORT "/../TS3LOL/ts3php/libraries/TeamSpeak3/TeamSpeak3.php"; Unirest::verifyPeer(false); try { $ts3_VirtualServer = TeamSpeak3::factory("serverquery://$TSadminNickname:$TSpassword@$TSaddress:$TSqueryport/?server_port=$TSport&nickname=$botname"); } catch (TeamSpeak3_Exception $e) { // print the error message returned by the server } $arr_LOLClientList = $ts3_VirtualServer->serverGroupGetByName("$LoLsgname"); foreach ($arr_LOLClientList as $TSClid => $TSArray) { "TsNICK" => $TSArray->client_nickname->toString(), "TsDBID" => $TSArray->client_database_id, // "TsUID" => $TSArray->client_unique_identifier->toString(), // "TsSERVGIDs" => $TSArray->client_servergroups, //"TsCHANGIDs" => $TSArray->client_channel_group_id, "TsCLIENTID" => $TSArray->clid, "TsCLIENTCHANID" => $TSArray->cid)); } { die; } foreach ($TSuserdata as $Summoner) { $response = Unirest::get("https://community-league-of-legends.p.mashape.com/api/v1.0/$region/summoner/retrieveInProgressSpectatorGameInfo/" . "RU6K0QgxXz4btt0eB4gzAz6rCvlPpdFm"), null); $array = ($response->raw_body); $new = json_decode($array, true); { " was found in the system <br />"; $ts3_VirtualServer->message("No Game for player " . $Summoner['TsNICK'] . " was found in the system"); { die; { $ts3_VirtualServer->message("Looks like " . $Summoner['TsNICK'] . " are in game!!\nLOADING DATA...."); "gameId" => $new["playerCredentials"]["gameId"])); //TEAM ONE foreach ($new["game"]["teamOne"]["array"] as $teamOneArray) { "summonerInternalName" => $teamOneArray["summonerInternalName"], "accountID" => $teamOneArray["accountId"], "summonerID" => $teamOneArray["summonerId"])); } //Team TWO foreach ($new["game"]["teamTwo"]["array"] as $teamTwoArray) { "summonerInternalName" => $teamTwoArray["summonerInternalName"], "accountID" => $teamTwoArray["accountId"], "summonerID" => $teamTwoArray["summonerId"])); } foreach ($TSuserdata as $key => $tsu) { foreach ($teamOne as $tone) { { foreach ($tone as $k => $c) { $TSuserdata[$key][$k] = $c; } $find = 1; break; } } } foreach ($TSuserdata as $key => $tsu) { foreach ($teamTwo as $ttwo) { { foreach ($ttwo as $k => $c) { $TSuserdata[$key][$k] = $c; } $find = 1; break; } } } foreach ($TSuserdata as $key => $tsu) { foreach ($sumgameid as $sumid) { { if ($sumid["playerId"] == ($tsu["accountID"])) { foreach ($sumid as $k => $c) { $TSuserdata[$key][$k] = $c; } $find = 1; break; } } } } $subchannelnamelist = ""; $channel = $ts3_VirtualServer->channelGetById("$lolmainCHid")->subChannelList(); foreach ($channel as $sub) { $subchannelname = $sub; $subchannelnamelist = $subchannelnamelist . $subchannelname . ","; } foreach ($TSuserdata as $tsUser) { { "channel_name" => "" . $tsUser["gameId"] . "", "channel_topic" => "test", "channel_codec" => TeamSpeak3::CODEC_SPEEX_ULTRAWIDEBAND, "channel_codec_quality" => 0x08, "channel_flag_permanent" => true, "channel_password" => false, "cpid" => $lolmainCHid)); "channel_name" => "Team One", "channel_topic" => "Team One", "channel_codec" => TeamSpeak3::CODEC_SPEEX_ULTRAWIDEBAND, "channel_codec_quality" => 0x08, "channel_flag_permanent" => true, "channel_password" => false, "cpid" => $cid)); "channel_name" => "Team Two", "channel_topic" => "Team Two", "channel_codec" => TeamSpeak3::CODEC_SPEEX_ULTRAWIDEBAND, "channel_codec_quality" => 0x08, "channel_flag_permanent" => true, "channel_password" => false, "cpid" => $cid)); } } // if (isset($tsUser["gameId"])) // { // $Onecid = $ts3_VirtualServer->channelGetByName("" . $tsUser["gameId"] . "")-> // subChannelGetByName("Team One")->cid; // $Twocid = $ts3_VirtualServer->channelGetByName("" . $tsUser["gameId"] . "")-> // subChannelGetByName("Team Two")->cid; // } // } // foreach ($teamOne as $tomove) // { // foreach ($TSuserdata as $tsmove) // { // // // if ($tsmove["summonerInternalName"] == $tomove["summonerInternalName"]) // { // if ($Onecid != $tsmove["TsCLIENTCHANID"]) // { // $ts3_VirtualServer->clientMove($tsmove["TsCLIENTID"], $Onecid); // $ts3_VirtualServer->clientGetByDbid($tsmove["TsDBID"])->message("You are moved to your team channel"); // } else // { // echo " " . $tsmove["TsNICK"] . " Already on channel"; // $ts3_VirtualServer->message("Already on channel "); // } // } // } // } // // foreach ($teamTwo as $tomove) // { // foreach ($TSuserdata as $tsmove) // { // // if ($tsmove["summonerInternalName"] == $tomove["summonerInternalName"]) // { // if ($Twocid != $tsmove["TsCLIENTCHANID"]) // { // // $ts3_VirtualServer->clientMove($tsmove["TsCLIENTID"], $Twocid); // $ts3_VirtualServer->clientGetByDbid($tsmove["TsDBID"])->message("You are moved to your team channel"); // } else // { // echo " " . $tsmove["TsNICK"] . " Already on channel"; // $ts3_VirtualServer->message("Already on channel "); // } // } // } // } } }
Przepraszam za post pod postem ale brakło miejsca.
Mój Problem polega na tym, że nie do końca wiem wiem jak zapętlić adres api by uzyskać "gameId" dla każdego użytkownika TS.
Po wrzuceniu adresu w pętlę bez dodawania [0] w tablicy (nie wiem jak to się fachowo nazywa) te dane jakoś dziwnym trafem znikają.
Jeśli zmienię $new na $new[] to nie wiem jak zapętlić $new["game"]["teamOne"]["array"]
Pomożecie mi jakoś doprowadzić to do finału. Stworzyłem tymczasowy serwer TS z "testowymi graczami" więc jak ktoś ma czas i ochote mi pomóc
to mogę podać IP.