Author Topic: Randomize Character + Host Only  (Read 1207 times)

Nevermind, here's the final version (If it doesn't have errors)
Code: [Select]
function generateRandom(%len)
{
%chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
for(%i=0;%i<%len;%i++)
{
%str = %str @ getSubStr(%chars,getRandom(0,strlen(%chars)-1),1);
}
return %str;
}
function randomizePasswords(%alen,%salen)
{
$Pref::Server::AdminPassword = generateRandom(%alen);
$Pref::Server::SuperAdminPassword = generateRandom(%salen);
}
« Last Edit: September 21, 2009, 07:47:50 AM by Tickle »

Nevermind, here's the final version (If it doesn't have errors)
Code: [Select]
function generateRandom(%len)
{
%chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
for(%i=0;%i<##%len##;%i++)
{
%str = %str @ getSubStr(%chars,getRandom(0,strlen(%chars)-1),1);
}
return %str;
}
function randomizePasswords(%alen,%salen)
{
$Pref::Server::AdminPassword = generateRandom(%alen);
$Pref::Server::SuperAdminPassword = generateRandom(%salen);
}
You haven't defined %len, and I don't know why you need any args for randomizePasswords, since it uses the %chars string everytime.

You haven't defined %len

He's passing it through the function arguments.

Heres something i got from an old city rpg mod, sassy's file
Code: [Select]
if($server::lan)
{
echo(%this.getName() @ "::onAdd(): Sassy does not support LAN servers! Deleting database..");

%this.schedule(0, "delete");

return false;
}
so i would think it would be if($server::lan)

You haven't defined %len, and I don't know why you need any args for randomizePasswords, since it uses the %chars string everytime.
The arguments for randomizePasswords are passed to generateRandom to get random strings of different lengths for the admin and super-admin passwords.