How do I remove colorcodes from a string? -
czop1223 - 30.05.2017
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?
Re: How do I remove colorcodes from a string? -
R0 - 30.05.2017
Just remove the color codes that are in the text and it will work fine.
Re: How do I remove colorcodes from a string? -
czop1223 - 30.05.2017
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.
Re: How do I remove colorcodes from a string? -
DimaShift - 30.05.2017
SendClientMessage(playerid,-1, "Welcome to Marco's Bistro!");
Re: How do I remove colorcodes from a string? -
czop1223 - 31.05.2017
Sweet jesus.
Re: How do I remove colorcodes from a string? -
Sew_Sumi - 31.05.2017
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.
Re: How do I remove colorcodes from a string? -
czop1223 - 31.05.2017
Yeah, I need help w/ this function because I could not make it.
Re: How do I remove colorcodes from a string? -
Toroi - 31.05.2017
Show us your
SendClientMessageEx (or whatever your text-wrapping function name is) function here, please. Let's see what can we do