[FilterScript] ESET Smart Register/Login System
#1

Alot of people might wait for me to Update ESET Smart Admin 4 but dont worry im updating it to Y_INI

Anyways I present to you the ESET Smart Register/Login System

I also uploaded this to Paste bin but since this is a little peace of code ill also post it here.

Features:
Register System
Login System

pawn Code:
// Includes
#include <a_samp>
#include <YSI\y_ini>
#include <sscanf2>
// Settings
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PATH "/Administration/Users/%s.ini"
// Colors
#define COLOR_ORANGE  0xFF8000FF
#define COLOR_WHITE   0x000000FF
#define COLOR_RED     0xFF0000FF
#define COLOR_CYAN    0x00FFFFFF
// pInfo enum
enum pInfo
{
    pPass,
    pScore,
    pCash,
    pKills,
    pDeaths,
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
public OnPlayerConnect(playerid)
{
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login Menu","Type your password below to login.","Login","Kick");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register Menu","Type your password below to register a new account.","Register","Kick");
    }
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "%s has Joined the server.", pname);
    SendClientMessageToAll(COLOR_CYAN, string);
    return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"Player Saved Data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Register Menu","You have been registered","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Login Menu","You have been logged in to your account","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login Menu","Wrong Pass dude\nType your password below to login into your account","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"Player Saved Data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    GetPlayerName(playerid, pname, sizeof(pname));
    switch(reason) {
        case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", pname);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pname);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pname);
        }
    SendClientMessageToAll(COLOR_CYAN, string);
    return 1;
}
I hoped you liked this System.
This is like a small new release of how ESET Smart Admin 4 will look.

Note: It doesnt contain an admin system as you can see.

Download

You will need:
To create a file in scriptfiles called Administration then create a subfolder for Administration called Users
e.g: /scriptfiles/Administration/Users thats how it will look.


Credits:
****** for Y_INI
Dracoblue for password hash
Me for creating this simple system

Also to some noobs which might post
ESET means lots of things
e.g ESET = Easy Team Easy System
so stfu noobs
And its not name stealing.
Reply
#2

It's simple but cool.
Reply
#3

Quote:
Originally Posted by KeKe98
View Post
It's simple but cool.
Thanks also i made it simple so people can add more levels on enums etc. or INI_IntSet and etc..
Anyways thanks for your comment
Reply
#4

Quote:
Originally Posted by Notis123
View Post
Alot of people might wait for me to Update ESET Smart Admin 4 but dont worry im updating it to Y_INI

Anyways I present to you the ESET Smart Register/Login System

I also uploaded this to Paste bin but since this is a little peace of code ill also post it here.

Features:
Register System
Login System

pawn Code:
// Includes
#include <a_samp>
#include <YSI\y_ini>
#include <sscanf2>
// Settings
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PATH "/Administration/Users/%s.ini"
// Colors
#define COLOR_ORANGE  0xFF8000FF
#define COLOR_WHITE   0x000000FF
#define COLOR_RED     0xFF0000FF
#define COLOR_CYAN    0x00FFFFFF
// pInfo enum
enum pInfo
{
    pPass,
    pScore,
    pCash,
    pKills,
    pDeaths,
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
public OnPlayerConnect(playerid)
{
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login Menu","Type your password below to login.","Login","Kick");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register Menu","Type your password below to register a new account.","Register","Kick");
    }
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "%s has Joined the server.", pname);
    SendClientMessageToAll(COLOR_CYAN, string);
    return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"Player Saved Data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Register Menu","You have been registered","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Login Menu","You have been logged in to your account","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login Menu","Wrong Pass dude\nType your password below to login into your account","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"Player Saved Data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    GetPlayerName(playerid, pname, sizeof(pname));
    switch(reason) {
        case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", pname);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pname);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pname);
        }
    SendClientMessageToAll(COLOR_CYAN, string);
    return 1;
}
I hoped you liked this System.
This is like a small new release of how ESET Smart Admin 4 will look.

Note: It doesnt contain an admin system as you can see.

Download

You will need:
To create a file in scriptfiles called Administration then create a subfolder for Administration called Users
e.g: /scriptfiles/Administration/Users thats how it will look.


Credits:
****** for Y_INI
Dracoblue for password hash
Me for creating this simple system
You sure you created all of this? I do recall seeing a Y_INI registration tutorial which was posted by a user named 'Kush' that is similar to this.

https://sampforum.blast.hk/showthread.php?tid=273088
Reply
#5

Yes i've made this also the LoadUser is by a friend of mine
LoadUser can be used to make Y_INI writing faster and better.
If i wanted to make loading user i could use Dini to make it manual but i prefer y_ini because its kinda easy .
And udb hash is from DB(Draco Blue) and the LoadUser/Path is my friends idea i wanted to release my ESET Login/Register with dini but he told me dini is old now so..
Reply
#6

Really dude?
Who steals a huge company's name just for SA-MP? That can get you in trouble
http://eset.com
Reply
#7

Quote:
Originally Posted by TEXFTW
View Post
Really dude?
Who steals a huge company's name just for SA-MP? That can get you in trouble
http://eset.com
You're so stupid man.
ESET Smart Register/Login its not the anti virus you noob
ESET can mean lots of things
Also since the name is different im legal


e.g ESET = Easy System Easy Team
so stfu you noob
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)