Raised This Month: $51 Target: $400
 12% 

replace_all


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bol
Member
Join Date: Feb 2014
Old 05-28-2014 , 14:45   replace_all
Reply With Quote #1

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" );
bol is offline
swapped
BANNED
Join Date: Mar 2014
Location: OrpheuRegisterHook
Old 05-28-2014 , 14:47   Re: replace_all
Reply With Quote #2

replace_all(szName, 31, "^", " " );
swapped is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-28-2014 , 14:48   Re: replace_all
Reply With Quote #3

Quote:
Originally Posted by swapped View Post
replace_all(szName, 31, "^^", " " );
Fixed
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
bol
Member
Join Date: Feb 2014
Old 05-28-2014 , 15:07   Re: replace_all
Reply With Quote #4

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?

Last edited by bol; 05-28-2014 at 15:08.
bol is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 05-28-2014 , 15:55   Re: replace_all
Reply With Quote #5

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)
aron9forever is offline
bol
Member
Join Date: Feb 2014
Old 05-28-2014 , 17:33   Re: replace_all
Reply With Quote #6

I've tried the following
PHP Code:
replace_all(szName31" ""^n" ); 
Which didnt work ofcourse, I'll try that code out aron.
bol is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-28-2014 , 17:40   Re: replace_all
Reply With Quote #7

Quote:
Originally Posted by bol View Post
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
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 05-28-2014 at 17:40.
YamiKaitou is offline
bol
Member
Join Date: Feb 2014
Old 05-28-2014 , 17:49   Re: replace_all
Reply With Quote #8

Yes just sorted it.

PHP Code:
console_cmd(id,"name %s"szName); 
----------->
PHP Code:
console_cmd(id,"name ^"%s^""szName); 
Noobishly overlooked
bol is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-28-2014 , 19:46   Re: replace_all
Reply With Quote #9

For changing someones name, use engclient_cmd(id, "name", "new name here").
__________________
fysiks is offline
bol
Member
Join Date: Feb 2014
Old 05-29-2014 , 07:36   Re: replace_all
Reply With Quote #10

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

Last edited by bol; 05-29-2014 at 07:39.
bol 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 19:51.


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