Buff time check

Examples of functions, that return buff time by ID \ name


function BuffTime(ID: integer; Obj: TL2Live = nil): cardinal;  overload;   // check the time of the object buff by ID
var i: integer;
begin
  result:= 0;
  if (Obj = nil) then Obj:= User;                 // if the object is not specified, then by default we use the user
  for i:= 0 to Obj.Buffs.Count-1 do begin         // running through the list of our buffs
    if (Obj.Buffs.Items(i).id = ID) then begin    // if id matched then
      result:= Obj.Buffs.Items(i).EndTime;        // write to the result time before the end of the buff
      break;
    end;
  end;
end;

function BuffTime(const Name: string; Obj: TL2Live = nil): cardinal;  overload;   // check the time of the object buff by name
var i: integer;
begin
  result:= 0;                                            
  if (Obj = nil) then Obj:= User;                     // if the object is not specified, then by default we use the user
  for i:= 0 to Obj.Buffs.Count-1 do begin             // running through the list of our buffs
    if (Obj.Buffs.Items(i).Name = Name) then begin    // if name matched then
      result:= Obj.Buffs.Items(i).EndTime;            // write to the result time before the end of the buff
      break;
    end;
  end;
end;

begin
  Print(BuffTime(1204));   // Print out our buff time in ms
  Print(BuffTime('Shield', User.Target));   // It prints the time of our tarff bff in ms

end.