Change a user rights group.

 

Syntax

function mSetUserRoleID(iUIN, iRole: integer): integer;

 

Parameters and return values

Parameter

Type

Value

iUIN

integer

unique user identifier;

iRole

integer

identifier of a new rights group.

 

Function result

0

no errors;

-1

you can't change rights group for the built-in bot (UIN = 0);

-2

such user UIN does not exist;

-3

invalid rights group identifier.

 

Example

const
  ROLE_NAME = 'Administrators';
  USER_UIN = 30;
var
  iRoleID, iResult: integer;
begin
  iRoleID := mGetRoleIDByName(ROLE_NAME);
  
    if iRoleID <> -1 then begin
      mLogScript('Role ID: ' + IntToStr(iRoleID), '');
      iResult := mSetUserRoleID(USER_UIN, iRoleID);
      
        case iResult of
          0: mLogScript('All ok!', '0');
          -1: mLogScript('You can''t use UIN = 0', '-1');
          -2: mLogScript('User doesn''t exist', '-2');
          -3: mLogScript('Wrong role id', '-3');
        end;
    end;
end.

Script work result

[17:05:07] (Log "mSetUserRoleID"): Role ID: 13

[17:05:07] (Log "mSetUserRoleID"): [0] All ok!

[17:05:07] (Run "mSetUserRoleID"): Script operation time: 29 ms

[17:05:07] (Run "mSetUserRoleID"): Script done successfully.

 

See also

IntToStr

mGetRoleIDByName

mLogScript