SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 30/10/2016, 11:20 PM   #1
Jelly23
Guest
 
Posts: n/a
Exclamation TextDraw Menu v1.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 Code:
TextMenuShowForPlayer(playerid,menuid,header[],content[],items=0)
TextMenuHideForPlayer(playerid
Callbacks:
PHP Code:
forward OnTextMenuResponse(playerid,menuid,listitem); 
Example:
PHP Code:
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

Last edited by Jelly23; 27/05/2017 at 07:23 PM.
  Reply With Quote
Old 01/11/2016, 12:19 PM   #2
Jelly23
Guest
 
Posts: n/a
Default Re: TextDraw Menu v1.0

Updated.
  Reply With Quote
Old 01/11/2016, 12:26 PM   #3
Yashas
Gangsta
 
Join Date: Jun 2012
Location: India
Posts: 878
Reputation: 313
Default Re: TextDraw Menu v1.0

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

Code:
    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.

Code:
    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

Code:
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);

Last edited by Yashas; 01/11/2016 at 02:14 PM.
Yashas is offline   Reply With Quote
Old 01/11/2016, 12:41 PM   #4
MikeB
Banned
 
Join Date: Mar 2014
Posts: 60
Reputation: 10
Default Re: TextDraw Menu v1.0

Nice include.

Quote:
Originally Posted by Yashas View Post
There are a lot of people who will copy your example code and use it.

Code:
    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.

Code:
    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

Code:
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?
MikeB is offline   Reply With Quote
Old 01/11/2016, 01:40 PM   #5
Jelly23
Guest
 
Posts: n/a
Default Re: TextDraw Menu v1.0

Quote:
Originally Posted by MikeB View Post
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 With Quote
Old 01/11/2016, 02:13 PM   #6
Yashas
Gangsta
 
Join Date: Jun 2012
Location: India
Posts: 878
Reputation: 313
Default Re: TextDraw Menu v1.0

Quote:
Originally Posted by MikeB View Post
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 View Post
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.
Yashas is offline   Reply With Quote
Old 01/11/2016, 02:21 PM   #7
Jelly23
Guest
 
Posts: n/a
Default Re: TextDraw Menu v1.0

Quote:
Originally Posted by Yashas View Post
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 With Quote
Old 02/11/2016, 06:26 PM   #8
Eoussama
High-roller
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 1,294
Reputation: 266
Default Re: TextDraw Menu v1.0

Dope
__________________

|===[Web taxi]===|
List of my work
Github
Pastebin

|===[Interesting topics]===|
Semantic Versioning
Eoussama is offline   Reply With Quote
Old 18/11/2016, 10:17 AM   #9
NealPeteros
Gangsta
 
NealPeteros's Avatar
 
Join Date: Dec 2015
Location: GetPlayerCountry(playerid);
Posts: 638
Reputation: 51
Default Re: TextDraw Menu v1.0

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:

__________________
Quote:
SA-MP is like a drug or alcohol or smoking.. you really get used to it and can not leave it.
NealPeteros is offline   Reply With Quote
Old 18/11/2016, 10:46 AM   #10
Zorono
Huge Clucker
 
Zorono's Avatar
 
Join Date: Dec 2015
Location: Africa, Egypt, Alexandria
Posts: 352
Reputation: 30
Default Re: TextDraw Menu v1.0

Quote:
Originally Posted by NealPeteros View Post
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
Zorono is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textdraw Menu.. TheRaGeLord Scripting Help 0 05/08/2015 01:14 PM
[Include] Textdraw Menu - v1.0 Hirsw0w Includes 27 16/02/2015 07:52 PM
Textdraw Menu ? rockhopper Scripting Help 17 09/07/2014 03:02 PM
[Pedido] TextDraw-Menu lucas_MAPPER PortuguÍs/Portuguese 9 07/10/2012 01:40 AM


All times are GMT. The time now is 12:22 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.