Code:
#include <amxmodx>
#include <amxmisc>
#define PASSWORD_LENGTH 16
new sv_password;
public plugin_init()
{
register_plugin("Password Generator", "0.1", "Exolent");
register_clcmd("say /pass", "CmdPass");
sv_password = get_cvar_pointer("sv_password");
}
public CmdPass(client)
{
if( !access(client, ADMIN_CVAR) )
{
client_print(client, print_chat, "You have no access to that command!");
return PLUGIN_HANDLED;
}
new password[PASSWORD_LENGTH];
for( new i = 0; i < sizeof(password) - 1; i++ )
{
switch( i % 3 )
{
case 0: password[i] = random_num('0', '9');
case 1: password[i] = random_num('a', 'z');
case 2: password[i] = random_num('A', 'Z');
}
}
client_print(client, print_chat, "Password has been printed to your console.");
console_print(client, "^"sv_password^" is ^"%s^"", password);
set_pcvar_string(sv_password, password);
new name[32];
get_user_name(client, name, sizeof(name) - 1);
client_print(0, print_chat, "ADMIN %s : set a random server password.", name);
return PLUGIN_HANDLED;
}
__________________