[RLC] Register, Login & Change Password v-0.2

Started by !, Sep 15, 2017, 07:44 AM

Previous topic - Next topic

!

Update Reason: Used vcmp official hashing, unique id concept has been used and installation is made simple.

Commands:
   -> /commands
   -> /register <password>
   -> /login <password>
   -> /changepass <old-password> <new-password>

Installation: Download the file rlc.nut from the link and place it inside svr_dir and place the bellow functions in appropriate server events.

onScriptLoad()
/* onScriptLoad() */
dofile( "rlc.nut", true );
rlc_table.onScriptLoad( );

onPlayerJoin( player )
/* onPlayerJoin( player ) */
rlc_table.onPlayerJoin( player );

onPlayerPart( player, reason )
/* onPlayerPart( player, reason ) */
rlc_table.onPlayerPart( player );

onPlayerCommand( player, command, arguments )
/* onPlayerCommand( player, command, arguments ) */
switch( command ) {
 case "register":
 case "login":
 case "changepass":
    rlc_table.onPlayerCommand( player, command, arguments );
 break;
 case "commands":
    MessagePlayer( "[#7bb215][RLC] [#15a26f]RLC Commands: [/] register, login, changepass.", player );
 break;
 default:
    MessagePlayer( "[#7bb215][RLC] [#cc3510](ERROR) Invalid command, use /commands to check for availble commands.", player );
}


Github: Link

Discord: zeus#5155

Mahmoud Tornado

#1
okay but the database not saveing why ?
@zeus

Mahmoud Tornado


Mahmoud Tornado

i think the problem here
//Functions

function Login( player, pass )
{
local q = QuerySQL( DataBase, "SELECT * FROM Account WHERE Name LIKE '" + player.Name + "'" );
local Clan = GetSQLColumnData( q, 2 );
Stats[ player.ID ].Reg = true;
Stats[ player.ID ].Log = true;
local q = QuerySQL( DataBase, "SELECT Cash, Bank, Kills, Deaths FROM Account WHERE Name LIKE '" + player.Name + "'" );
if (!q) return MessagePlayer( "Data is not loaded, your nick is not found in database.", player );

Stats[ player.ID ].Cash = GetSQLColumnData( q, 0 );
Stats[ player.ID ].Bank = GetSQLColumnData( q, 1 );
Stats[ player.ID ].Kills = GetSQLColumnData( q, 2 );
Stats[ player.ID ].Deaths = GetSQLColumnData( q, 3 );
FreeSQLQuery( q );
local w = QuerySQL( Clans, "SELECT * FROM ClanMembersRequest WHERE Player LIKE '" + player.Name + "' COLLATE NOCASE" );
if (w)
{
Stats[ player.ID ].ClanRequest = true;
Stats[ player.ID ].ClaneTag = GetSQLColumnData( w, 1 );
Stats[ player.ID ].Clane = GetSQLColumnData( w, 2 );
Stats[ player.ID ].ClaneState = GetSQLColumnData( w, 3 );
MessagePlayer( "[#00de00]Clan Request: [#fbf3f3]Clan [ " + Stats[ player.ID ].Clane + " ].Use /acceptclan or /rejectclan.",player);
}
FreeSQLQuery( w );

if ( Clan != "None" )
{
local r = QuerySQL( Clans, "SELECT Tag FROM ClanStats WHERE Clan LIKE '"+Clan+"'" );
if (r)
{
local
Tag = GetSQLColumnData( r, 0 ),
t = QuerySQL( Clans, "SELECT * FROM ClanMembers WHERE Clan LIKE '"+Clan+"'" ),
Owner = GetSQLColumnData( t, 1 ),
Leader1 = GetSQLColumnData( t, 2 ),
Leader2 = GetSQLColumnData( t, 3 ),
Leader3 = GetSQLColumnData( t, 4 ),
Users = GetSQLColumnData( t, 5 );
if ( Owner == player.Name )
{
Stats[ player.ID ].Clan = Clan;
Stats[ player.ID ].ClanTag = Tag;
Stats[ player.ID ].ClanState = "Owner";
}
if ( Leader1 == player.Name )
{
Stats[ player.ID ].Clan = Clan;
Stats[ player.ID ].ClanTag = Tag;
Stats[ player.ID ].ClanState = "Leader1";
}
if ( Leader2 == player.Name )
{
Stats[ player.ID ].Clan = Clan;
Stats[ player.ID ].ClanTag = Tag;
Stats[ player.ID ].ClanState = "Leader2";
}
if ( Leader3 == player.Name )
{
Stats[ player.ID ].Clan = Clan;
Stats[ player.ID ].ClanTag = Tag;
Stats[ player.ID ].ClanState = "Leader3";
}
if ( Users.find( player.Name ) )
{
Stats[ player.ID ].Clan = Clan;
Stats[ player.ID ].ClanTag = Tag;
Stats[ player.ID ].ClanState = "Users";
}
FreeSQLQuery(t);
}
FreeSQLQuery(r);
}

CheckPlayerClan( player );
MessagePlayer("[#00de00]Server Msg: [#fbf3f3]Welcome Back.",player);
MessagePlayer("[#00de00]Server Msg: [#fbf3f3]You Have Logged-In Successfully.",player);
}

