SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 30/05/2017, 06:13 PM   #1
czop1223
Little Clucker
 
Join Date: Jul 2012
Posts: 48
Reputation: 0
Default 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?
czop1223 is offline   Reply With Quote
Old 30/05/2017, 06:16 PM   #2
R0
Big Clucker
 
R0's Avatar
 
Join Date: May 2014
Location: Nowhere,But still you can find me anytime you want
Posts: 140
Reputation: 33
Default Re: How do I remove colorcodes from a string?

Just remove the color codes that are in the text and it will work fine.
__________________
Quote:
Originally Posted by hardiksingh5 View Post
please guys tell me how to hack ******** accounts i really need help some one hacked my i want to hack his back please help
R0 is offline   Reply With Quote
Old 30/05/2017, 06:34 PM   #3
czop1223
Little Clucker
 
Join Date: Jul 2012
Posts: 48
Reputation: 0
Default Re: How do I remove colorcodes from a string?

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.
czop1223 is offline   Reply With Quote
Old 30/05/2017, 07:53 PM   #4
DimaShift
Banned
 
Join Date: May 2017
Location: Republic of Moldova
Posts: 121
Reputation: 43
Default Re: How do I remove colorcodes from a string?

SendClientMessage(playerid,-1, "Welcome to Marco's Bistro!");
DimaShift is offline   Reply With Quote
Old 31/05/2017, 02:02 AM   #5
czop1223
Little Clucker
 
Join Date: Jul 2012
Posts: 48
Reputation: 0
Default Re: How do I remove colorcodes from a string?

Sweet jesus.
czop1223 is offline   Reply With Quote
Old 31/05/2017, 04:36 AM   #6
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,269
Reputation: 525
Default Re: How do I remove colorcodes from a string?

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.
Sew_Sumi is offline   Reply With Quote
Old 31/05/2017, 12:24 PM   #7
czop1223
Little Clucker
 
Join Date: Jul 2012
Posts: 48
Reputation: 0
Default Re: How do I remove colorcodes from a string?

Yeah, I need help w/ this function because I could not make it.
czop1223 is offline   Reply With Quote
Old 31/05/2017, 12:42 PM   #8
Toroi
Gangsta
 
Toroi's Avatar
 
Join Date: Feb 2017
Location: Venezuela
Posts: 698
Reputation: 146
Default Re: How do I remove colorcodes from a string?

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

Quote:
Originally Posted by Thanks View Post
So.. hey everyone im trying to searching at ****** how to make leaderboard with Textdraws so i find many but Not in my brain...
Toroi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use colorcodes in name? blankse Scripting Help 1 20/05/2016 06:13 PM
How do I remove the file Extension from a string? Sasino97 Scripting Help 12 21/10/2011 09:06 PM
Remove string from a file. Butilka Help Archive 2 25/07/2010 06:36 PM
add/remove string Cracker Help Archive 2 20/08/2009 07:45 PM


All times are GMT. The time now is 07:32 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.