samp.directory
← Scripts and libraries

Open-GTO/textlist

Text List system

Library★ 2updated Oct 2018MITPAWNsampctl
Open on GitHub

Install with sampctl

sampctl package install Open-GTO/textlist

Run this in your project folder. sampctl downloads the package and what it depends on.

Try it in the Pawn compiler →

Adds its include files, with the libraries it depends on, to the Pawn compiler in your browser, ready to include in a script.

Depends on 1 package

Used by 2 packages

README.md

TextList

Text Draw list system.

Screens

Working vehicle tuning system from Open-GTO gamemode. You can see sources here.

Functions

Show created TextList
TextList_Show(playerid, function[])
Open TextList
TextList_Open(playerid, function[], list_items[][], list_size = sizeof(list_items), header[] = "",
              button1[] = "", button2[] = "", Float:pos_x = 89.0, Float:pos_y = 140.0,
              select_color = 0xFFA500FF,
              lists_bg_color[TEXTLIST_MAX_ITEMS] = {0x212121A0, ...},
              lists_fg_color[TEXTLIST_MAX_ITEMS] = {0xFFFFFFFF, ...},
              header_bg_color = 0xB71C1CAA, header_fg_color = 0xFFFFFFFF,
              paginator_bg_color = 0x21212160, paginator_fg_color = 0xFFFFFFFF,
              button1_bg_color = 0x6D4C41AA, button1_fg_color = 0xFFFFFFFF,
              button2_bg_color = 0x6D4C41AA, button2_fg_color = 0xFFFFFFFF)
Close TextList
TextList_Close(playerid);
Is TextList opened
TextList_IsOpen(playerid);

Callbacks

Each TextList has its own handler function, it looks as follows:

TextListResponse:example_tl(playerid, TextListType:response, itemid, itemvalue[])
{
    return 1;
}

This function is called when a user interacts with TextList.

TextListType can have these values:

  • TextList_None
  • TextList_Button1
  • TextList_Button2
  • TextList_ListItem
  • TextList_ListUp
  • TextList_ListDown
  • TextList_Cancel

Defines

DirectiveDefault valueCan be redefined
TEXTLIST_MAX_ITEMS30yes
TEXTLIST_MAX_ITEMS_ON_LIST10yes
TEXTLIST_MAX_ITEM_NAME32no
TEXTLIST_MAX_FUNCTION_NAME31no
TEXTLIST_MAX_BUTTON_NAME12no

Usage

The system provides the ability to create a function to open TextList, this is useful when multiple calls one list (mostly used when creating nested menus):

TextListCreate:example_tl(playerid)
{
	new items[][TEXTLIST_MAX_ITEM_NAME] = {
		"Test 1",
		"Big Test 2"
	};

	new bg_colors[TEXTLIST_MAX_ITEMS] = {
		0xFF0000FF,
		0x00FF00FF
	};

	TextList_Open(playerid, TextList:example_tl, items, sizeof(items),
	              "Example header",
	              "Button 1", "Button 2",
	              .lists_bg_color = bg_colors);
}

TextListResponse:example_tl(playerid, TextListType:response, itemid, itemvalue[])
{
	new string[128];
	format(string, sizeof(string), " %d | %d | %d | %s", playerid, _:response, itemid, itemvalue);
	SendClientMessage(playerid, -1, string);
	return 1;
}

And you should use TextList_Show for opening created TextList:

TextList_Show(playerid, TextList:example_tl);

Of course you can not use the system, you can do everything without TextListCreate.

This page is built from what GitHub publishes about the repository. samp.directory does not host the code. Report a problem with this listing

Open-GTO/textlist: SA-MP Library | samp.directory