function Register( player, password )
{
local pass = e(password);
QuerySQL( DataBase, "INSERT INTO Account ( Name, Pass, Clan, Cash, Bank, Kills, Deaths ) VALUES ( '" + player.Name + "', '" + pass + "', 'None'', '0', '0', '0', '0' )" );

Stats[ player.ID ].Log = true;
Stats[ player.ID ].Reg = true;
MessagePlayer("[#00de00]Server Msg: [#fbf3f3]Nick: " + player.Name + ". Password: " + password + ".",player);
MessagePlayer( "[#00de00]Server Msg: [#fbf3f3]You Have Successfully Register.", player );
}

!


Discord: zeus#5155

Ðℯαтℌ ℳαṧт℮я

(Sorry For Bumping Old Topics) Thank You So Much! This Helped Alot!

[SC]Spartan

Could you please add a system that changes the player's nickname and writes it to the database?

KrOoB_

Try this

else if (cmd == "isimdegis")
 {
 if ( stats[ player.ID ].Log == false ) return MessagePlayer( "[#E0E0E0]Sunucuya giris yapmaniz gerek", player );
 else if ( stats[ player.ID ].Reg == false ) return MessagePlayer( "[#E0E0E0]Sunucuya kayit olmaniz gerek", player );
 else if ( !text ) MessagePlayer("[#E0E0E0]Kod: /isimdegis <Yeniisim>",player);
 else {
 local name = VARCHAR(25);
 QuerySQL(DataBase, "UPDATE Accounts SET Name = '" + name + "' WHERE Name = '" + escapeSQLString(player.Name) + "'");
 MessagePlayer("[#E0E0E0]İsminiz basariyla degistirildi ",player);
 }
 }

[SC]Spartan

Thanks KrooB , i dont know if it work when i go home i will test it but what language is it?

!

Quote from: [SC]Spartan on Aug 28, 2018, 02:40 PMThanks KrooB , i dont know if it work when i go home i will test it but what language is it?
Turkish

Discord: zeus#5155

Xmair

Why do you use a custom encryption method?

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

MatheuS

Quote from: Xmair on Aug 29, 2018, 06:17 AMWhy do you use a custom encryption method?

Maybe he don't know how to use Hashing plugin
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

!

Quote from: Takanaue on Aug 29, 2018, 06:32 AM
Quote from: Xmair on Aug 29, 2018, 06:17 AMWhy do you use a custom encryption method?
Maybe he don't know how to use Hashing plugin
Yep he is right 11 months ago I never knew about hashing plugin maybe I can update this topic later and remove the custom encryption made by Stormeus and use the official hashing function.

Discord: zeus#5155


[SC]Spartan

AN ERROR HAS OCCURED [the index 'VARCHAR' does not exist]
I tried everything but I get this error someone could help me how to fix it? I would appreciate