i need help to fix this script

:global maxu
:global maxd
:set maxd 4096
:set maxu 256
:local numUsers 0;
:foreach user in=[/ip hotspot host find] do={:set numUsers ($numUsers + 1)};
/ip hotspot host;
:foreach ew in=[find]
do={
:local ip [get $ew address];
:local user [get $ew address];
:local na [get $ew to-address];\

:foreach user in=[/ip hotspot active find] do={
:local username [/ip hotspot active get $user user];

:set maxd (($maxd / $numUsers).“k”);
:set maxu (($maxu / $numUsers).“k”);
:if ($ip = $na )
do={ /queue simple ;
remove [find comment=$username] ;
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s comment=“$username” direction=both disabled=no
interface=all limit-at=“$maxu/$maxd” max-limit=“$maxu/$maxd” name=$ip packet-marks=“” parent=none priority=4
queue=default-small/default-small target-addresses=$ip total-queue=default-small;\

/queue simple move [find name=cache] 1;
/queue simple move [find comment=$username] 1

}}}

I fix syntax and logical errors.
It’s full of errors…

I hope I have understand what do you want to do…

Script for RouterOS 6.7+

:global maxu value=4096;
:global maxd value=256;
:local numUsers value=[:len [/ip hotspot host find]];
:if ($numUsers > 0) do {
 :set maxu value=(($maxu / $numUsers)."k");
 :set maxd value=(($maxd / $numUsers)."k");
 :foreach tmpHost in=[/ip hotspot host find] do={
  :local hostMAC value=[/ip hotspot host get $tmpHost value-name=mac-address];
  :local hostIP value=[/ip hotspot host get $tmpHost value-name=address];
  :foreach tmpUser in=[/ip hotspot active find] do={
   :local username value=[/ip hotspot active get $tmpUser value-name=user];
   :local userMAC value=[/ip hotspot active get $tmpUser value-name=mac-address];
   :if ($hostMAC = $userMAC ) do={
    /queue simple remove [find where comment=$username];
    /queue simple add comment="$username" disabled=no  limit-at="$maxu/$maxd" max-limit="$maxu/$maxd" name=$hostIP parent=none priority=4/4 target=$hostIP;
   }
  }
 }
}

Script for RouterOS 5.26

:global maxu value=4096;
:global maxd value=256;
:local numUsers value=[:len [/ip hotspot host find]];
:if ($numUsers > 0) do {
 :set maxu value=(($maxu / $numUsers)."k");
 :set maxd value=(($maxd / $numUsers)."k");
 :foreach tmpHost in=[/ip hotspot host find] do={
  :local hostMAC value=[/ip hotspot host get $tmpHost value-name=mac-address];
  :local hostIP value=[/ip hotspot host get $tmpHost value-name=address];
  :foreach tmpUser in=[/ip hotspot active find] do={
   :local username value=[/ip hotspot active get $tmpUser value-name=user];
   :local userMAC value=[/ip hotspot active get $tmpUser value-name=mac-address];
   :if ($hostMAC = $userMAC ) do={
    /queue simple remove [find where comment=$username];
    /queue simple add comment="$username" disabled=no  limit-at="$maxu/$maxd" max-limit="$maxu/$maxd" name=$hostIP parent=none priority=4 target=$hostIP;
   }
  }
 }
}

thank you

you is the best

Thank you for job

this script like the first i fixed it use to {{ auto Division download & upload Between users Equality }} its work
please try it and rply what Do you think


/queue simple ;
remove [find comment="newmind"] ;


/ip hotspot host;
:foreach i in=[find]
do={
:local ip [get $i address];
:local down 4096
:local upl 256
:local r [:len [find]]
:local downlo ((down / r)*1000);
:local uplo ((upl / r)*1000);
:local aspeed ("$uplo"."/"."$downlo")

/queue simple ;
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s comment=newmind direction=both disabled=no
interface=all limit-at=$aspeed max-limit=$aspeed name=$ip packet-marks="" parent=none priority=4
queue=default-small/default-small target-addresses=$ip total-queue=default-small;\

}}}}

\



and i need to try to use the script Which you fixed thank you again

I answer you in other thread:
http://forum.mikrotik.com/t/auto-division-download-upload-between-users-equality/76546/1

The script of this factitious I think you’re Egyptian
A script is generally true

:global active
:global uspeed 8100
:global dspeed 2048
:global maxu
:global maxd
:global overu
:global overd
:global maxactive 20
:set active ( [:len [/ip hotspot active find]] )
:set maxd (($uspeed / $active)*1000)
:set maxu (($dspeed / $active)*1000)
:set overu ((($uspeed / $active)*1000)+(180*1000))
:set overd ((($dspeed / $active)*1000)+(60*1000))
/ip hotspot active ;\
:foreach nm in=[find]\
do={\
:local ip [get $nm address]
:local mind [get $nm user];\
:if ( $active > $maxactive )\
do={/queue simple ;\
remove [find name=$mind] ;\
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s comment=newmind direction=both disabled=no \
    interface=all limit-at="$overd/$overu" max-limit="$overd/$overu" name=$mind packet-marks="" parent=none priority=4 \
    queue=default-small/default-small target-addresses=$ip total-queue=default-small;} else={ /queue simple ;\
remove [find name=$mind] ;\
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s comment=newmind direction=both disabled=no \
    interface=all limit-at="$maxu/$maxd" max-limit="$maxu/$maxd" name=$mind packet-marks="" parent=none priority=4 \
    queue=default-small/default-small target-addresses=$ip total-queue=default-small;\
}}