Raised This Month: $51 Target: $400
 12% 

[REQ] Register and login system (mysql)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
raptor666
Junior Member
Join Date: Aug 2012
Old 07-27-2018 , 18:11   [REQ] Register and login system (mysql)
Reply With Quote #1

Hi all!

I would like to ask for some help! I want a system where they can register from the players menu and they can log in.
There is enough user account and password to sign up.
After successful login, 2 buttons should still be in the menu: An example menu item and logout.
It would be very important for the system to be mysql.

There is no need for anything else, because after that, I am adapting myself properly.

Thank you in advance for your help!

Last edited by raptor666; 08-01-2018 at 11:37.
raptor666 is offline
Equiment
AlliedModders Donor
Join Date: Feb 2014
Old 07-29-2018 , 07:38   Re: [REQ] Register and login system (mysql)
Reply With Quote #2

Hi, can make it, write me in steam (https://steamcommunity.com/id/sirequiment) or telegram: @Equiment
Equiment is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-30-2018 , 10:31   Re: [REQ] Register and login system (mysql)
Reply With Quote #3

Gracious...

I would like to do this
mug1wara is offline
raptor666
Junior Member
Join Date: Aug 2012
Old 07-30-2018 , 17:31   Re: [REQ] Register and login system (mysql)
Reply With Quote #4

@mug1wara ?
raptor666 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-30-2018 , 17:38   Re: [REQ] Register and login system (mysql)
Reply With Quote #5

Yes, what's up?

I meant, it would've been fun to do this.

If you haven't got it done already, just let me know :p

Last edited by mug1wara; 07-30-2018 at 17:39.
mug1wara is offline
raptor666
Junior Member
Join Date: Aug 2012
Old 07-30-2018 , 17:46   Re: [REQ] Register and login system (mysql)
Reply With Quote #6

Not happened. But I can not afford to pay for it.
raptor666 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-30-2018 , 17:50   Re: [REQ] Register and login system (mysql)
Reply With Quote #7

No, that's fine. I'm not in need of any money ^^
mug1wara is offline
raptor666
Junior Member
Join Date: Aug 2012
Old 08-09-2018 , 15:12   Re: [REQ] Register and login system (mysql)
Reply With Quote #8

Not a duplicate. Unfortunately, Mugiwara does not do it.
Because he did 1 but he was wrong. It does not work any part of it either.

Please help! Not working!

Quote:
#include <sourcemod>

#pragma semicolon 1

Database g_hDatabase;

char g_sSteamid[MAXPLAYERS + 1][32];

char g_sName[MAXPLAYERS + 1][256];
char g_sPassword[MAXPLAYERS + 1][256];
char g_sEmail[MAXPLAYERS + 1][256];

bool g_bRegister;

public void OnPluginStart()
{
Database.Connect(SQL_Connection, "vipsystem");
}

public void SQL_Connection(Database hDatabase, const char[] sError, int iData)
{
if (hDatabase == null)
ThrowError(sError);

else
{
g_hDatabase = hDatabase;

g_hDatabase.Query(SQL_Error, "CREATE TABLE IF NOT EXISTS players (steam_id VARCHAR(32) NOT NULL PRIMARY KEY, account_name VARCHAR(32) NOT NULL, account_password VARCHAR(32) NOT NULL, account_email VARCHAR(32) NOT NULL)");
}
}

public void SQL_Error(Database hDatabase, DBResultSet hResults, const char[] sError, int iData)
{
if (hResults == null)
ThrowError(sError);
}

public void OnClientPostAdminCheck(int iClient)
{
if (IsValidClient(iClient))
{
GetClientAuthId(iClient, AuthId_Steam2, g_sSteamid[iClient], sizeof(g_sSteamid[]));

Menu hMenu = new Menu(Menu_Authorization);

hMenu.SetTitle("Choose Your Option.");

hMenu.AddItem("", "Login");
hMenu.AddItem("", "Register");

hMenu.Display(iClient, MENU_TIME_FOREVER);
}
}

public int Menu_Authorization(Menu hMenu, MenuAction hAction, int iClient, int iParam)
{
switch (hAction)
{
case MenuAction_Select:
{
switch (iParam)
{
case 0:
{
char sQuery[256];
//Format(sQuery, sizeof(sQuery), "SELECT * FROM players WHERE steam_id = \"%s\"", g_sSteamid[iClient]);
Format(sQuery, sizeof(sQuery), "SELECT * FROM players WHERE steam_id = '%s'", g_sSteamid[iClient]);

g_hDatabase.Query(SQL_Authorization, sQuery, GetClientUserId(iClient));

}

case 1:
g_bRegister = true;
}
}

case MenuAction_End:
delete hMenu;
}
//char sQuery[256];
//SQL_TQuery(g_hDatabase, SQL_ErrorCheckCallBack, sQuery);
}

public void SQL_Authorization(Database hDatabase, DBResultSet hResults, const char[] sError, int iData)
{
if (hResults == null)
ThrowError(sError);

int iClient = GetClientOfUserId(iData);

if (IsValidClient(iClient))
{
if (hResults.RowCount != 0)
{
hResults.FetchRow();

hResults.FetchString(1, g_sSteamid[iClient], sizeof(g_sSteamid[]));
hResults.FetchString(2, g_sName[iClient], sizeof(g_sName[]));
hResults.FetchString(3, g_sPassword[iClient], sizeof(g_sPassword[]));
//hResults.FetchString(4, g_sEmail[iClient], sizeof(g_sEmail[]));
}

else
PrintToChat(iClient, "Your account wasn't found! You may register.");
}
//SQL_TQuery(g_hDatabase, SQL_ErrorCheckCallBack, sQuery);
SQL_TQuery(g_hDatabase, SQL_ErrorCheckCallBack, hResults.FetchRow());
}

public Action OnClientSayCommand(int iClient, const char[] sCommand, const char[] sArgs)
{
if (g_bRegister)
{
char sName[64], sPassword1[64], sPassword2[64], sEmail[64];

GetCmdArg(1, sName, sizeof(sName));
GetCmdArg(2, sPassword1, sizeof(sPassword1));
GetCmdArg(3, sPassword2, sizeof(sPassword2));
GetCmdArg(4, sEmail, sizeof(sEmail));

if (sPassword1[0] != sPassword2[0])
{
PrintToChat(iClient, "Invalid password confirmation.");

return Plugin_Handled;
}

char sQuery[256];
//Format(sQuery, sizeof(sQuery), "INSERT INTO players (steam_id, account_name, account_password, account_email) VALUES (\"%s\", \"%s\", \"%s\", \"%s\")", g_sSteamid[iClient], sName, sPassword1, sEmail);
Format(sQuery, sizeof(sQuery), "INSERT INTO players (steam_id, account_name, account_password, account_email) VALUES ('%s', '%s', '%s', '%s')", g_sSteamid[iClient], sName, sPassword1, sEmail);

g_hDatabase.Query(SQL_Error, sQuery);

g_bRegister = false;

return Plugin_Handled;
}

return Plugin_Continue;
}

public SQL_ErrorCheckCallBack(Handlewner, Handle:hDatabase, const String:error[], any:data)
{
// This is just an errorcallback for function who normally don't return any data
if(hDatabase == INVALID_HANDLE)
{
SetFailState("Query failed! %s", error);
}
}

stock bool IsValidClient(int iClient)
{
if (!(0 < iClient <= MaxClients) || !IsClientInGame(iClient) || IsFakeClient(iClient))
return false;

return true;
}
Register error:

L 08/20/2018 - 13:28:57: [SM] Exception reported: No command callback available
L 08/20/2018 - 13:28:57: [SM] Blaming: Regandlogin.smx
L 08/20/2018 - 13:28:57: [SM] Call stack trace:
L 08/20/2018 - 13:28:57: [SM] [0] GetCmdArg
L 08/20/2018 - 13:28:57: [SM] [1] Line 118, Regandlogin.sp::OnClientSayCommand

login error: no errors but, not working.

Last edited by raptor666; 08-20-2018 at 07:32.
raptor666 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode