SA-MP Forums Archive
How to get this ... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to get this ... (/showthread.php?tid=380522)



How to get this ... - OTACON - 25.09.2012

Hi all, I wanted to know how I can get the X and Y position of a TextDraw and display it in a printf?.

Thanks in advance.

Sorry for my Inglйs.


Re : How to get this ... - Varkoll_ - 25.09.2012

I don't understand... When you create a textdraw, you know the X and Y position... If you want to replace your textdraw, use a textdraw editor...


Re: Re : How to get this ... - .v - 25.09.2012

Quote:
Originally Posted by leo3412
Посмотреть сообщение
I don't understand... When you create a textdraw, you know the X and Y position... If you want to replace your textdraw, use a textdraw editor...
Exactly the easier way to get the X,Y,Z is to use an texdraw editor. And What I don't understand is "display it in a printf?."


Re: Re : How to get this ... - clarencecuzz - 25.09.2012

Quote:
Originally Posted by .v
Посмотреть сообщение
Exactly the easier way to get the X,Y,Z is to use an texdraw editor. And What I don't understand is "display it in a printf?."
Obviously they want to get the X and Y coordinates of the textdraw and use it in printf.

Example:
pawn Код:
printf("Textdraw | X = %.2f, Y = %.2f",X, Y);
Credits to Nero_3D:
pawn Код:
stock Float: TextDrawCoords[Text: (MAX_TEXT_DRAWS * 2)] = {-1.0, ...};
#define TextDrawCoords[%0][%1] TextDrawCoords[(%0) + Text: (MAX_TEXT_DRAWS * (%1))]
stock Text: TextDrawCreateEx(Float:x, Float:y, text[])
{    
    new Text: gtext = TextDrawCreate(x, y, text);    
    if(gtext != Text: INVALID_TEXT_DRAW)
    {        
        TextDrawCoords[gtext][0] = x;        
        TextDrawCoords[gtext][1] = y;    
    }    
    return gtext;
}
#define TextDrawCreate TextDrawCreateEx
stock TextDrawDestroyEx(Text:text)
{    
    if(TextDrawDestroy(text))
    {        
        TextDrawCoords[text][0] = TextDrawCoords[text][1] = -1.0;        
        return true;    
    }    
    return false;
}
#define TextDrawDestroy TextDrawDestroyEx
stock TextDrawGetPos(Text:text, &Float:x, &Float:y)
{    
    if(TextDrawCoords[text][0] != -1.0)
    {        
        x = TextDrawCoords[text][0];        
        y = TextDrawCoords[text][1];        
        return true;    
    }    
    return false;
}
Example of it's use for printf:
pawn Код:
CMD:gettextpos(playerid,params[])
{
    TextDrawGetPos(MyTextdraw, TEXTPOSX, TEXTPOSY);
    printf("MyTextdraw: X: %.2f | Y: %.2f",TEXTPOSX, TEXTPOSY);
    return 1;
}



Respuesta: Re: Re : How to get this ... - OTACON - 26.09.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Obviously they want to get the X and Y coordinates of the textdraw and use it in printf.

Example:
pawn Код:
printf("Textdraw | X = %.2f, Y = %.2f",X, Y);
Credits to Nero_3D:
pawn Код:
stock Float: TextDrawCoords[Text: (MAX_TEXT_DRAWS * 2)] = {-1.0, ...};
#define TextDrawCoords[%0][%1] TextDrawCoords[(%0) + Text: (MAX_TEXT_DRAWS * (%1))]
stock Text: TextDrawCreateEx(Float:x, Float:y, text[])
{    
    new Text: gtext = TextDrawCreate(x, y, text);    
    if(gtext != Text: INVALID_TEXT_DRAW)
    {        
        TextDrawCoords[gtext][0] = x;        
        TextDrawCoords[gtext][1] = y;    
    }    
    return gtext;
}
#define TextDrawCreate TextDrawCreateEx
stock TextDrawDestroyEx(Text:text)
{    
    if(TextDrawDestroy(text))
    {        
        TextDrawCoords[text][0] = TextDrawCoords[text][1] = -1.0;        
        return true;    
    }    
    return false;
}
#define TextDrawDestroy TextDrawDestroyEx
stock TextDrawGetPos(Text:text, &Float:x, &Float:y)
{    
    if(TextDrawCoords[text][0] != -1.0)
    {        
        x = TextDrawCoords[text][0];        
        y = TextDrawCoords[text][1];        
        return true;    
    }    
    return false;
}
Example of it's use for printf:
pawn Код:
CMD:gettextpos(playerid,params[])
{
    TextDrawGetPos(MyTextdraw, TEXTPOSX, TEXTPOSY);
    printf("MyTextdraw: X: %.2f | Y: %.2f",TEXTPOSX, TEXTPOSY);
    return 1;
}
Thanks, I'll try with that