AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Strlen and replace problem (https://forums.alliedmods.net/showthread.php?t=28304)

L0neW0lf 05-12-2006 04:01

Strlen and replace problem
 
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 05-12-2006 04:03

hmmm i think it is the strlen that is wrong........it returns a number but i need to check for the char "@"

twistedeuphoria 05-12-2006 04:17

strlen is for finding the length of the string. It looks like you want contain or containi.

L0neW0lf 05-12-2006 04:23

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)"

p3tsin 05-12-2006 05:13

Code:
if(string[0] == '@') replace(string,1, "@", "(at)")

L0neW0lf 05-12-2006 06:30

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)")     }

v3x 05-12-2006 09:44

Show the full code ...................

L0neW0lf 05-12-2006 10:26

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)")     } }

p3tsin 05-12-2006 10:31

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)     } }

v3x 05-12-2006 10:41

Code:
replace(new_name,32, "@", "(at)")


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

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