Only 1 Hotspot Id Can Login Together - MikroTik Script RouterOS
Make Sure that only 1 hotspot ID can log in together, if there are 2 IDs that are logged in, it will automatically turn off the first ID (note: not for multi shared users). This script is also great if we want to switch logins to other devices without having to log out and wait for the session timeout on the previous device.
Before it is installed, at least we don't understand the concept of the work of the script, don't just take it out and paste it, instead the hotspot error :)
Please install it directly on the IP -> hotspot -> User Profile -> select the profile name -> Script -> On Login
Hotspot Profile On Login
:local uname $user;
:local usercount 0;
:local usertime "00:00:00";
:local kickable;
:local maxuser 2;
:foreach i in=[/ip hotspot active find user=$uname] do= {
:local curup [/ip hotspot active get $i uptime];
:if ( $curup > $usertime ) do={
:set usertime $curup;
:set kickable $i;
}
:set usercount ($usercount+1);
}
:if ($usercount = $maxuser) do={
:log info "Login user: $uname ($usercount/$maxuser) - Oldest $usertime will be logout!";
/ip hotspot active remove numbers=$kickable;
} else {
:log info "Login user: $uname ($usercount/$maxuser)";