Raised This Month: $ Target: $400
 0% 

Replacing a part of a message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 12-03-2010 , 10:22   Re: Replacing a part of a message
Reply With Quote #1

Quote:
Originally Posted by bibu View Post
Couldn't understand seta's message, but however.
He meant that Exolent is using too much spacing in his code. While I also don't see how such spacing can look good or improve readability for anyone, it's a matter of one's taste.

Also it would be more efficient to not use 2D arrays for such code. Here's my way tho:
Code:
new message[sizeof(g_szWelcomeMsgs[])]; copy(message, charsmax(message), g_szWelcomeMsgs[g_RandomMsg]);   RemoveAll(message, charsmax(message), "\r"); RemoveAll(message, charsmax(message), "\y"); RemoveAll(message, charsmax(message), "\w"); RemoveAll(message, charsmax(message), "\d"); RemoveAll(message, charsmax(message), "\R");   client_print(id, print_chat, "bibu said %s to all", message);   // ...   RemoveAll(message[], length, text[])         while (replace(message, length, text, "")) {}
__________________

Last edited by hleV; 12-03-2010 at 10:33.
hleV is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2010 , 13:48   Re: Replacing a part of a message
Reply With Quote #2

Quote:
Originally Posted by hleV View Post
He meant that Exolent is using too much spacing in his code. While I also don't see how such spacing can look good or improve readability for anyone, it's a matter of one's taste.

Also it would be more efficient to not use 2D arrays for such code. Here's my way tho:
Code:
new message[sizeof(g_szWelcomeMsgs[])]; copy(message, charsmax(message), g_szWelcomeMsgs[g_RandomMsg]);   RemoveAll(message, charsmax(message), "\r"); RemoveAll(message, charsmax(message), "\y"); RemoveAll(message, charsmax(message), "\w"); RemoveAll(message, charsmax(message), "\d"); RemoveAll(message, charsmax(message), "\R");   client_print(id, print_chat, "bibu said %s to all", message);   // ...   RemoveAll(message[], length, text[])         while (replace(message, length, text, "")) {}
Why don't you just use replace_all()?
__________________
fysiks is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 11:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode