Help me with my User System
#1


So, i made a register/login system, i requested so many help here but it turned out not well.

I need someone good at script to help me, when you register at this system then logging in again with the same password it causes a problem, it won't let you login even though your password is the same as you put in the dialog that you registered at.

Please guys help me, i'll +rep. And thanks to those who tried to help me.


PHP код:
// -------------------- = INCLUDES = -------------------- //
#include <a_samp>
#include <YSI\y_ini>
// -------------------- = COLOR DEFINES = -------------------- //
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SEAGREEN 0x2E8B57AA
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
#define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
// -------------------- = COLOR DEFINES = -------------------- //
// -------------------- = REGISTER SYSTEM = -------------------- //
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PATH "/Users/%s.ini"
#pragma tabsize 0
enum pInfo
{
    
pPass,
    
pCash,
    
pAdmin,
    
pKills,
    
pDeaths
}
new 
PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playeridname[], value[]);
public 
LoadUser_data(playeridname[], value[])
{
    
INI_Int("Password"PlayerInfo[playerid][pPass]);
    
INI_Int("Cash"PlayerInfo[playerid][pCash]);
    
INI_Int("Admin"PlayerInfo[playerid][pAdmin]);
    
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(playeridplayernamesizeof(playername));
    
format(Stringsizeof(String), PATHplayername);
    return 
String;
}
stock udb_hash(buf[])
{
    new 
length=strlen(buf);
    new 
s1 1;
    new 
s2 0;
    new 
n;
    for (
n=0n<lengthn++)
    {
       
s1 = (s1 buf[n]) % 65521;
       
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;
}
main()
{
    print(
"\n----------------------------------");
    print(
" LG:RP v.1 by Raisollah");
    print(
"----------------------------------\n");
}
public 
OnGameModeInit()
{
    
// Don't use these lines if it's a filterscript
    
SetGameModeText("LG:RP v.1");
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    if(
fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,"Login""Type your password below.""Login""Cancel");
     }
     else
     {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,"Register""Type your password below""Register""Cancel");
     }
     
     return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File"Data");
    
INI_WriteInt(File"Cash"GetPlayerMoney(playerid));
    
INI_WriteInt(File"Admin"PlayerInfo[playerid][pAdmin]);
    
INI_WriteInt(File"Kills"PlayerInfo[playerid][pKills]);
    
INI_WriteInt(File"Deaths"PlayerInfo[playerid][pDeaths]);
    
INI_Close(File);
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
PlayerInfo[killerid][pKills]++;
    
PlayerInfo[playerid][pDeaths]++;
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if(!
response) return Kick(playerid);
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Register""You have entered an invalid password.\n Type your password below.""Register""Cancel");
                new 
INI:File INI_Open(UserPath(playerid));
                
INI_SetTag(File,"Data");
                
INI_WriteInt(File"Password"udb_hash(inputtext));
                
INI_WriteInt(File"Cash"0);
                
INI_WriteInt(File"Kills"0);
                
INI_WriteInt(File"Deaths"0);
                
INI_Close(File);
                
SendClientMessage(playeridCOLOR_WHITE"Well done, you have successfully registered.");
            }
        }
        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(playeridPlayerInfo[playerid][pCash]);
                    
SendClientMessage(playeridCOLOR_WHITE"You have successfully logged in.");
                }
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT"Login""Type your password below.""Login""Cancel");
                }
            }
        }
    }
    return 
1;

Reply
#2

Please use a system that's already made and stay far away from udb_hash. That function is a checksum algorithm, better known as Adler32. You might as well be saving passwords in plain text.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Please use a system that's already made and stay far away from udb_hash. That function is a checksum algorithm, better known as Adler32. You might as well be saving passwords in plain text.
Can you give me the link of it? I want a opinion from those experienced ones.

EDIT: What is a checksum algorithm?
Reply
#4

Just use Whirpool it's is one of the best.. ****** it.
Reply
#5

Quote:
Originally Posted by Scrillex
Посмотреть сообщение
Just use Whirpool it's is one of the best.. ****** it.
Can you help me with this? Whenever i register at the script that i made then put a "1" as password then when you relog then put "1" as your password you can't login, i already checked my whole script for mistakes but seems okay. Please help me, i'm new at scripting.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)