AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   remove letters frome string? (https://forums.alliedmods.net/showthread.php?t=65161)

fxfighter 01-02-2008 15:33

remove letters frome string?
 
have always wonder how but have never known?
Code:


if(contain(map, "de_"))
{
//remove _de
}


Arkshine 01-02-2008 16:31

Re: remove letters frome string?
 
It depends how you code after that.

There are severals ways using, strtok(), contain(), etc..

with strtok:
Code:
 strtok( sMap, sPrefix, charsmax( sPrefix ), sMap, charsmax( sMap ), '_' );

Arkshine 01-02-2008 17:03

Re: remove letters frome string?
 
In case where you don't need to remove prefix map, you can do something like:

Code:
sMap[ contain( sMap, "_" ) + 1 ];

E.g.: you want to display map without prefix, you can do directly :

Code:
client_print( id, print_chat, "Current Map : %s", sMap[ contain( sMap, "_" ) + 1 ] );

contain() returns position of '_'. And +1, because we want to display all characters after '_'.

That's why I've said it depends how you code after.

Emp` 01-02-2008 17:56

Re: remove letters frome string?
 
Code:

replace(string, len, "de_", "")

if( equal(string, "de_", 3) )
  copy( string, len, string[3])



All times are GMT -4. The time now is 11:12.

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