Raised This Month: $ Target: $400
 0% 

[HELP] Replacing part of word/text


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kapitana
Member
Join Date: Apr 2014
Old 01-05-2016 , 12:30   [HELP] Replacing part of word/text
Reply With Quote #1

Hello AlliedModders,
I have this little problem replacing part of word. I tried many things .. but it didn't work for me. Anyway, what I am trying to do is something like:

new word[20]
format(word, 20, "\dAdmin")

And when I use it to replace the "\d" with "" and keep only "Admin". Anyway that was just an example .. I need this "replacement" for different purpose .. if its possible, please share . Thanks in advance

Last edited by kapitana; 01-05-2016 at 12:31. Reason: Title mistake .. :D
kapitana is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-05-2016 , 12:51   Re: [HELP] Replacing part of word/text
Reply With Quote #2

replace ?
__________________

Last edited by HamletEagle; 01-05-2016 at 12:52.
HamletEagle is offline
kapitana
Member
Join Date: Apr 2014
Old 01-05-2016 , 13:03   Re: [HELP] Replacing part of word/text
Reply With Quote #3

Yea ... that's it. Thnx
kapitana is offline
kapitana
Member
Join Date: Apr 2014
Old 01-05-2016 , 13:37   Re: [HELP] Replacing part of word/text
Reply With Quote #4

1 more question .. if possible ... Is there a way to add something like "Mega" before the "Admin" word ? And make it look like: "MegaAdmin" ? ... I took a look at add(dest[],len,const src[],max=0); .. but it concatenates one string onto another and doesn't get my job done ...
kapitana is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-05-2016 , 13:47   Re: [HELP] Replacing part of word/text
Reply With Quote #5

PHP Code:
new FinalString[60]
formatex(FinalStringcharsmax(FinalString), "Mega%s"word
You could use add too, if you have "Mega" in a string.
__________________

Last edited by HamletEagle; 01-05-2016 at 13:47.
HamletEagle is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 01-05-2016 , 13:51   Re: [HELP] Replacing part of word/text
Reply With Quote #6

Quote:
Originally Posted by kapitana View Post
1 more question .. if possible ... Is there a way to add something like "Mega" before the "Admin" word ? And make it look like: "MegaAdmin" ? ... I took a look at add(dest[],len,const src[],max=0); .. but it concatenates one string onto another and doesn't get my job done ...
You cannot replace 'Admin' with 'MegaAdmin'?

Code:
    new text[ 101 ];     formatex( text, sizeof( text ) - 1, "Hi am an Admin" );     replace(text, sizeof( text ) - 1, "Admin", "MegaAdmin" );
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 01-05-2016 at 13:58. Reason: spelling fix
addons_zz is offline
kapitana
Member
Join Date: Apr 2014
Old 01-05-2016 , 13:52   Re: [HELP] Replacing part of word/text
Reply With Quote #7

OK. Thnx for the fast answers

Last edited by kapitana; 01-05-2016 at 13:54.
kapitana is offline
kapitana
Member
Join Date: Apr 2014
Old 01-05-2016 , 14:00   Re: [HELP] Replacing part of word/text
Reply With Quote #8

I was trying to add "Mega" without changing/replacing "Admin" .. But I guess that can't be done .. thnx for the help!

Last edited by kapitana; 01-05-2016 at 14:01.
kapitana 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 09:26.


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