Login Script not working
#1

Ive made an ini file in scriptfiles, called Players.ini
My player name is Decysen then it does this: Decysen=TestPass
It should say logged if it it inputs that, or else say Invalid Password. But this command will only say Unknown Command. Can somebody help me why this wont work? Thnx

Код:
#include <a_samp>
#include <dini>

#define COLOR_RED 0xFF0000AA

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

new _LOGIN_Password[MAX_PLAYERS];
new _LOGIN_LoggedIn[MAX_PLAYERS];
new Name[MAX_PLAYER_NAME+1];

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	if(_LOGIN_LoggedIn[playerid] == 1)
	{
		return 1;
	} else {
		return 0;
	}
	return 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(login, 5, cmdtext);
	return 0;
}

dcmd_login(playerid, params[])
{
	print("Got Input FS");
	if(params[128] == dini_Int("Players.ini", Name))
	{
  	_LOGIN_LoggedIn[playerid] = 1;
  	SendClientMessage(playerid, COLOR_RED, "Logged In.");
	} else {
		SendClientMessage(playerid, COLOR_RED, "Invalid Password! Please Retry.");
	}
	return 1;
}

public OnPlayerConnect(playerid)
{
  _LOGIN_LoggedIn[playerid] = 0;
  
	GetPlayerName(playerid, Name, sizeof(Name));
	// _LOGIN_Password[playerid] = dini_Get("Players.ini", Name);
	
	printf("%s (%d) Password Is: %s", Name, playerid, dini_Get("Players.ini", Name));
	return 1;
}
Reply
#2

If you use dcmd it will never return Unknown Command. ONLY if the code crash and so false return
And because you use dcmd it only can be the second reason
The code crash after the print and before the logged in message
Than where can be the problem, ahhh there
pawn Код:
if(params[128] == dini_Int("Players.ini", Name))
fix this line by yourself if you can
Reply
#3

Thats exactly the problem, i don't know how to fix this. Please help me
Reply
#4

Why's that?
new Name[MAX_PLAYER_NAME+1];
Reply
#5

whats wrong with it?
Reply
#6

Quote:
Originally Posted by MenaceX^
Why's that?
new Name[MAX_PLAYER_NAME+1];
its just a global array called Name with 25 cells which are 100 bytes (800 bits) - maybe I am wrong, hard to remain if you never use it

and to your problem
pawn Код:
if(params[128] == dini_Int("Players.ini", Name))
Solution
pawn Код:
if(!strcmp(params, dini_Get("Players.ini", Name), true))
because the password isnt always an integer

And just as advance notice the array name isnt player assigned
Reply
#7

So can you guys help me fix it?
Reply
#8

Thnx for the code, but if i type nothing now like: /login
It will just say logged in
Reply
#9

that happens because dini_Gets returns 0 and if you compare nothing with nothing it will success and log you in, so we do now
pawn Код:
dcmd_login(playerid, params[])
{
    print("Got Input FS");
    if(!strlen(params) || strcmp(params, dini_Get("Players.ini", Name), true) != 0)
        return SendClientMessage(playerid, COLOR_RED, "Invalid Password! Please Retry.");
    SendClientMessage(playerid, COLOR_RED, "Logged In.");
    _LOGIN_LoggedIn[playerid] = 1;
    return 1;
}
Reply
#10

Yes but why should he use 25 cells when the limit is 24?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)