Please help me with the register system, i'm doing it more than 2weeks.... -
karakana7 - 06.11.2010
So I have my registration/login system but it doesn't working normally how it should have...So whith register system everything is ok, when i register, creates my file in users folder, but something bad with login system, because there's no difference what password i will type it will always log me in...So that my login code:
Код:
dcmd_login(playerid, params[])
{
new file[256];
new name[MAX_PLAYER_NAME];
new string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "\\Users\\%s.ini", name);
if(!dini_Exists(file)) return SendClientMessage(playerid, 0xFFFFFFFF, "You aren't registered, to do so type /register [password] command!");
if(!strlen(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE:/register [password]");
if(logged[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "You are already logged in!");
new variable[256];
variable = dini_Get(file,"password");
if(!strcmp(params, variable))
{
format(string, sizeof(string), "%s, you typed your pasword incorrectly", name);
SendClientMessage(playerid, 0xFFFFFFFF, string);
return 1;
}
if(strcmp(params, variable))
{
logged[playerid] = 1;
SendClientMessage(playerid, 0xFFFFFFFF, "You successfully logged in!");
return 1;
}
return 0;
}
Re: Please help me with the register system, i'm doing it more than 2weeks.... -
JamesC - 06.11.2010
Could you please post your register command too? Are you leaving your passwords as is or encrypting them?
Re: Please help me with the register system, i'm doing it more than 2weeks.... -
Kwarde - 06.11.2010
pawn Код:
dcmd_login(playerid, params[])
{
new file[256], name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(file, 256, "\\Users\\%s.ini", name);
if(!dini_Exists(file)) return SendClientMessage(playerid, 0xFFFFFFFF, "You aren't registered, to do, type /register [password] !");
if(!strlen(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE:/register [password]");
if(logged[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "You are already logged in!");
if(!strcmp(params, dini_Get(file, "password"), true))
{
logged[playerid] = 1;
SendClientMessage(playerid, 0xFFFFFFFF, "You successfully logged in!");
return 1;
}
if(strcmp(params, variable))
{
format(string, sizeof(string), "%s, you typed your pasword incorrectly", name);
SendClientMessage(playerid, 0xFFFFFFFF, string);
return 1;
}
return 0;
}
Try this one?
I didn't test it, so I don't know if it's working
And I made it a bit different, so it will save a BIT disk space
And please use [ pawn ][ /pawn ] BB codes
Then it will be PAWN highlighted
Re: Please help me with the register system, i'm doing it more than 2weeks.... -
karakana7 - 06.11.2010
Quote:
Originally Posted by Kwarde
pawn Код:
dcmd_login(playerid, params[]) { new file[256], name[MAX_PLAYER_NAME], string[128]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(file, 256, "\\Users\\%s.ini", name); if(!dini_Exists(file)) return SendClientMessage(playerid, 0xFFFFFFFF, "You aren't registered, to do, type /register [password] !"); if(!strlen(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE:/register [password]"); if(logged[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "You are already logged in!"); if(!strcmp(params, dini_Get(file, "password"), true)) { logged[playerid] = 1; SendClientMessage(playerid, 0xFFFFFFFF, "You successfully logged in!"); return 1; } if(strcmp(params, variable)) { format(string, sizeof(string), "%s, you typed your pasword incorrectly", name); SendClientMessage(playerid, 0xFFFFFFFF, string); return 1; } return 0; }
Try this one?
I didn't test it, so I don't know if it's working
And I made it a bit different, so it will save a BIT disk space
And please use [ pawn ][ /pawn ] BB codes
Then it will be PAWN highlighted
|
THANK YOU SO MUCH!!!!!!
Wow, now it's working.But one little problem, i don't know why i can click spawn if i'm not registered, or not logged in and than I can play the game even if i'm not logged in!How to fix it?
Re: Please help me with the register system, i'm doing it more than 2weeks.... -
karakana7 - 06.11.2010
REFRESH!
Re: Please help me with the register system, i'm doing it more than 2weeks.... -
Kwarde - 06.11.2010
Ok add this:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
if(logged[playerid] == 0){
SendClientMessage(playerid, 0xFF0000AA, "ERROR: You're not logged in!");
return 0;
}
return 1;
}
And a tip about the
'new logged[MAX_PLAYERS]; (or something like that)
Make it a 'bool'
->
new bool:logged[MAX_PLAYERS];
And then
logged[playerid] = 0; is now
logged[playerid] = false;, and
logged[playerid] = 1; is then
logged[playerid] = true;
Then you can check if a player is logged on this way:
if(logged[playerid]) instead of
if(logged[playerid] == 1)
And ps,
if(logged[playerid] == 0) is then
if(!logged[playerid])
Re: Please help me with the register system, i'm doing it more than 2weeks.... -
karakana7 - 07.11.2010
Quote:
Originally Posted by Kwarde
Ok add this:
pawn Код:
public OnPlayerRequestSpawn(playerid) { if(logged[playerid] == 0){ SendClientMessage(playerid, 0xFF0000AA, "ERROR: You're not logged in!"); return 0; } return 1; }
And a tip about the 'new logged[MAX_PLAYERS]; (or something like that)
Make it a 'bool' -> new bool:logged[MAX_PLAYERS];
And then logged[playerid] = 0; is now logged[playerid] = false;, and logged[playerid] = 1; is then logged[playerid] = true;
Then you can check if a player is logged on this way: if(logged[playerid]) instead of if(logged[playerid] == 1)
And ps, if(logged[playerid] == 0) is then if(!logged[playerid])
|
Thank you for helping me, but this code under OnPlayerRequestSpawn isn't working, I can click on spawn and play the game if i didn't type any password...So maybe anyone else know how to do that?
Re: Please help me with the register system, i'm doing it more than 2weeks.... -
Biesmen - 07.11.2010
pawn Код:
format(file, 256, "\\Users\\%s.ini", name);
Are you using linux? If yes, keep it like that.
If no change it to
pawn Код:
format(file, 256, "\Users\%s.ini", name);
or
pawn Код:
format(file, 256, "Users\%s.ini", name);
For the login check, use this:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
if(logged[playerid] == 1) {
return 1;
} else {
SendClientMessage(playerid, 0xFF0000AA, "ERROR: You're not logged in!");
return 0;
}
}