if ( ResetUserPassword( Database, tName, password ) )
new
password = strval( params[ idx + 1 ] );
Can you show me ResetUserPassword function? And 'tName' 'Database' variables?
|
stock ResetUserPassword( DB:Database, Name[ ], Password[ ] )
{
new DBResult:Result;
if ( Database )
{
new
Query [ 512 ],
Pw[ 64 ];
format( Query, sizeof( Query ), "SELECT * FROM `users` WHERE `name`=lower('%s') AND `password`='%s'", Name, Pw );
Result = db_query( Database, Query );
if ( db_num_fields( Result ) )
{
db_free_result( Result );
format( Query, sizeof( Query ), "UPDATE `users` SET `password`='%s' WHERE `name`=lower('%s') AND `password`='%s'", Password, Name, Pw );
Result = db_query( Database, Query );
db_free_result( Result );
return 1;
}
else
{
db_free_result( Result );
return 0;
}
}
else
{
printf( "[ERROR] NO DATABASE!" );
return 0;
}
}
new
password [69] = strval( params[ idx + 1 ] );
password [69] = strval( params[ idx + 1 ] );
new
password [128];
format(password, sizeof(password), "%s", strval( params[ idx + 1 ] ));
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)" );
}