Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Przenoszenie z afk do ostatniego kanału


MEXXIO

Rekomendowane odpowiedzi

Opublikowano

Mam problem z kodem, skrypt czy tam bot przenosi użytkownika na kanał afk lecz nie mam kompletnie pomysłu jak rozwiązać problem aby z powrotem przenosił na kanał na którym był przed wykopaniem na afk.

public function afkchecker(): void
{
	foreach ($this->clientlist as $cl)
	{
		if($cl['client_type'] == 0)
		{
			if($cl['client_input_muted']==1 || $cl['client_output_muted']==1 || $cl['client_away']==1)
		    {
				if($this->config['afkchecker']['move_afk'] == true)
				{
					self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
				}
			}
		}
	}
}

 

Opublikowano

Zrób sobie zmienna gdzie zapisujesz id kanału użytkownika i wtedy jak wróci z afk to go  szuka w tej zmiennej i przenosi go spowrotem na ten kanał.

 

public function afkchecker(): void
{
	$clientsAfk = [];
	foreach ($this->clientlist as $cl)
	{
		if($cl['client_type'] == 0)
		{
			if($cl['client_input_muted']==1 || $cl['client_output_muted']==1 || $cl['client_away']==1)
		    {
				if($this->config['afkchecker']['move_afk'] == true)
				{
					self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
					$clientsAfk[$cl["client_unique_identifier"]["last_channel"] = $cl["cid"];
				}
			} 
			if($cl['client_input_muted']==0 && $cl['client_output_muted']==0 && $cl['client_away']==10)
			{
				self::$tsAdmin->clientMove($cl['clid'], $clientsAfk[$cl["client_unique_identifier"]["last_channel"]);
				unset($clientsAfk[$cl["client_unique_identifier"]);
			}
		}
	}
}

Powinno działać ;) 

PS: Możesz usunąć te sprawdzanie czy move_afk jest true jeśli i tak tylko będziesz miał przesuwanie :)

Opublikowano

Niestety nie działa, pytanie po co jest

["last_channel"]

które wywala błąd w logu. Ja próbowałem coś takiego i nic

public function afkchecker(): void
{
	$clientsAfk = [];
	foreach ($this->clientlist as $cl)
	{
		if($cl['client_type'] == 0)
		{
			if($cl["client_unique_identifier"] != $clientsAfk)
			{
				if($cl['client_input_muted'] == 1 || $cl['client_output_muted'] == 1 || $cl['client_away'] == 1)
			    {
					if($this->config['afkchecker']['move_afk'] == true)
					{
						$clientsAfk[$cl["client_unique_identifier"]] = $cl["cid"];
						self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
					}
				}
			}
			elseif($cl["client_unique_identifier"] == $clientsAfk)
			{
				if($cl['client_input_muted'] == 0 || $cl['client_output_muted'] == 0 || $cl['client_away'] == 0)
				{
					self::$tsAdmin->clientMove($cl['clid'], $clientsAfk[$cl["client_unique_identifier"]]);
				}
			}
		}
	}
}

 

Opublikowano
Dnia 9.02.2018 o 23:37, MEXXIO napisał:

Niestety nie działa, pytanie po co jest


["last_channel"]

które wywala błąd w logu. Ja próbowałem coś takiego i nic


public function afkchecker(): void
{
	$clientsAfk = [];
	foreach ($this->clientlist as $cl)
	{
		if($cl['client_type'] == 0)
		{
			if($cl["client_unique_identifier"] != $clientsAfk)
			{
				if($cl['client_input_muted'] == 1 || $cl['client_output_muted'] == 1 || $cl['client_away'] == 1)
			    {
					if($this->config['afkchecker']['move_afk'] == true)
					{
						$clientsAfk[$cl["client_unique_identifier"]] = $cl["cid"];
						self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
					}
				}
			}
			elseif($cl["client_unique_identifier"] == $clientsAfk)
			{
				if($cl['client_input_muted'] == 0 || $cl['client_output_muted'] == 0 || $cl['client_away'] == 0)
				{
					self::$tsAdmin->clientMove($cl['clid'], $clientsAfk[$cl["client_unique_identifier"]]);
				}
			}
		}
	}
}

 

Porównujesz element do tablicy??? XD???

 

if($cl["client_unique_identifier"] != $clientsAfk)

Po co? 

elseif($cl["client_unique_identifier"] == $clientsAfk)

Tu są te błędy. 

Protip. Wypadałoby po pomyślnym przeniesieniu klienta usunąć z pamięci(tabilcy) bo go będzie do usranej śmierci(lub resetu bota) wywalać na tamten kanał :p 

Opublikowano
public function afkchecker(): void
{
	$clients = self::$tsAdmin->getElement('data', self::$tsAdmin->clientList('-groups -voice -away -times -uid'));

	foreach ($clients as $cl)
	{
		if($cl['client_type'] == 0)
		{
			if($cl['client_input_muted'] == 1 || $cl['client_output_muted'] == 1 || $cl['client_away'] == 1)
			{
				if($this->config['afkchecker']['move_afk'] == true)
				{
					self::$clientsAfk[$cl["client_unique_identifier"]] = $cl["cid"];
					self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
				}
			}
			else
			{
				if($cl['client_input_muted'] == 0 || $cl['client_output_muted'] == 0 || $cl['client_away'] == 0)
				{
					self::$tsAdmin->clientMove($cl['clid'], self::$clientsAfk[$cl["client_unique_identifier"]]);
					unset(self::$clientsAfk[$cl['client_unique_identifier']]);
				}
			}
		}
	}
}

Mam coś takiego teraz działa lecz gdy biorę wycisz mic np. to muszę szybko od ciszyć to wtedy działa jeśli to zrobię po paru sec wtedy nie działa.

Bot do którego próbuję dodać funkcję to:
https://github.com/Majcon94/TS3Bot
z tego bota chcę przenieść:
https://github.com/inferno211/iBot

Opublikowano
1 minutę temu, Matex. napisał:

Jedno i drugie najlepsze możliwe twory.. X-D

 

Dodaj gdzieś tam na górze pliku 


private static $clientsAfk = [];

 

Może nie napisałem od razu ale dodałem to na samej górze ;)

