I have the following line of code:
textprintf_ex(buffer, font, p1stuff.chp + "/" + p1stuff.mhp, 705, 501, color_text, -1);
I am getting errors concerning using the variables in the string. The variables represent current hit points and max hit points. How can I make this work properly?
Thanks in advance,Jim
Are you using C++? It seems so. If you are using C:
char temp[512]; snprintf(temp, sizeof(temp), "%d/%d", p1stuff.chp, p1stuff.mhp); textprintf_ex(buffer, font, temp, 705, 501, color_text, -1);
If you are using C++ and STL (not tested):
// textprintf_ex needs a char pointer, not a string, so I construct a // temporary string and call c_str(), which returns "a pointer to a // null-terminated array of characters representing the string's contents" // according to the STL documentation. textprintf_ex(buffer, font, string(p1stuff.chp + "/" + p1stuff.mhp).c_str(), 705, 501, color_text, -1);
Would this work with textout_ex as well?
Jim
Yes, or with any other function that needs a char pointer as argument.
Thanks Rey
Jim
void textprintf_ex(BITMAP *bmp, const FONT *f, int x, y, color, bg, const char *fmt, ...);
Try:
textprintf_ex(buffer, font, 705, 501, color_text, -1, "%d/%d", p1stuff.chp, p1stuff.mhp);
char temp[512];
snprintf(temp, sizeof(temp), "%d/%d", p1stuff.chp, p1stuff.mhp);
textprintf_ex(buffer,
font,
temp,
705,
501,
color_text,
-1);
... why in the world of jumping jehosephats would anyone do that?
textprintf_ex(buffer, font, 705, 501, color_text, -1, "%d/%d", p1stuff.chp, p1stuff.mhp);
Because it is 5:19 AM and at this hour I focus either on C++ or C
Do we need to point out that the syntax you used for textprintf_ex isn't even valid..?
Do we need to point out that the syntax you used for textprintf_ex isn't even valid..?
Hehehehe...:D
I just copy/pasted his example
I know...but I couldn't pass up a
! Hehehe...
That is Matthew's fault for not adding intellisense to the reply box