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:height, Float:startY, Float:maxHeight, totalItems, pageSize, currentPage = 0) {
    
// calculate how many pages can be possible
    
new pages = (totalItems / pageSize) + ((totalItems % pageSize) ? 1 : 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:y, Float:height;
    
ScrollBar(y, height, 166.5, 108.0, 100, 10); // 100 items and each page handles 10 items
    
    
scrollPTD[playerid] = CreatePlayerTextDraw(playerid, 489.0000, y, "LD_SPAC:WHITE");
    
PlayerTextDrawFont(playerid, scrollPTD[playerid], 4);
    
PlayerTextDrawLetterSize(playerid, scrollPTD[playerid], 0.0000, 18.2000);
    
PlayerTextDrawColor(playerid, scrollPTD[playerid], -16776961);
    
PlayerTextDrawSetShadow(playerid, scrollPTD[playerid], 0);
    
PlayerTextDrawSetOutline(playerid, scrollPTD[playerid], 0);
    
PlayerTextDrawBackgroundColor(playerid, scrollPTD[playerid], 255);
    
PlayerTextDrawSetProportional(playerid, scrollPTD[playerid], 1);
    
PlayerTextDrawUseBox(playerid, scrollPTD[playerid], 1);
    
PlayerTextDrawBoxColor(playerid, scrollPTD[playerid], 150);
    
PlayerTextDrawTextSize(playerid, scrollPTD[playerid], 7.5000, height);
    
PlayerTextDrawShow(playerid, scrollPTD[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:height, Float:startY, Float:maxHeight, totalItems, pageSize, currentPage = 0) {
    
// calculate how many pages can be possible
    
new pages = (totalItems / pageSize) + ((totalItems % pageSize) ? 1 : 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:y, Float:height;
    
ScrollBar(y, height, 166.5, 108.0, 100, 10); // 100 items and each page handles 10 items
    
    
scrollPTD[playerid] = CreatePlayerTextDraw(playerid, 489.0000, y, "LD_SPAC:WHITE");
    
PlayerTextDrawFont(playerid, scrollPTD[playerid], 4);
    
PlayerTextDrawLetterSize(playerid, scrollPTD[playerid], 0.0000, 18.2000);
    
PlayerTextDrawColor(playerid, scrollPTD[playerid], -16776961);
    
PlayerTextDrawSetShadow(playerid, scrollPTD[playerid], 0);
    
PlayerTextDrawSetOutline(playerid, scrollPTD[playerid], 0);
    
PlayerTextDrawBackgroundColor(playerid, scrollPTD[playerid], 255);
    
PlayerTextDrawSetProportional(playerid, scrollPTD[playerid], 1);
    
PlayerTextDrawUseBox(playerid, scrollPTD[playerid], 1);
    
PlayerTextDrawBoxColor(playerid, scrollPTD[playerid], 150);
    
PlayerTextDrawTextSize(playerid, scrollPTD[playerid], 7.5000, height);
    
PlayerTextDrawShow(playerid, scrollPTD[playerid]);
} 
thank you for this detailed example
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)