Raised This Month: $ Target: $400
 0% 

Strlen and replace problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-12-2006 , 04:01   Strlen and replace problem
Reply With Quote #1

I aint exactly sure if it is the len or the replace that dont work.......

if (strlen(string,1)="@") {
replace ( string, 1, "@","(at)")
}

somebody who can help ?
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-12-2006 , 04:03  
Reply With Quote #2

hmmm i think it is the strlen that is wrong........it returns a number but i need to check for the char "@"
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
twistedeuphoria
Veteran Member
Join Date: Jul 2004
Old 05-12-2006 , 04:17  
Reply With Quote #3

strlen is for finding the length of the string. It looks like you want contain or containi.
__________________
twistedeuphoria is offline
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-12-2006 , 04:23  
Reply With Quote #4

could be

but cant figure out how to put the code....

i want to check the first letter in a string, only the first letter. If that letter is a "@" i want to replace it with "(at)"
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 05-12-2006 , 05:13  
Reply With Quote #5

Code:
if(string[0] == '@') replace(string,1, "@", "(at)")
__________________
plop
p3tsin is offline
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-12-2006 , 06:30  
Reply With Quote #6

Hi there

That looks more correct to me, but still cant make it work......

Tried this:

Code:
    else if (new_name[0] == '@') ) {     replace(new_name,1, "@", "(at)")     }

And this:

Code:
    else if ( equal(new_name[0],"@") ) {     replace(new_name,1, "@", "(at)")     }
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-12-2006 , 09:44  
Reply With Quote #7

Show the full code ...................
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-12-2006 , 10:26  
Reply With Quote #8

Code:
/* This plugin is made for personal purpose. Made by Lone Wolf @ clan-server.dk Thanks to v3x for support */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Nick Manager" #define VERSION "1.0" #define AUTHOR "Lone Wolf @ clan-server.dk" #define change_nick "amx_nick" #define Illegal "Illegal Name" #define Unnamed "Cant find my name" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)    } public client_putinserver(id) {   check_name(id) } public client_infochanged(id) {   check_name(id) } public check_name(id) {     new new_name[33]     get_user_info(id , "name" , new_name , 32)     if (strlen(new_name) < 2) {         client_cmd(id , "name ^"%s^"" , Illegal)     }     else if ( equali(new_name,"player") || equali(new_name,"unnamed") ) {         client_cmd(id , "name ^"%s^"" , Unnamed)     }     else if ( equal(new_name[0],"@") ) {     replace(new_name,1, "@", "(at)")     } }
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 05-12-2006 , 10:31  
Reply With Quote #9

Code:
check_name(id) {       new new_name[33]       get_user_info(id , "name" , new_name , 32)       if (strlen(new_name) < 2) {           client_cmd(id , "name ^"%s^"",Illegal)       }     else if ( equali(new_name,"player") || equali(new_name,"unnamed") ) {         client_cmd(id , "name ^"%s^"",Unnamed)     }     else if ( new_name[0] == '@' ) {         replace(new_name,1, "@", "(at)")         client_cmd(id , "name ^"%s^"", new_name)     } }
__________________
plop
p3tsin is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-12-2006 , 10:41  
Reply With Quote #10

Code:
replace(new_name,32, "@", "(at)")
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x 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 05:09.


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