AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   replace_all (https://forums.alliedmods.net/showthread.php?t=241139)

bol 05-28-2014 14:45

replace_all
 
hi

How would I be able to replace the ^ symbol in a name?

I've tried this but it doesn't work
replace_all(szName, 31, "^4", "^1" );

swapped 05-28-2014 14:47

Re: replace_all
 
replace_all(szName, 31, "^", " " );

YamiKaitou 05-28-2014 14:48

Re: replace_all
 
Quote:

Originally Posted by swapped (Post 2143660)
replace_all(szName, 31, "^^", " " );

Fixed

bol 05-28-2014 15:07

Re: replace_all
 
Works thank you for the quick help.

There is another issue which occurred before as well.

PHP Code:

replace_all(szName31"^^4""^^1" ); 

When someone has a space in their name in example players name = "^4Dirk^4 uNITED^4"
It would take everything till the space and new nickname becomes = "^1Dirk^1"
Im assuming replace_all by default would remove spacing.
Are there symbols to maintain spacing in users name?

aron9forever 05-28-2014 15:55

Re: replace_all
 
cont szName2
for(new i=0;i<=((sizeof szName)-1);i++)
{
if(szName[i]!='^^')
{
szName2[i]=szNAme[i+1]
i++
}
}

someone fix it if the transition between c++ and pawn is wrong, but this would be the very basic handling of what you want, probably what replace_all does(except it changes to what you want instead of deleting)

bol 05-28-2014 17:33

Re: replace_all
 
I've tried the following
PHP Code:

replace_all(szName31" ""^n" ); 

Which didnt work ofcourse, I'll try that code out aron.

YamiKaitou 05-28-2014 17:40

Re: replace_all
 
Quote:

Originally Posted by bol (Post 2143665)
Im assuming replace_all by default would remove spacing.

replace_all does not touch the spacing unless it is passed as the "what". You must have something else wrong

bol 05-28-2014 17:49

Re: replace_all
 
Yes just sorted it.

PHP Code:

console_cmd(id,"name %s"szName); 

----------->
PHP Code:

console_cmd(id,"name ^"%s^""szName); 

Noobishly overlooked :oops:

fysiks 05-28-2014 19:46

Re: replace_all
 
For changing someones name, use engclient_cmd(id, "name", "new name here").

bol 05-29-2014 07:36

Re: replace_all
 
Interesting, can you also tell me the reason why or what the difference is?
Would guess one difference to be the spacing to be of no issue :)


All times are GMT -4. The time now is 18:07.

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