login / register
#1

im haveing problems with my register system i have this

Код:
public OnPlayerConnect(playerid)
{
 	new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
	if(!dini_Exists(file)) {
		dini_Create(file);
		dini_Set(file,"Name",Name);
		dini_Set(file,"Ip",Ip);
		dini_IntSet(file,"Registered",-1);
		dini_IntSet(file,"Password",0);
		dini_IntSet(file,"Level",0);
		dini_IntSet(file,"Wired",0);
		dini_IntSet(file,"Jailed",0);
		SendClientMessage(playerid,COLOUR_ORANGE,"You're username is not recognized on this server. Please /register to continue.");
	}
	strcat(gPlayerInfo[playerid][PLAYER_NAME],			dini_Get(file,"Name"));
	strcat(gPlayerInfo[playerid][PLAYER_IP],			dini_Get(file,"Ip"));
	gPlayerInfo[playerid][PLAYER_REGGED] 			   = dini_Int(file,"Registered");
	gPlayerInfo[playerid][PLAYER_PASS]              = dini_Int(file,"Password");
	gPlayerInfo[playerid][PLAYER_LEVEL] 			   = dini_Int(file,"Level");
	gPlayerInfo[playerid][PLAYER_WIRED]              = dini_Int(file,"Wired");
	gPlayerInfo[playerid][PLAYER_JAILED] 			   = dini_Int(file,"Jailed");
	if(gPlayerInfo[playerid][PLAYER_REGGED] == 0) 	        SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server, but you have not registered. Please /register to continue.");
	else if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)       SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server. Please /login to continue.");
    gPlayerInfo[playerid][PLAYER_REGGED]             = 0;
	return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
	new file[100]; 
    format(file,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
	dini_Set(file,"Name",gPlayerInfo[playerid][PLAYER_NAME]);
	dini_Set(file,"Ip",gPlayerInfo[playerid][PLAYER_IP]);
	dini_IntSet(file,"Registered",gPlayerInfo[playerid][PLAYER_REGGED]);
	dini_IntSet(file,"Password",gPlayerInfo[playerid][PLAYER_PASS]);
	dini_IntSet(file,"Level",gPlayerInfo[playerid][PLAYER_LEVEL]);
	dini_IntSet(file,"Wired",gPlayerInfo[playerid][PLAYER_WIRED]);
	dini_IntSet(file,"Jailed",gPlayerInfo[playerid][PLAYER_JAILED]);
	gPlayerInfo[playerid][PLAYER_NAME]  = 0;
	gPlayerInfo[playerid][PLAYER_IP]   = 0;
	gPlayerInfo[playerid][PLAYER_REGGED] = 0;
	gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
	gPlayerInfo[playerid][PLAYER_PASS]  = 0;
	gPlayerInfo[playerid][PLAYER_LEVEL] = 0;
	gPlayerInfo[playerid][PLAYER_WIRED] = 0;
	gPlayerInfo[playerid][PLAYER_JAILED] = 0;
  	return 1;
}
Код:
dcmd_register(playerid, params[])
{
  if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
	return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You have already registered!");
  else if(!params[0])
	return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /register [password]");
  /*else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
  {
	new string[200];
    format(string, sizeof(string), "ERROR: Password must be between %d and $d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
	return SendClientMessage(playerid, COLOUR_ORANGE, string);
  }*/
  else
  {
	new password = num_hash(params);
	gPlayerInfo[playerid][PLAYER_PASS] = password;
	gPlayerInfo[playerid][PLAYER_REGGED] = 1;
    gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
	GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
	new string[256]; format(string, sizeof(string), "You have successfully registered your account with the password \'%s\'. You have been automatically logged in.", params);
	return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
  }
}
Код:
dcmd_login(playerid, params[])
{
  if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
	return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
  else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
	return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-in.");
  else if(!params[0])
	return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /login [password]");
  else
  {
	new password = num_hash(params);
	if(gPlayerInfo[playerid][PLAYER_PASS] == password)
	{
	  gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
      GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
	  return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged in to your account.");
	}
	else
	  return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
  }
}

ok so the problem is that it say im logged in but when i type /login [password] it say ERROR: You must register first to do that! Use /register [password] to register and login

so a little help




EDIT: how do i make it so the data save isent there a command
Reply
#2

Is your username recognized when you reconnect to the server after registering ?
Reply
#3

ya it is its just not saveing the info
Reply
#4

ok iv tryed this accountstimer = SetTimer("SaveAccounts", 0, 1); but it dose nothing so if there is more to that line or something ...

plz help
Reply
#5

*BUMP* help plz
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)