PDA

View Full Version : Login Problem


ChrisMiller
02/08/2012, 04:02 PM
I am currently using another server's login and register system. The problem is that you can login to any account with any password.
For example if Dante_William's password is "fdapolice", you can login with "asdfsdfsdf".

I'm quite new to scripting so if anyone could tell me what is needed to resolve this problem, it would be great.

This is the login system.

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new sendername[MAX_PLAYER_NAME];
new string[128];
if(dialogid == 1 || dialogid == 2)
{
if(dialogid == 1)
{
if( response == 0 )
{
SendClientMessage(playerid, COLOR_RED, "SERVER: You have been kicked out automatically.");
Kick(playerid);
}
else
{
if(strlen(inputtext))
{
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
}
else
{
new loginstring[128];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname) );
format(loginstring,sizeof(loginstring),"Incorrect password. \n \nThat name is registered, you may now enter your password.");
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login",loginstring,"Login","Exit");
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 2) { SendClientMessage(playerid, COLOR_RED, "SERVER: Wrong password, you have been kicked out automatically."); Kick(playerid); }
}
}
}
if(dialogid == 2)
{
if(strlen(inputtext))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "users/%s.ini", sendername);
new File: hFile = fopen(string, io_read);
if (hFile)
{
SendClientMessage(playerid, COLOR_YELLOW, "That username is already taken, please choose a different one.");
fclose(hFile);
return 1;
}
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
Encrypt(tmppass);
OnPlayerRegister(playerid,tmppass);
}
else
{
new regstring[128];
format(regstring,sizeof(regstring),"Welcome, %s.\nYou don't have an account here...\nplease register by entering a password:",GetPlayerNameEx(playerid));
ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT ,"Register",regstring,"Register","Exit");
}

[MM]RoXoR[FS]
02/08/2012, 04:07 PM
Throw that system and create your own if you really want to learn scripting.

Jikesh
02/08/2012, 04:08 PM
Dudb / dini or mysql?

ChrisMiller
02/08/2012, 04:53 PM
Any help?

ChrisMiller
02/08/2012, 06:08 PM
Can someone please help me quick, my server launch day is suppose to be today...

Stm
02/08/2012, 06:31 PM
I thing that the problem is not in your login code, its with register code. Try to find where your script is registering the password because you have telling the script to register everybody how joins your server with that password!

Roko_foko
02/08/2012, 06:33 PM
I don't know where did you found this code, but it HAS A LOT OF mistakes. Better search on tutorial section (http://forum.sa-mp.com/forumdisplay.php?f=70) how to make a /login /register commands/dialogs system.
>>example<< (http://forum.sa-mp.com/showthread.php?t=290320)

ChrisMiller
03/08/2012, 02:06 AM
I thing that the problem is not in your login code, its with register code. Try to find where your script is registering the password because you have telling the script to register everybody how joins your server with that password!

Right here.
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
Encrypt(tmppass);
OnPlayerRegister(playerid,tmppass);
}