Problem with /login and /register -
Flashy - 03.06.2010
Hello everyone
I have a little problem with my registration system. Ok the following problems:
- When I type in /register it says I am not logged in
- When I type /login it says I am not registered
Itґs confusing cause I am already registered and it says I am automatically logged it.
So if any one can find the problem, I would be very grateful

[All usefull help or solve the problem-->Add to my credits ingame]
pawn Код:
if(PlayerInfo[playerid][LoggedIn] == 0 && PlayerInfo[playerid][Registered] == 1)
{
if (strcmp( cmd, "/login", true) != 0)
{
SendClientMessage(playerid,COLOR_BRIGHTRED,"* You cannot use commands when you aren't logged in! Please use /login to login onto your account.");
return true;
}
}
if(PlayerInfo[playerid][Registered] == 0 && PlayerInfo[playerid][LoggedIn] == 0)
{
if (strcmp( cmd, "/register", true) != 0)
{
SendClientMessage(playerid,COLOR_BRIGHTRED,"* You cannot use commands because you aren't registered! Please use /register to create an account.");
return true;
}
}
pawn Код:
dcmd_register(playerid, params[])
{
new pName[24], PlayerFile[50], plrIP[50];
GetPlayerName(playerid, pName, sizeof(pName));
format(PlayerFile, sizeof(PlayerFile), "/accounts/%s.ini", pName);
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
if(dini_Exists(PlayerFile))
{
PlayerInfo[playerid][Registered] = 1;
PlayerInfo[playerid][LoggedIn] = 0;
SendClientMessage(playerid, COLOR_BRIGHTRED, "You have already registered! Please use /login to login or choose another nickname.");
}
if(!dini_Exists(PlayerFile))
{
if (!strlen(params)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: Usage: /register [password]");
dini_Create(PlayerFile);
dini_IntSet(PlayerFile, "Registered", 0);
dini_IntSet(PlayerFile, "LoggedIn", 0);
dini_Set(PlayerFile, "Password", MD5_Hash(params));
dini_Set(PlayerFile, "PlayerIP", plrIP);
dini_IntSet(PlayerFile, "AdminLevel", 0);
dini_IntSet(PlayerFile, "Deaths", 0);
dini_IntSet(PlayerFile, "Kills", 0);
dini_IntSet(PlayerFile, "Money", 0);
SendClientMessage(playerid, COLOR_GREEN, "You have succesfully registered, you have been automatically logged in.");
PlayerInfo[playerid][Registered] = 1;
PlayerInfo[playerid][LoggedIn] = 1;
}
return 1;
}
dcmd_login(playerid, params[])
{
new pName[24], PlayerFile[50], Pass[256], plrIP[50];
GetPlayerName(playerid, pName, sizeof(pName));
format(PlayerFile, sizeof(PlayerFile), "/accounts/%s.ini", pName);
if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You are already logged in!");
if(PlayerInfo[playerid][Registered] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You are not registered! Use /register to register.");
if(sscanf(params, "s", Pass)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "Usage: /login [password]");
Pass = dini_Get(PlayerFile, "Password");
if(!strcmp(MD5_Hash(params), Pass, true))
{
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
dini_Set(PlayerFile, "PlayerIP", plrIP);
SendClientMessage(playerid, COLOR_GREEN, "You have been succesfully logged in");
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][AdminLevel] = dini_Int(PlayerFile, "AdminLevel");
PlayerInfo[playerid][Kills] = dini_Int(PlayerFile, "Kills");
PlayerInfo[playerid][Deaths] = dini_Int(PlayerFile, "Deaths");
SetPlayerMoney(playerid, dini_Int(PlayerFile, "Money"));
}
else
{
new str[256];
WrongPassword[playerid]++;
if(WrongPassword[playerid] >= 3)
{
new year, month, day; getdate(year, month, day);
new hour, minute, second; gettime(hour, minute, second);
new str2[256], string[256];
format(str2, sizeof(str2), "* %s has been kicked: Failed to login.", pName);
SendClientMessageToAll(COLOR_BRIGHTRED, str2);
Kick(playerid);
new File:KickFile = fopen("KickLog.txt", io_append);
format(string, sizeof string, "[%d/%d/%d]-[%d:%d:%d]: %s has been kicked by the server. [Reason: Entered an invalid password 3 times]\r\n", year, month, day, hour, minute, second, pName);
fwrite(KickFile, string);
fclose(KickFile);
}
format(str, sizeof(str), "Invalid password. %d/3 tries left.", WrongPassword[playerid]);
SendClientMessage(playerid, COLOR_BRIGHTRED, str);
}
return 1;
}
Re: Problem with /login and /register -
MastahServers - 03.06.2010
Try /register [password] when you are ingame
and registered already
Re: Problem with /login and /register -
Flashy - 03.06.2010
I have it already. It says I must login xD
But then I use /login [pass] and it says I must register
Re: Problem with /login and /register -
Flashy - 03.06.2010
Hmm Bumb? No one have an idea?
Re: Problem with /login and /register -
FUNExtreme - 03.06.2010
Do you check the dini file to see if the player is registered OnPlayerConnect. If you don't, the server can't know that he is registered if you do not set the variable to 1
Re: Problem with /login and /register -
Flashy - 03.06.2010
Maybe thatґs the problem.
What is the function with check the dini file if he is registered/logged in our not?
Re: Problem with /login and /register -
FUNExtreme - 03.06.2010
You will need to use dini_get
https://sampwiki.blast.hk/wiki/Creating_...n_FilterScript
In that tutorial search for the OnPlayerConnect function, there you have an example on how to get the variable out of the dini file.
Greetzz
Re: Problem with /login and /register -
Flashy - 03.06.2010
Well, I take 40 mins to fix that but still canґt. I used dini_Get and so on but nothing works..
I donґt get any errors but it is still the same problem again and again.
So if any one edit my first post with the script in the way it will works I will be grateful.
And if you want I add you to credits.
Re: Problem with /login and /register -
FUNExtreme - 03.06.2010
Could you show us what you created?
Re: Problem with /login and /register -
Flashy - 03.06.2010
It is the same in the first post. I do what you have said with dini_Get bla bla but it donґt works.
I think the script in my first post is right..it saves all stats but the only problem is at the beginning when player try to /login and /register ;/
I must get this fixed >.>
Re: Problem with /login and /register -
Infinity - 03.06.2010
Just some random thoughts here:
pawn Код:
if(PlayerInfo[playerid][Registered] == 0 && PlayerInfo[playerid][LoggedIn] == 0)
Should be:
pawn Код:
else if(PlayerInfo[playerid][Registered] == 0 && PlayerInfo[playerid][LoggedIn] == 0)
And
pawn Код:
if(PlayerInfo[playerid][Registered] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You are not registered! Use /register to register.");
Should be:
pawn Код:
if(!dini_Exists(PlayerFile))return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You are not registered! Use /register to register.");