I've use bindatcmd to create a limited time @autoloot
this is my script
- script ATLsetTick -1,{
OnInit:
bindatcmd "atlt",strnpcinfo(3)+"::OnAtlt";
end;
OnPCLoginEvent:
if (gettimetick(2) < #atl_expire) {
attachnpctimer strcharinfo(0);
initnpctimer strnpcinfo(3);
}
end;
OnAtlt:
set #atl_expire, gettimetick(2) + 20;
announce "You have 20 second to use @atl",bc_blue|bc_self;
attachnpctimer strcharinfo(0);
initnpctimer strnpcinfo(3);
end;
OnTimer1000:
if ((#atl_expire - gettimetick(2)) == 10)
announce "10 sec left.",bc_blue|bc_self;
else if ((#atl_expire - gettimetick(2)) == 5)
announce "5 sec left.",bc_blue|bc_self;
else if (gettimetick(2) > #atl_expire) {
if (atl_check == 1) {
atcommand "@autoloot";
set atl_check, 0;
}
announce "timeout.",bc_self,0xFF0000;
stopnpctimer strnpcinfo(3);
detachnpctimer strnpcinfo(3);
}
initnpctimer strnpcinfo(3);
end;
}
- script ATLCheck -1,{
OnInit:
bindatcmd "atl",strnpcinfo(3)+"::OnAtl";
end;
OnPCLogoutEvent:
set atl_check, 0;
end;
OnAtl:
if (gettimetick(2) > #atl_expire) {
announce "You don't have permission.",bc_self,0xFF0000;
}
else {
atcommand "@autoloot";
if (atl_check == 0)
set atl_check, 1;
else if (atl_check == 1)
set atl_check, 0;
}
end;
}
it's work fine but when script end and stop the timer it always show error in console like this
how i fix this?