Multipage Textdraw?
#1

Code creating TDs:
OnPlayerConnect
Код:
for(new a = 0; a < MAX_ITEMS_PER_PAGE; a++){ // MAX_ITEMS_PER_PAGE id not good, is 16, but must behigher...
    if((a % 4) == 0 && a >= 4){
        Textdraw[playerid][TD_Items][a] = CreatePlayerTextDraw(playerid, startPosX, startPosY, "Preview_Model");
        startPosX = 32.000000;
        startPosY += addToStartPosY;
    }
    Textdraw[playerid][TD_Items][a] = CreatePlayerTextDraw(playerid, startPosX, startPosY, "Preview_Model");
    startPosX += addToStartPosX;
    PlayerTextDrawFont(playerid, Textdraw[playerid][TD_Items][a], 5);
    PlayerTextDrawLetterSize(playerid, Textdraw[playerid][TD_Items][a], 0.600000, 2.000000);
    PlayerTextDrawTextSize(playerid, Textdraw[playerid][TD_Items][a], 37.500000, 34.500000);
    PlayerTextDrawSetOutline(playerid, Textdraw[playerid][TD_Items][a], 0);
    PlayerTextDrawSetShadow(playerid, Textdraw[playerid][TD_Items][a], 0);
    PlayerTextDrawAlignment(playerid, Textdraw[playerid][TD_Items][a], 1);
    PlayerTextDrawColor(playerid, Textdraw[playerid][TD_Items][a], -1);
    PlayerTextDrawBackgroundColor(playerid, Textdraw[playerid][TD_Items][a], 125);
    PlayerTextDrawBoxColor(playerid, Textdraw[playerid][TD_Items][a], 1097458175);
    PlayerTextDrawUseBox(playerid, Textdraw[playerid][TD_Items][a], 0);
    PlayerTextDrawSetProportional(playerid, Textdraw[playerid][TD_Items][a], 1);
    PlayerTextDrawSetSelectable(playerid, Textdraw[playerid][TD_Items][a], 1);
    PlayerTextDrawSetPreviewModel(playerid, Textdraw[playerid][TD_Items][a], Weapon[a][ItemID]);
    PlayerTextDrawSetPreviewRot(playerid, Textdraw[playerid][TD_Items][a], -115.000000, -108.000000, -90.000000, 0.579999);
}

Textdraw[playerid][TD_BackPage] = CreatePlayerTextDraw(playerid, 45.000000, 324.000000, "<<");
PlayerTextDrawFont(playerid, Textdraw[playerid][TD_BackPage], 2);
PlayerTextDrawLetterSize(playerid, Textdraw[playerid][TD_BackPage], 0.258332, 1.750000);
PlayerTextDrawTextSize(playerid, Textdraw[playerid][TD_BackPage], 20.000000, 29.000000);
PlayerTextDrawSetOutline(playerid, Textdraw[playerid][TD_BackPage], 1);
PlayerTextDrawSetShadow(playerid, Textdraw[playerid][TD_BackPage], 0);
PlayerTextDrawAlignment(playerid, Textdraw[playerid][TD_BackPage], 2);
PlayerTextDrawColor(playerid, Textdraw[playerid][TD_BackPage], -1);
PlayerTextDrawBackgroundColor(playerid, Textdraw[playerid][TD_BackPage], 255);
PlayerTextDrawBoxColor(playerid, Textdraw[playerid][TD_BackPage], 200);
PlayerTextDrawUseBox(playerid, Textdraw[playerid][TD_BackPage], 1);
PlayerTextDrawSetProportional(playerid, Textdraw[playerid][TD_BackPage], 1);
PlayerTextDrawSetSelectable(playerid, Textdraw[playerid][TD_BackPage], 1);

Textdraw[playerid][TD_NextPage] = CreatePlayerTextDraw(playerid, 83.000000, 324.000000, ">>");
PlayerTextDrawFont(playerid, Textdraw[playerid][TD_NextPage], 2);
PlayerTextDrawLetterSize(playerid, Textdraw[playerid][TD_NextPage], 0.258332, 1.750000);
PlayerTextDrawTextSize(playerid, Textdraw[playerid][TD_NextPage], 20.000000, 29.000000);
PlayerTextDrawSetOutline(playerid, Textdraw[playerid][TD_NextPage], 1);
PlayerTextDrawSetShadow(playerid, Textdraw[playerid][TD_NextPage], 0);
PlayerTextDrawAlignment(playerid, Textdraw[playerid][TD_NextPage], 2);
PlayerTextDrawColor(playerid, Textdraw[playerid][TD_NextPage], -1);
PlayerTextDrawBackgroundColor(playerid, Textdraw[playerid][TD_NextPage], 255);
PlayerTextDrawBoxColor(playerid, Textdraw[playerid][TD_NextPage], 200);
PlayerTextDrawUseBox(playerid, Textdraw[playerid][TD_NextPage], 1);
PlayerTextDrawSetProportional(playerid, Textdraw[playerid][TD_NextPage], 1);
PlayerTextDrawSetSelectable(playerid, Textdraw[playerid][TD_NextPage], 1);
in OnPlayerClickPlayerTextDraw:
Код:
if(playertextid == Textdraw[playerid][TD_BackPage]){
    BackPage(playerid);
    return 1;
} else if(playertextid == Textdraw[playerid][TD_NextPage]){
    NextPage(playerid);
    return 1;
}
I don't know what functions NextPage and BackPage should contain..
Hello, I create textdraws with preview models, but I don't know how to create multipages (or scrollbar...).

