MyChat Scripts: mHaltUIN, shut down all MyChat Client connections by UIN

MyChat Scripts: mHaltUIN, shut down all MyChat Client connections by UIN

"For developers", "Server scripts", "Functions description", "Users", "mHaltUIN".

 

Disconnect any online user from the server and force shutting down of all his connected applications.

 

Syntax

function mHaltUIN(iUIN: integer): integer;

 

Parameters and return values

Parameter

Type

Value

iUIN

integer

online user unique ID;

 

Function result

0        all OK, N connections were disconnected;

-1        you can't shuit down the built-in bot (UIN 0);

-2        UIN must be above zero;

-3        specified user is disconnected from the server (offline).

 

Example

The function disconnects from the server and shut down all connected applications for users of the specified group.

const
  GROUP_NAME = 'External users';
var
  SL: TStringList;
  i, iUIN, iCount: integer;
begin
  SL := TStringList.Create;
  SL.CommaText := mGetUsersListInGroupByName(GROUP_NAME);
  
    if SL.Count > 0 then begin
      iCount := 0;
      
        for i := 0 to SL.Count - 1 do begin
          iUIN := StrToInt(SL[i]);
          
            if mIsUINOnline(iUIN) then begin
              mHaltUIN(iUIN);
              inc(iCount);
            end;  
        end;  
    end;  
    
  SL.Free;
  
    if iCount > 0 then mLogScript('Halted ' + IntToStr(iCount) + ' users', '');    
end.

Script work result

[18:09:47] (Log "mHaltUIN"): Halted 17 users

[18:09:47] (Run "mHaltUIN"): Script operation time: 527 ms

[18:09:47] (Run "mHaltUIN"): Script done successfully.

 

See also

Inc

IntToStr

mGetUsersListInGroupByName

mIsUINOnline

mLogScript

StrToInt