MyChat Scripts Engine: mDecUIN, revious UIN of a registered user
"For developers", "Server scripts", "Functions description", "Users", "mDecUIN".
Get the previous unique number (UIN) of a registered user on the server.
Users UINs are unique and never repeated. UIN=0 is for built-in bot Elisa, UIN=1 is an Administrator for managing the server. All other users can be created and deleted, but free UINs can't be used to save databases integrity.
To sort out existing user UINs, avoiding gaps, it is better using functions mlncUIN and mDecUIN.
Syntax
function mDecUIN(iUIN: integer): integer;
Parameters and return values
Parameter |
Type |
Value |
iUIN |
integer |
unique user identifier from which you need to get the previous ID. |
Function result
>0 previous UIN;
-1 first UIN does not exist on the server;
-2 no UINs, we reached the first one.
Example
Sorting out all registered users starting from the last one and counting those who have a profile photo and who does not.
var
iUIN, iCountWithPhoto, iCountWithoutPhoto: integer;
begin
iUIN := mGetMaxRegisteredUIN;
iCountWithPhoto := 0;
iCountWithoutPhoto := 0;
repeat
if mGetUserAttribute(iUIN, 'FotoCRC32') = '0' then inc(iCountWithoutPhoto)
else inc(iCountWithPhoto);
iUIN := mDecUIN(iUIN);
until iUIN < 0;
mLogScript('Users with/without photos: ' + IntToStr(iCountWithPhoto) + ' / ' + IntToStr(iCountWithoutPhoto), '');
end.
Script work result
[20:24:19] (Log "mDecUIN"): Users with/without photos: 286 / 7704
[20:24:19] (Run "mDecUIN"): Script operation time: 106 ms
[20:24:19] (Run "mDecUIN"): Script done successfully.