Vice City: Multiplayer

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

Title: [RLC] Register, Login & Change Password v-0.2
Post by: ! on September 15th, 2017, 08:44 AM
Update Reason: Used vcmp official hashing, unique id concept has been used and installation is made simple.

Commands:
Code: [Select]
   -> /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()
Code: [Select]
/* onScriptLoad() */
dofile( "rlc.nut", true );
rlc_table.onScriptLoad( );

onPlayerJoin( player )
Code: [Select]
/* onPlayerJoin( player ) */
rlc_table.onPlayerJoin( player );

onPlayerPart( player, reason )
Code: [Select]
/* onPlayerPart( player, reason ) */
rlc_table.onPlayerPart( player );

onPlayerCommand( player, command, arguments )
Code: [Select]
/* 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 September 15th, 2017, 05:13 PM
okay but the database not saveing why ?
@zeus
Title: Re: Basic Login/Registeration System
Post by: Mahmoud Tornado on September 15th, 2017, 05:31 PM
@zeus
i am adding clan system too!
Title: Re: Basic Login/Registeration System
Post by: Mahmoud Tornado on September 15th, 2017, 05:33 PM
i think the problem here
Code: [Select]
//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 September 16th, 2017, 11: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 August 25th, 2018, 02: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 August 26th, 2018, 03: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 August 27th, 2018, 02:24 AM
Try this

Code: [Select]
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 August 28th, 2018, 03: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 August 28th, 2018, 04:12 PM
Quote from [SC]Spartan on August 28th, 2018, 03:40 PM
Thanks 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 August 29th, 2018, 07:17 AM
Why do you use a custom encryption method?
Title: Re: Basic Login/Registeration System
Post by: MatheuS on August 29th, 2018, 07:32 AM
Quote from Xmair on August 29th, 2018, 07:17 AM
Why 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 August 29th, 2018, 11:08 AM
Quote from Takanaue on August 29th, 2018, 07:32 AM
Quote from Xmair on August 29th, 2018, 07:17 AM
Why 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 September 6th, 2018, 05:59 PM
No work :|
Title: Re: Basic Login/Registeration System
Post by: [SC]Spartan on September 6th, 2018, 07: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 September 7th, 2018, 12:47 AM
Quote from [SC]Spartan on September 6th, 2018, 07: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
Code: [Select]
local name = text.tointeger();
Title: Re: Basic Login/Registeration System
Post by: Shadow on September 7th, 2018, 06:00 AM
Quote from Xmair on August 29th, 2018, 07:17 AM
Why 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 September 7th, 2018, 08: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 September 7th, 2018, 12:32 PM
[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 September 7th, 2018, 08:05 AM
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
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)