[Include] TextDraw Menu v1.0
#1

TextDraw Menu v1.1

You might have seen textdraw menus in some servers, specially cops and robbers (Crazybob's), so i decided to make something similar.

Pictures:

No items


With items




Functions:
PHP код:
TextMenuShowForPlayer(playerid,menuid,header[],content[],items=0)
TextMenuHideForPlayer(playerid
Callbacks:
PHP код:
forward OnTextMenuResponse(playerid,menuid,listitem); 
Example:
PHP код:
CMD:test(playerid)
{
    new 
Test[600],bool:necessary true;
    if(
necessary)
    {
          
strcat(Test,"~y~1-~w~ Message 1~n~");
          
strcat(Test,"~y~2-~w~ Message 2~n~");
          
strcat(Test,"~y~3-~w~ Message 3~n~");
          
strcat(Test,"~y~4-~w~ Message 4~n~");
          
strcat(Test,"~y~5-~w~ Message 5~n~");
          
strcat(Test,"~y~6-~w~ Message 6");
          
necessary false;
     }
     
TextMenuShowForPlayer(playerid,0,"Items",Test,6);
     return 
1;
}
public 
OnTextMenuResponse(playerid,menuid,listitem)
{
     if(
menuid == 0)
     {
          switch(
listitem)
          {
                case 
1:
                {
                      
//Your stuff
                
}
                case 
2:
                {
                      
//Your stuff
                
}
                case 
3:
                {
                      
//Your stuff
                
}
                case 
4:
                {
                      
//Your stuff
                
}
                case 
5:
                {
                      
//Your stuff
                
}
                case 
6:
                {
                      
//Your stuff
                
}    
          }       
     }
     return 
1;    

Download:

Pastebin
Reply
#2

Updated.
Reply
#3

There are a lot of people who will copy your example code and use it.

Код:
    new Test[600];
    strcat(Test,"~y~1-~w~ Message 1~n~");
    strcat(Test,"~y~2-~w~ Message 2~n~");
    strcat(Test,"~y~3-~w~ Message 3~n~");
    strcat(Test,"~y~4-~w~ Message 4~n~");
    strcat(Test,"~y~5-~w~ Message 5~n~");
    strcat(Test,"~y~6-~w~ Message 6");
    TextMenuShowForPlayer(playerid,0,"Items",Test,6);
Bad practice.

Код:
    TextMenuShowForPlayer(playerid,0,"Items","~y~1-~w~ Message 1~n~~y~2-~w~ Message 2~n~~y~3-~w~ Message 3~n~~y~4-~w~ Message 4~n~~y~5-~w~ Message 5~n~~y~6-~w~ Message 6",6);
or at least

Код:
static Test[600], bool:need_format = true;
if(need_format)
{
    strcat(Test,"~y~1-~w~ Message 1~n~");
    strcat(Test,"~y~2-~w~ Message 2~n~");
    strcat(Test,"~y~3-~w~ Message 3~n~");
    strcat(Test,"~y~4-~w~ Message 4~n~");
    strcat(Test,"~y~5-~w~ Message 5~n~");
    strcat(Test,"~y~6-~w~ Message 6");
    need_format = false;
}
TextMenuShowForPlayer(playerid,0,"Items",Test,6);
Reply
#4

Nice include.

Quote:
Originally Posted by Yashas
Посмотреть сообщение
There are a lot of people who will copy your example code and use it.

Код:
    new Test[600];
    strcat(Test,"~y~1-~w~ Message 1~n~");
    strcat(Test,"~y~2-~w~ Message 2~n~");
    strcat(Test,"~y~3-~w~ Message 3~n~");
    strcat(Test,"~y~4-~w~ Message 4~n~");
    strcat(Test,"~y~5-~w~ Message 5~n~");
    strcat(Test,"~y~6-~w~ Message 6");
    TextMenuShowForPlayer(playerid,0,"Items",Test,6);
Bad practice.

Код:
    TextMenuShowForPlayer(playerid,0,"Items","~y~1-~w~ Message 1~n~~y~2-~w~ Message 2~n~~y~3-~w~ Message 3~n~~y~4-~w~ Message 4~n~~y~5-~w~ Message 5~n~~y~6-~w~ Message 6",6);
or at least

Код:
static Test[600], bool:need_format = true;
if(need_format)
{
    strcat(Test,"~y~1-~w~ Message 1~n~");
    strcat(Test,"~y~2-~w~ Message 2~n~");
    strcat(Test,"~y~3-~w~ Message 3~n~");
    strcat(Test,"~y~4-~w~ Message 4~n~");
    strcat(Test,"~y~5-~w~ Message 5~n~");
    strcat(Test,"~y~6-~w~ Message 6");
    need_format = true;
}
TextMenuShowForPlayer(playerid,0,"Items",Test,6);
Tell us in which year we are at, and when you do, do not reply back.

Funniest thing is that you tried to correct him, yet you have done a mistake in your own example. Do you expect people to use it now?
Reply
#5

Quote:
Originally Posted by MikeB
Посмотреть сообщение
Nice include.



Tell us in which year we are at, and when you do, do not reply back.

Funniest thing is that you tried to correct him, yet you have done a mistake in your own example. Do you expect people to use it now?
Dude, what's wrong with you? He just tried to correct my example.

@Yashas, thanks mate, just fixed it.
Reply
#6

Quote:
Originally Posted by MikeB
Посмотреть сообщение
Tell us in which year we are at, and when you do, do not reply back.

Funniest thing is that you tried to correct him, yet you have done a mistake in your own example. Do you expect people to use it now?
We are in 2016. Good luck with dcmd, dini, etc.

That is a terrible excuse to write bad code. Also note that there are servers which lag even when you have them running on high end dedicated servers because the code is that terrible.

Moreover, the scripts are in 'PAWN'. PAWN is good at amplifying the low-performance code to make it even slower.

What is the mistake in my code?

EDIT:fixed the mistake, the 'true' must be 'false' inside the if check.

Quote:
Originally Posted by Jelly23
Посмотреть сообщение
Dude, what's wrong with you? He just tried to correct my example.

@Yashas, thanks mate, just fixed it.
It must be 'static' variables. Static variables are like global variables. They don't loose the information they hold when the function terminates.
Reply
#7

Quote:
Originally Posted by Yashas
Посмотреть сообщение
It must be 'static' variables. Static variables are like global variables. They don't loose the information they hold when the function terminates.
I do know that, i was in a hurry when i wrote it, thanks in any form.
Reply
#8

Dope
Reply
#9

Why does it appear on the far most right? I expected it to appear in the left, right? So I was thinking to change the position of the textdraws, but I don't know how. Here's the include. [click_me]


PS: If you have time to teach me how, it'd be a great help.

EDIT: Or if it really is in the right, I'm not sure about this error:

Reply
#10

Quote:
Originally Posted by NealPeteros
Посмотреть сообщение
Why does it appear on the far most right? I expected it to appear in the left, right? So I was thinking to change the position of the textdraws, but I don't know how. Here's the include. [click_me]


PS: If you have time to teach me how, it'd be a great help.

EDIT: Or if it really is in the right, I'm not sure about this error:

i suggest you to try Player/TextDrawAligment to switch it left or right or center or try using jlalt's Textdraw converter to iTD (iplomiex's td editor) or .td (adri1's TD Editor) otherwise iam not sure if editing Textdraws pos randomly may work
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)