Dini Problem, Accounts Not Creating
#1

Something is wrong with my Dini Code that whenever someone does /register, nothing happens. It says, "Account Created". But Nothing is created .

Note: First Time using Dini.
Code:

Code:
if(strcmp(cmd, "/register", true) == 0)
	{
	  new name[MAX_PLAYER_NAME];
	  tmp = strtok(cmdtext, idx);
	  if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /register [password]");
	  if(dini_Exists(file))
			{
			  dini_Create(file);
			  dini_IntSet(file, "Password", udb_hash(tmp));
			  dini_IntSet(file,"Level", 0);
			  dini_IntSet(file,"AdminLevel", 0);
			  dini_IntSet(file,"Cash", 0);
			  dini_IntSet(file,"Muted", 0);
			  dini_IntSet(file,"Score", 0);
			  SendClientMessage(playerid, eadmin, "[EADMIN]: Account Created!");
			  PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
			  GetPlayerName(playerid, name, sizeof(name));
			  printf("%s has registered a account!", name);
			}
			else
			{
			  SendClientMessage(playerid, eadmin, "[EADMIN]: Account Already Found In Database");
        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
			}
	}
	if(strcmp(cmd, "/login", true) == 0)
	{
	  new name[MAX_PLAYER_NAME];
		if(gLogged[playerid] == 1)
		{
		  SendClientMessage(playerid, eadmin, "You already are logged in!");
		  return 1;
		}
		else
		{
		  if(dini_Exists(file))
			{
		  	tmp2 = dini_Get(file, "Password");
			 	if(udb_hash(tmp) != strval(tmp2))
				{
				  SendClientMessage(playerid, eadmin, "Login Failed!");
	 			  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	 			  printf("%s has failed to login", name);
				}
				else
				{
					gLogged[playerid] = 1;
					GivePlayerMoney(playerid, dini_Int(file, "Cash"));
					PlayerInfo[playerid][pLevel] = dini_Int(file, "Level");
					PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
					PlayerInfo[playerid][pMuted] = dini_Int(file, "Muted");
					PlayerInfo[playerid][pScore] = dini_Int(file, "Score");
					SendClientMessage(playerid, eadmin, "[EADMIN]: Account Logged into!");
				}
				return 1;
			}
		}
	}
Reply
#2

Code:
format(file,sizeof(file),"%s.ini",PlayerNickHere);
if(!fexist(file))
Reply
#3

Quote:
Originally Posted by Jefff
Code:
format(file,sizeof(file),"%s.ini",PlayerNickHere);
if(dini_Exists(file))
Still doesn't work, this is the new /register command

Code:
if(strcmp(cmd, "/register", true) == 0)
	{
	  new name[MAX_PLAYER_NAME];
	  tmp = strtok(cmdtext, idx);
	  GetPlayerName(playerid, name, sizeof(name));
	  if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /register [password]");
	  format(file,sizeof(file),"%s.ini",name);
	  if(dini_Exists(file))
			{
			  dini_Create(file);
			  dini_IntSet(file, "Password", udb_hash(tmp));
			  dini_IntSet(file,"Level", 0);
			  dini_IntSet(file,"AdminLevel", 0);
			  dini_IntSet(file,"Cash", 0);
			  dini_IntSet(file,"Muted", 0);
			  dini_IntSet(file,"Score", 0);
			  SendClientMessage(playerid, eadmin, "[EADMIN]: Account Created!");
			  PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
			  GetPlayerName(playerid, name, sizeof(name));
			  printf("%s has registered a account!", name);
			}
			else
			{
			  SendClientMessage(playerid, eadmin, "[EADMIN]: Account Already Found In Database");
        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
			}
	}
Reply
#4

Create the file first via dini_Create
Reply
#5

I've edited 1 post
should be
Code:
if(!dini_Exists(file))
but U dont need that way

simply:
Code:
if(!fexist(file))
Reply
#6

Quote:
Originally Posted by Jefff
I've edited 1 post
should be
Code:
if(!dini_Exists(file))
but U dont need that way

simply:
Code:
if(!fexist(file))
Success, ok now the other problem with /login,

The new /login command is:

Code:
if(strcmp(cmd, "/login", true) == 0)
	{
	  new name[MAX_PLAYER_NAME];
		if(gLogged[playerid] == 1)
		{
		  SendClientMessage(playerid, eadmin, "You already are logged in!");
		  return 1;
		}
		else
		{
		  if(!fexist(file))
			{
		  	tmp2 = dini_Get(file, "Password");
			 	if(udb_hash(tmp) != strval(tmp2))
				{
				  SendClientMessage(playerid, eadmin, "Login Failed!");
	 			  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	 			  printf("%s has failed to login", name);
				}
				else
				{
					gLogged[playerid] = 1;
					GivePlayerMoney(playerid, dini_Int(file, "Cash"));
					PlayerInfo[playerid][pLevel] = dini_Int(file, "Level");
					PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
					PlayerInfo[playerid][pMuted] = dini_Int(file, "Muted");
					PlayerInfo[playerid][pScore] = dini_Int(file, "Score");
					SendClientMessage(playerid, eadmin, "[EADMIN]: Account Logged into!");
				}
				return 1;
			}
		}
	}
Now it just keeps saying "Login Failed" When I write /login [mypassword]
Reply
#7

Code:
format(file,sizeof(file),"%s.ini",PlayerNickHere);
if(fexist(file))
:P
Reply
#8

Quote:
Originally Posted by Jefff
Code:
format(file,sizeof(file),"%s.ini",PlayerNickHere);
if(fexist(file))
:P
lol I forgot to put it in /login sorry
Reply
#9

And strtok too
Code:
if(strcmp(cmd, "/login", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
		new name[MAX_PLAYER_NAME];
		if(gLogged[playerid] == 1)
		{
			SendClientMessage(playerid, eadmin, "You already are logged in!");
			return 1;
		}
		else
		{
			GetPlayerName(playerid, name, sizeof(name));
			format(file,sizeof(file),"%s.ini",name);
			if(fexist(file))
			{
Reply
#10

Quote:
Originally Posted by Jefff
And strtok too
Code:
if(strcmp(cmd, "/login", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
		new name[MAX_PLAYER_NAME];
		if(gLogged[playerid] == 1)
		{
			SendClientMessage(playerid, eadmin, "You already are logged in!");
			return 1;
		}
		else
		{
			GetPlayerName(playerid, name, sizeof(name));
			format(file,sizeof(file),"%s.ini",name);
			if(fexist(file))
			{
It works, Thanks Jefff :P
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)