When you send ‘Report‘ to your party all bots in party will react and run the script, responding back to that chat with the Adena and some quest item count.
So, that script could be changed to do something different.
uses
SysUtils;
var
phrases: array of string = ['Report']; // Lines to look for
function ItemCount(id: integer): int64; // Count items by ID
var
i: integer;
begin
Result := 0;
for i := 0 to Inventory.User.Count - 1 do // Iterate over user's inventory
begin
if (Inventory.User.Items(i).id = id) then // If ID matches
Inc(Result, Inventory.User.Items(i).Count); // Increase the count
end;
end;
function FindItemIDByName(itemName: string): integer;
var
i: integer;
begin
Result := -1;
for i := 0 to Inventory.User.Count - 1 do
begin
if (LowerCase(Inventory.User.Items(i).name) = LowerCase(itemName)) then
begin
Result := Inventory.User.Items(i).id;
Break;
end;
end;
end;
function FormatWithDots(Value: int64): string;
begin
Result := FormatFloat('#,##0', Value);
Result := StringReplace(Result, ',', '.', [rfReplaceAll]);
end;
procedure Report;
var
i: integer;
itemName: string;
itemID: integer;
begin
while true do
begin
Delay(100);
if (ChatMessage.ChatType = mtParty) and
(Pos('Astron', ChatMessage.Sender) > 0) and // Change to your 'main' char who will send the message
(ChatMessage.Unread) then
begin
for i := Low(phrases) to High(phrases) do
begin
if (Pos(LowerCase(phrases[i]), LowerCase(ChatMessage.Text)) > 0) then
begin
Print(ChatMessage.Sender + ': ' + ChatMessage.Text);
itemName := Trim(Copy(ChatMessage.Text, Pos(' ', ChatMessage.Text) + 1, Length(ChatMessage.Text)));
itemID := FindItemIDByName(itemName);
if itemID > -1 then
begin
if ItemCount(itemID) > 0 then
Engine.Say('Reporting ' + itemName + ': ' + FormatWithDots(ItemCount(itemID)), 3, '');
end
else
begin
if itemName = 'Status' then
begin
if User.dead then
Engine.Say('Status: Dead', 3, '')
else
Engine.Say('Status: Alive', 3, '');
end
else
begin
Engine.Say('Item ' + itemName + ' not found.', 3, '');
end;
end;
Break;
end;
end;
end;
end;
end;
begin
Script.NewThread(@Report);
delay(-1);
end.
How this script works?
Author: Velmsun