28.08.2011, 13:35
(
Последний раз редактировалось Basicz; 28.08.2011 в 14:17.
)
Maybe an ' useless ' function =D
But
The function was not tested; but the method was.
Lorenc_ returns Lorenc
Avada_Kedavra_Lumos returns Avada ( This was tested with the method; the string size was not 24. )
Police_A returns Police
IMPROVED Version by RyDeR'
But
pawn Код:
stock getPlayerFirstRPName( playerid, bool: oneCharAllowed = false )
{
new
pName[ MAX_PLAYER_NAME ]
;
GetPlayerName( playerid, szName, sizeof szName );
if ( !( 'A' <= pName[ 0 ] <= 'Z' ) ) // if ( !( szName[ 0 ] >= 'A' && szName[ 0 ] <= 'Z' ) )
return 0;
if ( !oneCharAllowed )
{
if ( szName[ 1 ] == '_' )
return 0;
}
new
iPos = strfind( szName, "_" )
;
strdel( szName, iPos, strlen( szName ) );
return szName;
}
Lorenc_ returns Lorenc
Avada_Kedavra_Lumos returns Avada ( This was tested with the method; the string size was not 24. )
Police_A returns Police
IMPROVED Version by RyDeR'
pawn Код:
stock getPlayerFirstRPName( playerid, bool: oneCharAllowed = false )
{
new
pName[ MAX_PLAYER_NAME ]
;
GetPlayerName( playerid, szName, sizeof szName );
if ( !( 'A' <= pName[ 0 ] <= 'Z' ) ) // if ( !( szName[ 0 ] >= 'A' && szName[ 0 ] <= 'Z' ) )
return 0;
if ( !oneCharAllowed )
{
if ( szName[ 1 ] == '_' )
return 0;
}
new
iPos = strfind( szName, "_" )
;
if ( iPos == -1 )
szName[ iPos ] = EOS;
return szName;
}