How do I remove colorcodes from a string?

I've got word-wrapping system on my server that uses strlen, but for example taking this short text from SA-MP forum

SendClientMessage(playerid, COLOR_WHITE, "Welcome to {00FF00}M{FFFFFF}a{FF0000}r{FFFFFF}c{00FF00}o{FFFF FF}'{FF0000}s {FFFFFF}B{00FF00}i{FFFFFF}s{FF0000}t{FFFFFF}r{00FF 00}o{FFFFFF}!");

It would make the "Welcome to Marco's Bistro" look like "Welcome to Mar...(new line)...Co's Bistro" because strlen takes colorcodes into consideration. Let's see i make 2nd variable and want to store the text without colorcodes in it, how would I remove them?

Just remove the color codes that are in the text and it will work fine.

I need them, but I don't want them to get counted in strlen, so I need to move them onto a other variable and then delete them and use strlen on that new variable.

SendClientMessage(playerid,-1, "Welcome to Marco's Bistro!");

Sweet jesus.

Even though those codes aren't shown in the client they still add to string length. strlen is functioning correctly.

You'll need to make a function to remove the codes, or have a look for said function.

Yeah, I need help w/ this function because I could not make it.

Show us your SendClientMessageEx (or whatever your text-wrapping function name is) function here, please. Let's see what can we do

Forum Jump:

Users browsing this thread: 1 Guest(s)