Scias Posted January 26, 2015 Share Posted January 26, 2015 Literally stuck here and I have no idea what to do, this error is just too nerdy for me. Â Could anyone help me out ? Quote Link to comment Share on other sites More sharing options...
Thetruecrow Posted February 2, 2015 Share Posted February 2, 2015 Hello Scias. Â What you are trying to do: Add an int to a string, then add a string to the end of the string that has the int added to it. Â What you are actually doing: Adding an int value to a string, then adding a string value to that int value. Â What you can do is use std::stringstream to create a string then append values to it as such: std::stringstream locStr; locStr << "Character Location X: " << X << " Y: " << Y " Z: " << Z; handler->SendSysMessage(locStr.str().c_str()); This will print the floats with their decimals, if you only want the integer value you can cast it to int like before. Â You also have the option of using sprintf which will fill a buffer with a string and place the arguements based on the va_list implementation. char posBuff[255]; sprintf(posBuff, "Character Location X: %f Y: %f Z: %f", X, Y, Z); handler->SendSysMessage(posBuff); If the handler is the ChatHandler implementation found in skyfire, then just use the PSendSystemMessage instead as it supports formatted strings. handler->PSendSysMessage("Character Location X: %f Y: %f Z: %f", X, Y, Z); And just so you know, if you're casting to an int, use %i instead of %f. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.