Home API Manuals About Forum
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

SendGumpToClient

Shows a gump built by the script in the UO client connected to Stealth, and returns the Serial Stealth assigned to it. Use it to make your own in-game menus: script control, settings, choices.

The gump is described by a TGumpInfo record — the same record GetGumpInfo returns. You can take a server gump with GetGumpInfo, change it and send it, or fill a record from scratch.

The client’s answer never goes to the game server. It stays in Stealth: the evClientGumpReply event fires, and the answer is read with ClientGumpResponse (check it with ClientGumpResponsePresent or wait with WaitForClientGumpResponse). Server gumps keep working as before.

How the record is used:

  • Serial in the record is ignored. Stealth issues its own serials from $7F000001 upward, so they do not collide with server gumps; use the returned value to match the answer.
  • GumpID is taken from the record. The client replaces an open gump with the same GumpID, so one GumpID per menu lets you redraw it in place. 0 means the Stealth default $53544C47.
  • X, Y, the No* flags and all element arrays are sent as they are. Elements are ordered by Page, then by ElemNum; in a record filled from scratch you may leave every ElemNum at 0 — then the order is backgrounds, pictures, text, then buttons and inputs.
  • Text elements refer to the Text array by index (text_id). For a text entry, a non-empty Value wins over its text line; an entry whose default_text_id points outside Text gets a new line with its Value.
  • Not sent: TextEntriesLimited go out as plain text entries (the length limit is not kept in TGumpInfo), unknown layout commands, mastergump.

Such gumps are not part of Stealth’s gump list: they are not counted by GetGumpsCount, and NumGump*, GumpAuto* and WaitGump do not touch them. After the client reconnects they are sent again together with the server gumps. Close one with CloseClientGump by its GumpID.

Returns 0 if the gump does not fit into one packet (64 KB), if the script is stopping, or — for external scripts — if the record arrived damaged.

Показывает гамп, собранный скриптом, в UO-клиенте, подключённом к Stealth, и возвращает Serial, который Stealth ему выдал. Подходит для собственных меню в игре: управление скриптами, настройки, выбор вариантов.

Гамп описывается записью TGumpInfo — той же, что возвращает GetGumpInfo. Можно взять серверный гамп через GetGumpInfo, поправить и отправить, а можно заполнить запись с нуля.

Ответ клиента никогда не уходит на игровой сервер. Он остаётся в Stealth: срабатывает событие evClientGumpReply, а сам ответ читается через ClientGumpResponse (проверить — ClientGumpResponsePresent, дождаться — WaitForClientGumpResponse). Серверные гампы работают как раньше.

Как используется запись:

  • Serial из записи не используется. Stealth выдаёт свои serial начиная с $7F000001, поэтому они не пересекаются с серверными гампами; ответ сопоставляйте по возвращённому значению.
  • GumpID берётся из записи. Клиент заменяет открытый гамп с тем же GumpID, так что один GumpID на меню позволяет перерисовывать его на месте. 0 — GumpID Stealth по умолчанию, $53544C47.
  • X, Y, флаги No* и все массивы элементов уходят как есть. Порядок элементов — по Page, затем по ElemNum; в записи, заполненной с нуля, все ElemNum можно оставить 0 — тогда порядок такой: фоны, картинки, текст, затем кнопки и поля ввода.
  • Текстовые элементы ссылаются на массив Text по индексу (text_id). У поля ввода непустое Value важнее его строки; поле, у которого default_text_id указывает за пределы Text, получает новую строку со своим Value.
  • Не передаются: TextEntriesLimited уходят как обычные поля ввода (ограничение длины в TGumpInfo не хранится), неизвестные команды раскладки, mastergump.

Такие гампы не входят в список гампов Stealth: их не считает GetGumpsCount, на них не действуют NumGump*, GumpAuto* и WaitGump. После переподключения клиента они отправляются заново вместе с серверными. Закрыть — CloseClientGump по GumpID.

Возвращает 0, если гамп не помещается в один пакет (64 КБ), если скрипт останавливается или — для внешних скриптов — если запись пришла повреждённой.

Pascal

function SendGumpToClient(const Gump: TGumpInfo): Cardinal;

Parameters:

Python

def SendGumpToClient(Gump: GumpInfo) -> int: ...

In Python the header fields live in GumpInfo.gump (Serial, GumpID, X, Y, Pages, NoMove, NoResize, NoDispose, NoClose), element fields are in CamelCase (ReleasedID, ReturnValue, …), and Text is a list of Text objects. The struct types are imported from py_astealth.stealth_structs.

В Python поля заголовка лежат в GumpInfo.gump, поля элементов — в CamelCase (ReleasedID, ReturnValue, …), а Text — список объектов Text. Типы структур импортируются из py_astealth.stealth_structs.