Opublikowano

Spróbuj ten kod ;)

public function afkchecker(): void
{
	$clientsAfk = [];
	foreach ($this->clientlist as $cl)
	{
		if($cl['client_type'] == 0)
		{
			if($cl['client_input_muted']==1 || $cl['client_output_muted']==1 || $cl['client_away']==1)
		    {
				if($this->config['afkchecker']['move_afk'] == true)
				{
					self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
					$clientsAfk[$cl["client_unique_identifier"]]["last_channel"] = $cl["cid"];
				}
			}
			else if($cl['client_input_muted']==0 && $cl['client_output_muted']==0 && $cl['client_away']==10)
			{
				self::$tsAdmin->clientMove($cl['clid'], $clientsAfk[$cl["client_unique_identifier"]["last_channel"]);
				unset($clientsAfk[$cl["client_unique_identifier"]);
			}
		}
	}
}

 

Opublikowano
22 godziny temu, MEXXIO napisał:

public function afkchecker(): void
{
	$clients = self::$tsAdmin->getElement('data', self::$tsAdmin->clientList('-groups -voice -away -times -uid'));

	foreach ($clients as $cl)
	{
		if($cl['client_type'] == 0)
		{
			if($cl['client_input_muted'] == 1 || $cl['client_output_muted'] == 1 || $cl['client_away'] == 1)
			{
				if($this->config['afkchecker']['move_afk'] == true)
				{
					self::$clientsAfk[$cl["client_unique_identifier"]] = $cl["cid"];
					self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
				}
			}
			else
			{
				if($cl['client_input_muted'] == 0 || $cl['client_output_muted'] == 0 || $cl['client_away'] == 0)
				{
					self::$tsAdmin->clientMove($cl['clid'], self::$clientsAfk[$cl["client_unique_identifier"]]);
					unset(self::$clientsAfk[$cl['client_unique_identifier']]);
				}
			}
		}
	}
}

Mam coś takiego teraz działa lecz gdy biorę wycisz mic np. to muszę szybko od ciszyć to wtedy działa jeśli to zrobię po paru sec wtedy nie działa.

Bot do którego próbuję dodać funkcję to:
https://github.com/Majcon94/TS3Bot
z tego bota chcę przenieść:
https://github.com/inferno211/iBot

if($this->config['afkchecker']['move_afk'] == true

Co autor miał na myśli? Sens istnienia tego w tym miejscu jest no hmm ciekawy.

public function afkchecker(): void
{
    $clients = self::$tsAdmin->getElement('data', self::$tsAdmin->clientList('-groups -voice -away -times -uid'));

    foreach ($clients as $cl) {
        if ($cl['client_type'] == 0) {
            if ($cl['client_input_muted'] == 1 || $cl['client_output_muted'] == 1 || $cl['client_away'] == 1) {
                if ($this->config['afkchecker']['move_afk'] == true) {
                    if (!isset(self::$clientsAfk[$cl["client_unique_identifier"]])) {
                        self::$clientsAfk[$cl["client_unique_identifier"]] = $cl["cid"];
                        self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
                    }
                }
            } else {
                if ($cl['client_input_muted'] == 0 || $cl['client_output_muted'] == 0 || $cl['client_away'] == 0) {
                    self::$tsAdmin->clientMove($cl['clid'], self::$clientsAfk[$cl["client_unique_identifier"]]);
                    unset(self::$clientsAfk[$cl['client_unique_identifier']]);
                }
            }
        }
    }
}

Zobacz czy tak będzie działać. 

Opublikowano
3 godziny temu, Matex. napisał:

if($this->config['afkchecker']['move_afk'] == true

Co autor miał na myśli? Sens istnienia tego w tym miejscu jest no hmm ciekawy.


public function afkchecker(): void
{
    $clients = self::$tsAdmin->getElement('data', self::$tsAdmin->clientList('-groups -voice -away -times -uid'));

    foreach ($clients as $cl) {
        if ($cl['client_type'] == 0) {
            if ($cl['client_input_muted'] == 1 || $cl['client_output_muted'] == 1 || $cl['client_away'] == 1) {
                if ($this->config['afkchecker']['move_afk'] == true) {
                    if (!isset(self::$clientsAfk[$cl["client_unique_identifier"]])) {
                        self::$clientsAfk[$cl["client_unique_identifier"]] = $cl["cid"];
                        self::$tsAdmin->clientMove($cl['clid'], $this->config['afkchecker']['cid']);
                    }
                }
            } else {
                if ($cl['client_input_muted'] == 0 || $cl['client_output_muted'] == 0 || $cl['client_away'] == 0) {
                    self::$tsAdmin->clientMove($cl['clid'], self::$clientsAfk[$cl["client_unique_identifier"]]);
                    unset(self::$clientsAfk[$cl['client_unique_identifier']]);
                }
            }
        }
    }
}

Zobacz czy tak będzie działać. 

Działa teraz pięknie, ale w logach wyrzuca taki błąd:

PHP Notice:  Undefined index: erPgY+kwlTJx6BYqbdGn1/+9NW4= in /home/tsbot/class/functions.class.php on line 576

#EDIT: Zrobiłem coś takiego i nie wyrzuca żadnego błędu.

if ($cl['client_input_muted'] == 0 || $cl['client_output_muted'] == 0 || $cl['client_away'] == 0) {
                	if (isset(self::$clientsAfk[$cl["client_unique_identifier"]])) {
                		self::$tsAdmin->clientMove($cl['clid'], self::$clientsAfk[$cl["client_unique_identifier"]]);
                    	unset(self::$clientsAfk[$cl['client_unique_identifier']]);
                	}
                }

 

  • 3 tygodnie później...

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...