[Tutorial] Dynamic Text using Object.
#1


Hello there,
Most of you know how it works but a tutorial for new developers would be helpful.

If you need to know about the usage of this tutorial, please check this thread first. [ https://sampforum.blast.hk/showthread.php?tid=626942 ]


Okay, let's start!


Things you need:
Quote:
  • Map editor [ Any ]
  • Text editor and pawn compiler [ Any ]
  • A bit knowledge about SetDynamicObjectMaterialText
  • A perfect position for perfect use.
  • ZCMD [ or any]
  • Object index knowledge.
Work steps.

Step 1.

Make an object anywhere using the editor.
Quote:

Code:
PHP код:
CreateDynamicObject(186591679.44336, -1698.8126214.57880,   0.000000.00000180.00000); // We will modify it.
CreateDynamicObject(33351679.29102, -1698.8304412.27670,   0.000000.0000090.00000); //Realistic board. 
Step 2.
Texture the objects for fit the area. [ I am doing my own, you can do as you want]

PHP код:
    TempObject CreateDynamicObject(33351679.2910, -1698.830412.27670.00000.000090.0000); //Realistic board
    
SetDynamicObjectMaterial(TempObject016093"a51_ext""ws_whitewall2_bottom"0xFFFFFFFF);
    
SetDynamicObjectMaterial(TempObject210765"airportgnd_sfse""black64"0xFFFFFFFF);
    
//Define the modifiable object using a variable
    
TextEdit CreateDynamicObject(186591679.44336, -1698.8126214.57880,   0.000000.00000180.00000); // We will modify it. 
*Note : The object should be loaded using OnGameModeInit or OnFilterScriptInit

Step 3.
Make a command as you want.
PHP код:
CMD:note(playeridparams[])
{
  return 
1;

Now, doing it without any color [ default white ]

PHP код:
CMD:note(playeridparams[])
{
   new 
string[24], //For the text
          
FontSize//Size of the font that will be used for the text
          
Text[24]; //Detects if the line is text.
   
if(sscanf(params"s[24]i"TextFontSize)) //If player don't use /note %s %i
    
{
        
SendClientMessage(playerid, -1"** *Usage*: /note [string][fontsize]");
        return 
1;
     }
    
format(stringsizeof(string), "%s"text); //Setting the string format using format();
    //replaced the string and FontSize
    
SetDynamicObjectMaterialText(TextEdit 0string90"Arial"FontSize10xFFFFFFFF0x01); 
Perfect, you have successfully done it. Have fun and improve it as you want.

Now, optional [ Color text ]
Same thing as Step 3 but the command will be using like this.

PHP код:
CMD:note(playeridparams[])
{
    new 
string[24],
          
FontSize,
          
Text[24]; 
    if(
sscanf(params"s[24]is[12]"textamountparams)) //If player don't use /note%s %i %s
    
{
        
SendClientMessage(playerid, -1"** *Usage*: /note [string][fontsize] colorname");
        return 
1;
     }
        
//if params have white color name.
    
if(!strcmp(params"white"true5))
    {
         
format(stringsizeof(string), "%s"Text);
        
SetDynamicObjectMaterialText(TextEdit 0string90"Arial"FontSize10xFFFFFFFF0x01);
    }
        
//if params have red color name.
    
else if(!strcmp(params"red"true5))
    {
         
format(stringsizeof(string), "%s"Text);
        
SetDynamicObjectMaterialText(TextEdit 0string90"Arial"FontSize10xFF0080000x01);
    }
        
//if params have golden color name.
    
else if(!strcmp(params"golden"true5))
    {
         
format(stringsizeof(string), "%s"Text);
        
SetDynamicObjectMaterialText(TextEdit 0string90"Arial"FontSize10xFFD78E100x01);
    }
    else
    {
        
SendClientMessage(playerid, -1"Pick a color name");
    }
    return 
1;

Peace

Personal notes :
  • There maybe a more advanced option for this, I am not sure.
  • Tried dynamic color name type but it doesn't support
  • Feel free to give a suggestion for improving this simple command.
  • Have fun and make more advanced thing with this.
I will make a new tutorial with advance system.
Reply
#2

Simple but Awesome! +REP
Reply
#3

Quote:
PHP код:
format(stringsizeof(string), "%s"text); //Setting the string format using format(); 
What's the point of this? Just pass text to the function directly. A screenshot of the result would also be nice.
Reply
#4

Yeah taking us to another thread to take us to something else. Just post the direct link.
Reply
#5

You simply copied and pasted code, there's no definition of what each function does. Can't call this a tutorial but more of a.. guide?
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
What's the point of this? Just pass text to the function directly. A screenshot of the result would also be nice.
Thanks for the tip. Ya, it can be done, without format, just putting the Text directly in the SetDynamicObjectMaterialText would be a great, thanks for the feedback.

About the result, I have linked the showcase that I made before. This is the tutorial of how I did that.
You may check the video here [ https://www.youtube.com/watch?v=4ClfJ1g8ddg ]

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Yeah taking us to another thread to take us to something else. Just post the direct link.
Didn't get you mate. I have linked only two links, the showcase that I created and SetDynamicObjectMaterialText, what's the problem then?

Quote:
Originally Posted by Meller
Посмотреть сообщение
You simply copied and pasted code, there's no definition of what each function does. Can't call this a tutorial but more of a.. guide?
copied and pasted from where? The current definition is enough, where you are not understanding, I will provide more detail if you want.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)