Pascal Example

A small menu: one checkbox, one text entry, OK and Cancel.

var
  G: TGumpInfo;
  Bg: TResizePic;
  T: TGumpText;
  C: TCheckBox;
  E: TTextEntry;
  B: TGumpButton;
  Serial: Cardinal;
  R: TClientGumpResponse;
begin
  G.GumpID := 1001;
  G.X := 100;
  G.Y := 100;

  Bg.x := 0; Bg.y := 0; Bg.gump_id := 9200; Bg.width := 260; Bg.height := 150;
  SetLength(G.ResizePics, 1);
  G.ResizePics[0] := Bg;

  SetLength(G.Text, 1);
  G.Text[0] := 'Loot gold only';
  T.x := 45; T.y := 20; T.color := 0; T.text_id := 0;
  SetLength(G.GumpText, 1);
  G.GumpText[0] := T;

  C.x := 15; C.y := 20; C.released_id := 210; C.pressed_id := 211;
  C.status := 1; C.return_value := 10;
  SetLength(G.CheckBoxes, 1);
  G.CheckBoxes[0] := C;

  E.x := 15; E.y := 55; E.width := 200; E.height := 20; E.color := 0;
  E.return_value := 20; E.default_text_id := -1; E.Value := 'Britain';
  SetLength(G.TextEntries, 1);
  G.TextEntries[0] := E;

  SetLength(G.GumpButtons, 2);
  B.x := 15; B.y := 100; B.released_id := 4005; B.pressed_id := 4006;
  B.quit := 1; B.page_id := 0; B.return_value := 1;   // OK
  G.GumpButtons[0] := B;
  B.x := 130; B.return_value := 2;                     // Cancel
  G.GumpButtons[1] := B;

  Serial := SendGumpToClient(G);
  if WaitForClientGumpResponse(Serial, 60000) then
  begin
    R := ClientGumpResponse(Serial);
    // Switches holds the return_value of every checked checkbox
    if R.ButtonID = 1 then
      AddToSystemJournal('OK, checked: ' + IntToStr(Length(R.Switches)) +
        ', city: ' + R.TextEntries[0].Text);
  end;
end.

Python Example

from dataclasses import fields
from py_astealth.stealth_structs import (GumpInfo, Gump, GumpResizePic, GumpText, Text,
                                         GumpCheckBox, GumpTextEntry, GumpButton)


def new_gump(gump_id, x, y):
    lists = {f.name: [] for f in fields(GumpInfo) if f.name != 'gump'}
    header = Gump(Serial=0, GumpID=gump_id, X=x, Y=y, Pages=0,
                  NoMove=False, NoResize=False, NoDispose=False, NoClose=False)
    return GumpInfo(gump=header, **lists)


g = new_gump(1001, 100, 100)
g.ResizePics.append(GumpResizePic(X=0, Y=0, GumpID=9200, Width=260, Height=150, Page=0, ElemNum=0))
g.Text.append(Text('Loot gold only'))
g.GumpText.append(GumpText(X=45, Y=20, Color=0, TextID=0, Page=0, ElemNum=0))
g.CheckBoxes.append(GumpCheckBox(X=15, Y=20, ReleasedID=210, PressedID=211,
                                 Status=1, ReturnValue=10, Page=0, ElemNum=0))
g.TextEntries.append(GumpTextEntry(X=15, Y=55, Width=200, Height=20, Color=0, ReturnValue=20,
                                   DefaultTextID=-1, RealValue='Britain', Page=0, ElemNum=0))
g.GumpButtons.append(GumpButton(X=15, Y=100, ReleasedID=4005, PressedID=4006,
                                Quit=1, PageID=0, ReturnValue=1, Page=0, ElemNum=0))   # OK
g.GumpButtons.append(GumpButton(X=130, Y=100, ReleasedID=4005, PressedID=4006,
                                Quit=1, PageID=0, ReturnValue=2, Page=0, ElemNum=0))   # Cancel

serial = SendGumpToClient(g)
if WaitForClientGumpResponse(serial, 60000):
    r = ClientGumpResponse(serial)
    if r.ButtonID == 1:
        AddToSystemJournal(f'OK, gold only: {10 in r.Switches}, city: {r.TextEntries[0].Text}')

Resend a server gump to the client with a different position:

gi = GetGumpInfo(0)
gi.gump.X, gi.gump.Y = 300, 50
serial = SendGumpToClient(gi)

See Also

ClientGumpResponse, ClientGumpResponsePresent, WaitForClientGumpResponse, CloseClientGump, GetGumpInfo, evClientGumpReply, Gumps