You can modify the chars used by editing the ranges in CharRanges[] and code length by changing SecurityCodeLength value. It is currently setup to build a 6-character long code using characters 0-9, a-z, A-Z.
Sample output:
Code:
* Your security code is: xL8pqk
* Your security code is: r7CC44
* Your security code is: H3npmW
* Your security code is: XxJnJB
* Your security code is: O44oIA
* Your security code is: 8V08bw
PHP Code:
#include <amxmodx>
#define MAX_PLAYERS 32
const SecurityCodeLength = 6;
new const CharRanges[ 3 ][ 2 ] =
{
{ '0' , '9' }, //0-9 = asc 48-57
{ 'A' , 'Z' }, //A-Z = asc 65-90
{ 'a' , 'z' } //a-z = asc 97-122
};
new g_szSecurityCodes[ MAX_PLAYERS + 1 ][ SecurityCodeLength + 1 ];
public plugin_init()
{
register_plugin( "Security Code" , "0.1" , "bugsy" );
register_clcmd( "say /random" , "GenerateCode" );
}
public GenerateCode( id )
{
new iCurSet;
for ( new i = 0 ; i < SecurityCodeLength ; i++ )
{
iCurSet = random( sizeof( CharRanges ) );
g_szSecurityCodes[ id ][ i ] = random_num( CharRanges[ iCurSet ][ 0 ] , CharRanges[ iCurSet ][ 1 ] );
}
g_szSecurityCodes[ id ][ SecurityCodeLength ] = EOS;
client_print( id , print_chat , "* Your security code is: %s" , g_szSecurityCodes[ id ] );
}
__________________