How to get this ...
#5

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
Reply


Messages In This Thread
How to get this ... - by OTACON - 25.09.2012, 20:11
Re : How to get this ... - by Varkoll_ - 25.09.2012, 20:13
Re: Re : How to get this ... - by .v - 25.09.2012, 20:36
Re: Re : How to get this ... - by clarencecuzz - 25.09.2012, 23:55
Respuesta: Re: Re : How to get this ... - by OTACON - 26.09.2012, 00:32

Forum Jump:


Users browsing this thread: 3 Guest(s)