Someone have any suggest for me?

Possibly it can be scrollbar, but i also don't know how to do it...
Reply
#2

If you're doing a next page and back page it's simple.

Hide the textdraws for the page you're on using PlayerTextDrawHide. Then simply show the textdraws for the new page using PlayerTextDrawShow.

Use a variable to define which page the player is on.

Should look like this:

PHP код:

new textdrawsPage[MAX_PLAYERS];
/*if player types /mytextdraws then:*/
textdrawsPage[playerid] = 1;
/*good idea to hide all pages before showing page one, just in case they already had the textdraws open.*/
PlayerTextDrawHide(playerid, */all textdraw names*/); /*most likely need to copy and paste this quite a few times, might be worth putting into it's own function as well, up to you.*/
PlayerTextDrawShow(playerid, */page1 textdraw names*/); /*most likely multiple lines*/
/*Backpage Function*/
switch(textdrawsPage[playerid])
{
   case 
1/*In this case you could either hide all the textdraws or simply do nothing because they're on page 1*/ textdrawsPage[playerid] = /*0 to close, or just leave this bit out*/;
   case 
2/*You would then hide all page 2 textdraws and show all page 1 textdraws*/ textdrawsPage[playerid]--1;
   case 
3/*etc...etc...*/ textdrawsPage[playerid]--1;
   
/*etc...etc...*/
}
/*Next page would be same as Back page but opposite, you'd increase textdrawsPage and hide page you're on and show the page above. 
Small tips:
When you're creating the textdraws, put your pages in arrays, that way when you're showing/hiding the textdraws, you can do it in a for loop.
Also you could then combine that and make 2 functions to show pages and hide pages, that way it keeps you from copy and pasting over and over

Hope this helps.
Reply
#3

Thank you @ItsRobinson for the answer.
Sill I don't understand, how to whis will be working...
How I get current items? And how to get previous items?


Textdraw create code:
Код:
new Float:startPosX = 32.000000,
    Float:addToStartPosX = 42.000000,
    Float:startPosY = 150.000000,
    Float:addToStartPosY = 39.000000;
for(new a = 0; a < sizeof(Items); a++){
    if((a % 16) == 0){
        startPosY = 150.000000;
    }
    if((a % 4) == 0 && a >= 4){
        Textdraw[playerid][TD_Items][a] = CreatePlayerTextDraw(playerid, startPosX, startPosY, "Preview_Model");
        startPosX = 32.000000;
        startPosY += addToStartPosY;
    }
    Textdraw[playerid][TD_Items][a] = CreatePlayerTextDraw(playerid, startPosX, startPosY, "Preview_Model");
    startPosX += addToStartPosX;
    PlayerTextDrawFont(playerid, Textdraw[playerid][TD_Items][a], 5);
    PlayerTextDrawLetterSize(playerid, Textdraw[playerid][TD_Items][a], 0.600000, 2.000000);
    PlayerTextDrawTextSize(playerid, Textdraw[playerid][TD_Items][a], 37.500000, 34.500000);
    PlayerTextDrawSetOutline(playerid, Textdraw[playerid][TD_Items][a], 0);
    PlayerTextDrawSetShadow(playerid, Textdraw[playerid][TD_Items][a], 0);
    PlayerTextDrawAlignment(playerid, Textdraw[playerid][TD_Items][a], 1);
    PlayerTextDrawColor(playerid, Textdraw[playerid][TD_Items][a], -1);
    PlayerTextDrawBackgroundColor(playerid, Textdraw[playerid][TD_Items][a], 125);
    PlayerTextDrawBoxColor(playerid, Textdraw[playerid][TD_Items][a], 1097458175);
    PlayerTextDrawUseBox(playerid, Textdraw[playerid][TD_Items][a], 0);
    PlayerTextDrawSetProportional(playerid, Textdraw[playerid][TD_Items][a], 1);
    PlayerTextDrawSetSelectable(playerid, Textdraw[playerid][TD_Items][a], 1);
    PlayerTextDrawSetPreviewModel(playerid, Textdraw[playerid][TD_Items][a], ClothesHead[a][ItemID]);
    PlayerTextDrawSetPreviewRot(playerid, Textdraw[playerid][TD_Items][a], -115.000000, -108.000000, -90.000000, 0.579999);
}
Count of items depends on the array size (Items). Per page it's now 16. 4x4. Like this:

****
****
****
****


I don't know how many page will be there, because I will be add items to the array. is there any way to automate this?
Reply
#4

I'm gonna suggest mSelection to make your life easier
Reply
#5

Thank you, I will try this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)