Community discussions

MikroTik App
 
anassar26
just joined
Topic Author
Posts: 21
Joined: Sun Aug 02, 2020 3:20 pm

Please help to modify script to rest counters for specified hotspot user

Tue Jun 04, 2024 10:26 pm

Can you help me with the error in the following script, as it a rest the counters for all users and not the users specified in the script
# Define the list of specific users
:local userList {"user1"; "user2"; "user3"}

# Iterate over all hotspot users
:foreach user in=[/ip hotspot user find] do={
    :local userName [/ip hotspot user get $user name]
    
    # Check if the user is in the specified user list
    :if ([:find $userList $userName] != -1) do={
        # Reset the user's counters
        /ip hotspot user reset-counters $user
        
        :log info ("Counters for user " . $userName . " have been reset")
    }
}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12562
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help to modify script to rest counters for specified hotspot user

Wed Jun 05, 2024 12:55 am

Thsi script is like ChatGPT sh*t

Who is online

Users browsing this forum: No registered users and 9 guests