07.11.2015, 18:56
Thank you very much, however my command does not work.
For not having to create another topic. you could lend me a hand?
Thank you! +rep
For not having to create another topic. you could lend me a hand?
PHP код:
dcmd_setpassword( playerid, params[ ] )
{
if ( params[ 0 ] == '\0' )
return SendUsage( playerid, "/setname (id) (password)" );
new
tName[ MAX_PLAYER_NAME ],
tString[ 128 ],
DB:Database,
idx;
printf( "[ID:%d] typed setname command.", playerid );
tName = strtok( params, idx );
if ( IsNumeric( tName ) )
{
new
pid = strval( tName ),
passwordlen = strlen( params[ idx + 1 ] );
if ( !IsPlayerConnected( pid ) )
return SendError( playerid, "Not online!" );
GetPlayerName( pid, tName, MAX_PLAYER_NAME );
if ( !passwordlen )
return SendUsage( playerid, "/setpassword (id) (pass)" );
if ( passwordlen < 3 || passwordlen > 16 )
return SendError( playerid, "Password must be between 3 - 16 ch." );
passwordlen += ( idx + 1 );
for ( new i = idx + 1; i < passwordlen; i++ )
{
if ( isalnum( params[ i ] ) || params[ i ] == '_' )
continue;
else
return SendError( playerid, "Only: 0-9, A-Z, a-z, _" );
}
new
password [128];
format(password, sizeof(password), "%s", strval( params[ idx + 1 ] ));
Database = db_open( SZ_SQLITE_DB );
if ( Database )
{
if ( ResetUserPassword( Database, tName, password ) )
{
format( tString, sizeof( tString ), "The new %s's password is: {FFFFFF}%s", pid, password );
SendClientMessage( playerid, COLOR_RED, tString );
}
db_close( Database );
return 1;
}
return printf( "[ERROR] NO DATABASE!" );
}
else
return SendUsage( playerid, "/setpassword (id) (password)" );
}