Please help me with the register system, i'm doing it more than 2weeks....
#1

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;
}
Reply
#2

Could you please post your register command too? Are you leaving your passwords as is or encrypting them?
Reply
#3

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
Reply
#4

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?
Reply
#5

REFRESH!
Reply
#6

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])
Reply
#7

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?
Reply
#8

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;
        }
}
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)