Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: ! on Sep 15, 2017, 07:44 AM

Title: [RLC] Register, Login & Change Password v-0.2
Post by: ! on Sep 15, 2017, 07:44 AM
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 (https://github.com/zeus-gaming/RLC)
Title: Re: Basic Login/Registeration System
Post by: Mahmoud Tornado on Sep 15, 2017, 04:13 PM
okay but the database not saveing why ?
@zeus
Title: Re: Basic Login/Registeration System
Post by: Mahmoud Tornado on Sep 15, 2017, 04:31 PM
@zeus
i am adding clan system too!
Title: Re: Basic Login/Registeration System
Post by: Mahmoud Tornado on Sep 15, 2017, 04:33 PM
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 );
}
Title: Re: Basic Login/Registeration System
Post by: ! on Sep 16, 2017, 10:32 AM
(https://i.imgur.com/NVMlmYp.jpg)
It means something. (http://forum.vc-mp.org/?topic=4025.msg29787#msg29787)
Title: Re: Basic Login/Registeration System
Post by: Ðℯαтℌ ℳαṧт℮я on Aug 25, 2018, 01:15 PM
(Sorry For Bumping Old Topics) Thank You So Much! This Helped Alot!
Title: Re: Basic Login/Registeration System
Post by: [SC]Spartan on Aug 26, 2018, 02:31 PM
Could you please add a system that changes the player's nickname and writes it to the database?
Title: Re: Basic Login/Registeration System
Post by: KrOoB_ on Aug 27, 2018, 01:24 AM
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);
 }
 }
Title: Re: Basic Login/Registeration System
Post by: [SC]Spartan on Aug 28, 2018, 02:40 PM
Thanks KrooB , i dont know if it work when i go home i will test it but what language is it?
Title: Re: Basic Login/Registeration System
Post by: ! on Aug 28, 2018, 03:12 PM
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
Title: Re: Basic Login/Registeration System
Post by: Xmair on Aug 29, 2018, 06:17 AM
Why do you use a custom encryption method?
Title: Re: Basic Login/Registeration System
Post by: MatheuS 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
Title: Re: Basic Login/Registeration System
Post by: ! on Aug 29, 2018, 10:08 AM
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.
Title: Re: Basic Login/Registeration System
Post by: [SC]Spartan on Sep 06, 2018, 04:59 PM
No work :|
Title: Re: Basic Login/Registeration System
Post by: [SC]Spartan on Sep 06, 2018, 06:01 PM
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
Title: Re: Basic Login/Registeration System
Post by: Mahmoud Tornado on Sep 06, 2018, 11:47 PM
Quote from: [SC]Spartan on Sep 06, 2018, 06:01 PMAN 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

local name = text.tointeger();
Title: Re: Basic Login/Registeration System
Post by: Shadow on Sep 07, 2018, 05:00 AM
Quote from: Xmair on Aug 29, 2018, 06:17 AMWhy do you use a custom encryption method?

It's not a 'custom encryption', nor an 'encryption'.
It's the SHA-256 hashing (one way function) algorithm but implemented in squirrel (still, should use the hashing plugin instead.)
Title: Re: Basic Login/Registeration System
Post by: [SC]Spartan on Sep 07, 2018, 07:05 AM
if (cmd == "cambiarnick")
 {
 if ( Stats[ player.ID ].LoggedIn == true ) return MessagePlayer( "[#E0E0E0]Debes iniciar sesión en el servidor", player );
 else if ( Stats[ player.ID ].Registered == true ) return MessagePlayer( "[#E0E0E0]Debes ser registrado", player );
 else if ( !text ) MessagePlayer("[#E0E0E0]Código: / cambio de nombre <Nuevo nombre>",player);
 else {
 local name = VARCHAR(25);
 QuerySQL( db, "UPDATE Accounts SET Name = '" + name + "' WHERE Name = '" + escapeSQLString(player.Name) + "'");
 MessagePlayer("[#E0E0E0]Su nombre ha sido cambiado con éxito ",player);
}
}

Credit to KrOoB:

i have this error

AN ERROR HAS OCCURED [the index 'VARCHAR' does not exist]
I tried everything.
If there is no solution, could someone help me to do another one to change the nickname if the name is not removed

Title: Re: [RLC] Register, Login & Change Password v-0.2
Post by: ! on Sep 07, 2018, 11:32 AM
[RLC] Register, Login & Change Password

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

Topic Updated: Link (https://forum.vc-mp.org/?topic=5144.msg37031#msg37031)


:edit:
Quote from: [SC]Spartan on Sep 07, 2018, 07:05 AMAN ERROR HAS OCCURED [the index 'VARCHAR' does not exist]
I tried everything.
If there is no solution, could someone help me to do another one to change the nickname if the name is not removed
This snippet is not related to this topic if you have any issue in installation or found bug in this topic post here otherwise get dafaq out of this topic and create a support ticket over there Link (https://forum.vc-mp.org/?board=10.0)