PDA

View Full Version : Problem On Login System


Youssef214
22/05/2014, 04:49 PM
Hello, So When It Shows The Dialog Register While Connecting To Server (Dialog ID 1) I Register Successfully,But When I Rejoin,And When I Type My Password,It Doesn't Work,And It Says Wrong Password,Codes:

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
#pragma unused ret_memcpy
if(dialogid == 1) {
new file[128], name[MAX_PLAYER_NAME], str[128] , ip[12];
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, sizeof(file), "Counter Strike/Users/%s.ini", name);
if(response) {
if(strlen(inputtext)) {
dini_Create(file);
dini_IntSet(file, "Password", num_hash(inputtext));
dini_Set(file, "IP", ip);
format(str, sizeof(str), "You are registered as ~r~%s. Your password is ~r~%s. /changepass to change it", name, inputtext);
SendClientMessage(playerid, COLOR_YELLOW, str);
}
}
else {
Kick(playerid);
}
}
if(dialogid == 2)
{
new file[128], name[MAX_PLAYER_NAME], str[128], ip[12];
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), "Counter Strike/Users/%s.ini", name);
if(response) {
if(strlen(inputtext)) {
if(num_hash(inputtext) != dini_Int(file, "Password")) {
SendClientMessage(playerid, COLOR_RED, "Wrong Password");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login", "Enter Your Password Below", "Login", "Cancel");
}
else {
SendClientMessage(playerid, COLOR_YELLOW, "Succesfuly logged in");
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
PlayerInfo[playerid][VIPLevel] = dini_Int(file, "VIPLevel");
GivePlayerMoney(playerid, dini_Int(file, "Cash"));
SetPlayerScore(playerid, dini_Int(file, "Score"));
PlayerInfo[playerid][Kills] = dini_Int(file, "Kills");
PlayerInfo[playerid][Death] = dini_Int(file, "Death");
dini_Set(file, "IP", ip);
}
}
}
else {
Kick(playerid);
}
}
return 1;
}

Youssef214
22/05/2014, 06:29 PM
anyone?

AndySedeyn
22/05/2014, 06:30 PM
OnDialogResponse callback should return 0, not 1.

Youssef214
22/05/2014, 07:09 PM
Still,when i write the correct password to login,it doesn't make me logged to my account.

Denying
22/05/2014, 07:20 PM
format(str, sizeof(str), "Counter Strike/Users/%s.ini", name);

You are formatting str not file.

rumen98
22/05/2014, 07:21 PM
I think you can not make such roads to folders with empty space
format(file, sizeof(file), "Counter Strike/Users/%s.ini", name);

Edit: Late

Youssef214
22/05/2014, 07:40 PM
still,when i type my password,it still sends me: Wrong Password.

PinEvil
22/05/2014, 07:43 PM
I'd suggest you check your "users" file as the above didn't work for you!

I'd also suggest using mysql instead of Y_INI.

Youssef214
22/05/2014, 07:44 PM
i use Dini not Y_INI.

and the user information:

Password=295B0652D4FD7DC01D14EB47C0A1EA212188AE7A9 B19A5215149ABBED5CA17FDF167FD35DFA4BCD1CE5B0E7F1DA 67C2CB684D970A7174303C17C7B9A02BEAE42
IP=127.0.0.1
Logged=0
AdminLevel=0
VIPLevel=0
Cash=0
Score=0
Kills=0
Death=0

Youssef214
22/05/2014, 08:02 PM
anyone? i will +REP if someone helps me

Youssef214
22/05/2014, 08:22 PM
anyone?

admiralspeedy
23/05/2014, 04:17 AM
I've never used Dini, but based on your code, my knowledge of Y_INI and some quick research, I'm guessing it's due to the fact that you are using dini_IntSet and dini_Int for the password.

The password is a string, not an integer. So when you load up the game, it tries loading the password as an integer.

Ciandlah
23/05/2014, 05:31 AM
1. Show us your login Code so we can help you out.
2. From the account log you provided above I notice you are using Whirpool

But still post your code below so we can help

Youssef214
23/05/2014, 05:47 AM
you mean login code on onplayerconnect?

admiralspeedy
23/05/2014, 01:52 PM
1. Show us your login Code so we can help you out.
2. From the account log you provided above I notice you are using Whirpool

But still post your code below so we can help

He did post his code.

He's trying to call the password as an integer and it's hashed as a string.

Denying
23/05/2014, 01:56 PM
format(str, sizeof(str), "Counter Strike/Users/%s.ini", name); if(response) { if(strlen(inputtext)) { if(num_hash(inputtext) != dini_Int(file, "Password"))


You are formatting str instead of file, change that.

Fred1993
23/05/2014, 02:28 PM
hwo about you just remove num_hash?
dini_IntSet(file, "Password", inputtext);
and the also on login
if((inputtext != dini_Int(file, "Password"))

Sorry but i have used MYSQL, have no idea of dini.. but give it a try and remove num_hash