Textdraw scrollbar
#1

How to create a textdraw scrollbar like in this picture:


I have searched but can not find anything of it.
Reply
#2

idk, this thread can be usefull > https://sampforum.blast.hk/showthread.php?tid=570213
Reply
#3

Quote:
Originally Posted by Mugalito
Посмотреть сообщение
Not really, but thanks. it can be done without include.
anyone?
Reply
#4

https://sampforum.blast.hk/showthread.php?tid=636974

This thread looks very similiar to the picture you posted, you can maybe get something from the code there.
Reply
#5

posY - this will store your textdraw Y position
height - this will be your textdraw height (TextSize)
startY - put in your default position of scrollbar (where the scroll bar starts from)
maxHeight - maximum height the scollbar can have, expand your scrollbar to max and note the TextSize of Y
totalItems - how many items are there in your list
pageSize - how many items a page can display
currentPage - by default your scrollbar will start from 0, you can set this to whatever page you wish to start from

PHP код:
stock ScrollBar(&Float:posY, &Float:heightFloat:startYFloat:maxHeighttotalItemspageSizecurrentPage 0) {
    
// calculate how many pages can be possible
    
new pages = (totalItems pageSize) + ((totalItems pageSize) ? 0);
    
// scrollbar height (Y-axis)
    
height = (maxHeight pages);
    
    
// scrollbar position (Y-axis)
    // the position adjust with the page number you set in "currentPage" (0 = startY)
    
posY startY;
    
posY += (height currentPage);

Note: Use font type 4 for making scrollbar textdraw, the algorithm works perfectly for it. Recommended to use "LD_SPAC:WHITE" or "LD_SPAC:BLACK" sprites.

Example usage: (why not)
PHP код:
new PlayerText:scrollPTD[MAX_PLAYERS];
public 
OnPlayerConnect(playerid) {
    new 
Float:yFloat:height;
    
ScrollBar(yheight166.5108.010010); // 100 items and each page handles 10 items
    
    
scrollPTD[playerid] = CreatePlayerTextDraw(playerid489.0000y"LD_SPAC:WHITE");
    
PlayerTextDrawFont(playeridscrollPTD[playerid], 4);
    
PlayerTextDrawLetterSize(playeridscrollPTD[playerid], 0.000018.2000);
    
PlayerTextDrawColor(playeridscrollPTD[playerid], -16776961);
    
PlayerTextDrawSetShadow(playeridscrollPTD[playerid], 0);
    
PlayerTextDrawSetOutline(playeridscrollPTD[playerid], 0);
    
PlayerTextDrawBackgroundColor(playeridscrollPTD[playerid], 255);
    
PlayerTextDrawSetProportional(playeridscrollPTD[playerid], 1);
    
PlayerTextDrawUseBox(playeridscrollPTD[playerid], 1);
    
PlayerTextDrawBoxColor(playeridscrollPTD[playerid], 150);
    
PlayerTextDrawTextSize(playeridscrollPTD[playerid], 7.5000height);
    
PlayerTextDrawShow(playeridscrollPTD[playerid]);

Reply
#6

Quote:
Originally Posted by Gammix
Посмотреть сообщение
posY - this will store your textdraw Y position
height - this will be your textdraw height (TextSize)
startY - put in your default position of scrollbar (where the scroll bar starts from)
maxHeight - maximum height the scollbar can have, expand your scrollbar to max and note the TextSize of Y
totalItems - how many items are there in your list
pageSize - how many items a page can display
currentPage - by default your scrollbar will start from 0, you can set this to whatever page you wish to start from

PHP код:
stock ScrollBar(&Float:posY, &Float:heightFloat:startYFloat:maxHeighttotalItemspageSizecurrentPage 0) {
    
// calculate how many pages can be possible
    
new pages = (totalItems pageSize) + ((totalItems pageSize) ? 0);
    
// scrollbar height (Y-axis)
    
height = (maxHeight pages);
    
    
// scrollbar position (Y-axis)
    // the position adjust with the page number you set in "currentPage" (0 = startY)
    
posY startY;
    
posY += (height currentPage);

Note: Use font type 4 for making scrollbar textdraw, the algorithm works perfectly for it. Recommended to use "LD_SPAC:WHITE" or "LD_SPAC:BLACK" sprites.

Example usage: (why not)
PHP код:
new PlayerText:scrollPTD[MAX_PLAYERS];
public 
OnPlayerConnect(playerid) {
    new 
Float:yFloat:height;
    
ScrollBar(yheight166.5108.010010); // 100 items and each page handles 10 items
    
    
scrollPTD[playerid] = CreatePlayerTextDraw(playerid489.0000y"LD_SPAC:WHITE");
    
PlayerTextDrawFont(playeridscrollPTD[playerid], 4);
    
PlayerTextDrawLetterSize(playeridscrollPTD[playerid], 0.000018.2000);
    
PlayerTextDrawColor(playeridscrollPTD[playerid], -16776961);
    
PlayerTextDrawSetShadow(playeridscrollPTD[playerid], 0);
    
PlayerTextDrawSetOutline(playeridscrollPTD[playerid], 0);
    
PlayerTextDrawBackgroundColor(playeridscrollPTD[playerid], 255);
    
PlayerTextDrawSetProportional(playeridscrollPTD[playerid], 1);
    
PlayerTextDrawUseBox(playeridscrollPTD[playerid], 1);
    
PlayerTextDrawBoxColor(playeridscrollPTD[playerid], 150);
    
PlayerTextDrawTextSize(playeridscrollPTD[playerid], 7.5000height);
    
PlayerTextDrawShow(playeridscrollPTD[playerid]);

thank you for this detailed example
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)