Need help with accessing string arrays
#1

Hello there!
I tried to make a simple /register and /login script with dini.

Here's the script:

Код:
	

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


dcmd_register(playerid, params[])
{
	if (dini_Exists(gPlayerfile[playerid]))
	{	
		SendClientMessage(playerid, 0xFF0000FF, "You have already registered.");
		return 0;
	}
	else 
	{
		if (!params[0]) 
		{
			SendClientMessage(playerid, 0xFF0000FF, "Usage: /register <password>");
			return 0;
		}
		else 
		{
			dini_Create(gPlayerfile[playerid]);
			dini_Set(gPlayerfile[playerid], "Password", params);
			SendClientMessage(playerid, 0x00FF00FF, "You have successfully registered. Proceed to login thanks.");
			return 1;
		}
	}
}

dcmd_login(playerid, params[])
{
	if (!dini_Exists(gPlayerfile[playerid]))
	{
		SendClientMessage(playerid, 0xFF0000FF, "You have not registered.");
		return 0;
	}
	else if (gPlayerlogged[playerid])
	{
		SendClientMessage(playerid, 0x00FF00FF, "You have already logged in.");
		return 0;
	}
	else
	{
		new pw[1000];
		pw = dini_Get(gPlayerfile[playerid], "Password");
		if (params == pw) // THIS LINE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
		{
			gPlayerlogged[playerid] = 1;
			SendClientMessage(playerid, 0x00FF00FF, "Login successful.");
			return 1;
		}
		else
		{
			SendClientMessage(playerid, 0xFF0000FF, "Wrong password.");
			return 0;
		}
	}
}
The error says that params and pw should be indexed. Since the password is a string, I can't index it to a specific character. This may be too obvious, but I'm a newb. So please help
Thanks!

EDIT: Btw the register part works just fine. When I read the file, the password is set correctly.
Reply


Messages In This Thread
Need help with accessing string arrays - by iMr - 02.05.2009, 07:57
Re: Need help with accessing string arrays - by yom - 02.05.2009, 08:07
Re: Need help with accessing string arrays - by iMr - 02.05.2009, 09:19
Re: Need help with accessing string arrays - by HB - 02.05.2009, 09:35
Re: Need help with accessing string arrays - by iMr - 02.05.2009, 11:11
Re: Need help with accessing string arrays - by pen_theGun - 02.05.2009, 13:17

Forum Jump:


Users browsing this thread: 1 Guest(s)