Liberty Unleashed
Scripting => Script Help => Topic started by: Motley on May 04, 2016, 02:20:06 am
-
This really bugged me and had me currious as to what is the issues,. Finnaly I removed the hashing of passwords to see what was wrong and nothing was wrong. Its using hashing algorithms in a class.
I try to keep functions out of commands. Does any one have any ideas?
This is not a fix script etc more of how should I do it? hopefully not in the command system.
This is just a play script of mine
Hashes :P
class PlayerClass
{
// ------------------------------------------------------------------- //
IP = "0.0.0.0";
Cash = 0;
Bank = 0;
Kills = 0;
Deaths = 0;
Level = 0;
Password = null;
Logged = false;
// ------------------------------------------------------------------- //
constructor( player )
{
IP = Accounts.Get( player + " IP" );
Cash = Accounts.Get( player + " Cash" );
Bank = Accounts.Get( player + " Bank" );
Kills = Accounts.Get( player + " Kills" );
Deaths = Accounts.Get( player + " Deaths" );
Level = Accounts.Get( player + " Level" );
Password = Accounts.Get( player + " Password" );
Logged = false;
}
function Join( player )
{
if( Level == 0 )
{
MessagePlayer( "Please register to play.", player );
MessagePlayer( "Register with /register <password>", player );
}
else if ( Password )
{
// If they are registered, ask for them to login
if ( Level >= 1 )
{
MessagePlayer( "Login before spawning! /login <password>", player );
}
}
else
{
MessagePlayer( "Please login to play.", player );
MessagePlayer( "Login with /login <password>", player );
}
}
function Register( player, text )
{
if ( Level >= 1 )
{
MessagePlayer( "Error - You are already registered.", player );
return 1;
}
else
{
// Otherwise they have logged in succesfully!
Accounts.Add( player.Name + " Password", text );
Accounts.Add( player.Name + " Level", 1 );
Accounts.Add( player.Name + " IP", player.IP );
Accounts.Add( player.Name + " GOTO", "off" );
// Then we will add their kills/deaths and cash/bank
Accounts.Add( player.Name + " Cash", 0 );
Accounts.Add( player.Name + " Bank", 0 );
Accounts.Add( player.Name + " Kills", 0 );
Accounts.Add( player.Name + " Deaths", 0 );
// Then finally log that player in
Account[ player.ID ].Logged = true;
MessagePlayer( "To login to this account type: /login <password>", player );
MessagePlayer( "You have successfully registered with us!", player );
// And save the hash files
SaveHashes();
}
}
function LoginPlayer( player, text )
{
if ( Level == 0 )
{
// Player hasn't registered so tell them to do so
MessagePlayer( "// Error: You do not have an account, register with /register <password>", player );
return 1;
}
if ( Account[ player.ID ].Logged == true )
{
// Player has already logged in
MessagePlayer( "// Error: You are already logged in to your account.", player );
return 1;
}
if ( text != Password )
{
// Player has entered wrong password
MessagePlayer( "Error - Invalid Password.", player );
return 1;
}
else
{
// Otherwise they have logged in succesfully!
Account[ player.ID ].Logged = true;
Account[ player.ID ].Cash = Accounts.Get( player.Name + " Cash" );
Account[ player.ID ].Bank = Accounts.Get( player.Name + " Bank" );
Account[ player.ID ].Kills = Accounts.Get( player.Name + " Kills" );
Account[ player.ID ].Deaths = Accounts.Get( player.Name + " Deaths" );
Account[ player.ID ].Level = Accounts.Get( player.Name + " Level" );
player.Cash = Account[ player.ID ].Cash;
MessagePlayer( "You have successfully logged in!", player );
}
}
}
-
you can add functions to a class, however I believe they use the local scope of the class, so if you need anything global then you'll probably have to add a double colon before whatever it is you need to use (i.e. ::FindVehicle ).
-
THANKS!!! I will re add support for hashing passwords and see what happens
Tested,. Does not encrypt passwords.
(http://i.imgur.com/Fbc8Ukn.png)
-
I don't see anything wrong in that line. In classes is a bit hard to find a error, use // until disappears.
-
The error in general is MD5[Hashing of passwords] I guess I should give it up and put these functions in a command. make the encrypted text transfer over to the class functions.
-
The error in general is MD5[Hashing of passwords] I guess I should give it up and put these functions in a command. make the encrypted text transfer over to the class functions.
MD5 was broken by a chinese guy. It's recommeded at least SHA1 or even better SHA256
::SHA1(password.tostring());
-
Yes I plan to not use MD5, It is just when scripting its really simple to just type MD5 as a text
I plan to use maybe WHIRLPOOL + Salt, If anything either SHA1, or WHIRLPOOL,
-
::SHA1(password.tostring());
Should fix the instance error (I had this error before)
-
Ankris question
It seems it is very useful to add certain functions in side of the constructor/class ..
Reasons of why
Less locals and in general it's easier to script. Any good fair warnings as to scripting alot here ?
*I just removed the old post to refresh with this one.
(Old post)
FIXED THANKS!!!
This was just a test script i don't intend to create exploits like cash levels etc
class PlayerClass
{
// ------------------------------------------------------------------- //
IP = "0.0.0.0";
Cash = 0;
Bank = 0;
Kills = 0;
Deaths = 0;
Level = 0;
Password = null;
Logged = false;
// ------------------------------------------------------------------- //
constructor( player )
{
IP = Accounts.Get( player + " IP" );
Cash = Accounts.Get( player + " Cash" );
Bank = Accounts.Get( player + " Bank" );
Kills = Accounts.Get( player + " Kills" );
Deaths = Accounts.Get( player + " Deaths" );
Level = Accounts.Get( player + " Level" );
Password = Accounts.Get( player + " Password" );
Logged = false;
}
function Join( player )
{
if( !Level ){
::MessagePlayer( "Register before spawning! /login <password>", player );
}
else if ( Password )
{
// If they are registered, ask for them to login
if ( Level >= 1 )
{
::MessagePlayer( "Login before spawning! /login <password>", player );
}
}
else{
::MessagePlayer( "Login before spawning! /login <password>", player );
}
}
// This function is used to register a player with the server
// First we will add that players main account information
function Register( player, text )
{
if ( Level >= 1 )
{
::MessagePlayer( "Error - You are already registered.", player );
return 1;
}
else
{
// Otherwise they have logged in succesfully!
Accounts.Add( player.Name + " Password", ::SHA1(text) );
Accounts.Add( player.Name + " Level", 1 );
Accounts.Add( player.Name + " IP", player.IP );
Accounts.Add( player.Name + " GOTO", "off" );
// Then we will add their kills/deaths and cash/bank
Accounts.Add( player.Name + " Cash", 0 );
Accounts.Add( player.Name + " Bank", 0 );
Accounts.Add( player.Name + " Kills", 0 );
Accounts.Add( player.Name + " Deaths", 0 );
// Then finally log that player in
Account[ player.ID ].Logged = true;
::MessagePlayer( "To login to this account type: /login <password>", player );
::MessagePlayer( "You have successfully registered with us!", player );
// And save the hash files
SaveHashes();
}
}
function LoginPlayer( player, text )
{
if ( Level == 0 )
{
// Player hasn't registered so tell them to do so
::MessagePlayer( "// Error: You do not have an account, register with /register <password>", player );
return 1;
}
if ( Account[ player.ID ].Logged == true )
{
// Player has already logged in
::MessagePlayer( "// Error: You are already logged in to your account.", player );
return 1;
}
if ( ::SHA1(text) != Password )
{
// Player has entered wrong password
::MessagePlayer( "Error - Invalid Password.", player );
return 1;
}
else
{
// Otherwise they have logged in succesfully!
Account[ player.ID ].Logged = true;
Account[ player.ID ].Cash = Accounts.Get( player.Name + " Cash" );
Account[ player.ID ].Bank = Accounts.Get( player.Name + " Bank" );
Account[ player.ID ].Kills = Accounts.Get( player.Name + " Kills" );
Account[ player.ID ].Deaths = Accounts.Get( player.Name + " Deaths" );
Account[ player.ID ].Level = Accounts.Get( player.Name + " Level" );
player.Cash = Account[ player.ID ].Cash;
::MessagePlayer( "You have successfully logged in!", player );
}
}
}