29.11.2013, 13:40
How to cut the first 8 characters?
Код HTML:
{00FF00}text
{00FF00}text
Use strmid.
https://sampwiki.blast.hk/wiki/Strmid strmid(string, "ItWillCopeThis notthis", 1, 14); //string contains "ItWillCopeThis" 1 stands for the first character and 14 for the last. |
new string[42] = "We will delete everything apart from this";
strdel(string, 0, 37); // string is now "this"
stock RemoveHexColors( sz_Text[ ] )
{
new
iStart = strfind( sz_Text, "{" ),
iEnd = strfind( sz_Text, "}" ),
bool: using_color = true
;
if( iStart != -1 && iEnd != -1 && iEnd - iStart == 7 )
{
for( new i = iStart + 1; i != iEnd; i++ )
{
if( ( sz_Text[ i ] < 'A' || sz_Text[ i ] > 'Z' ) && ( sz_Text[ i ] < 'a' || sz_Text[ i ] > 'z' ) && ( sz_Text[ i ] < '0' || sz_Text[ i ] > '9' ) )
{
using_color = false;
break;
}
}
if( using_color )
{
strdel( sz_Text, iStart, iEnd + 1 );
return 1;
}
}
return 0;
}
new
string[ 64 ] = "Some test with colors {00FF00}and {FFFFFF}another color!"
;
while( RemoveHexColors( string ) ) RemoveHexColors( string );