AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Replacing part of word/text (https://forums.alliedmods.net/showthread.php?t=277248)

kapitana 01-05-2016 12:30

[HELP] Replacing part of word/text
 
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 :D. Thanks in advance :)

HamletEagle 01-05-2016 12:51

Re: [HELP] Replacing part of word/text
 
replace ?

kapitana 01-05-2016 13:03

Re: [HELP] Replacing part of word/text
 
Yea ... that's it. Thnx :)

kapitana 01-05-2016 13:37

Re: [HELP] Replacing part of word/text
 
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 ...

HamletEagle 01-05-2016 13:47

Re: [HELP] Replacing part of word/text
 
PHP Code:

new FinalString[60]
formatex(FinalStringcharsmax(FinalString), "Mega%s"word

You could use add too, if you have "Mega" in a string.

addons_zz 01-05-2016 13:51

Re: [HELP] Replacing part of word/text
 
Quote:

Originally Posted by kapitana (Post 2380290)
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" );

kapitana 01-05-2016 13:52

Re: [HELP] Replacing part of word/text
 
OK. Thnx for the fast answers :up:

kapitana 01-05-2016 14:00

Re: [HELP] Replacing part of word/text
 
I was trying to add "Mega" without changing/replacing "Admin" :D .. But I guess that can't be done .. thnx for the help!


All times are GMT -4. The time now is 09:26.

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