Giving a variable problem
#7

Код:
public OnPlayerDisconnect(playerid, reason)
{
	new file[128];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file,sizeof(file),"/Users/%s.ini",name);
	if(!dini_Exists(file))
	{
  dini_IntSet(file, "score", GetPlayerScore(playerid));
  dini_IntSet(file, "money", GetPlayerMoney(playerid));
	dini_IntSet(file, "Cookies",GetPVarInt(playerid,"Cookies"));
	}
	logged[playerid] = 0;
	dm[playerid] =0;
	God[playerid] =0;
	return 1;
}
^^
Is how i save.

Код:
dcmd_register(playerid, params[])
{
  new file[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE:/register [password]");
  if(dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are already registered!");
  dini_Create(file);
  dini_IntSet(file, "hashPW", udb_hash(params));
  dini_Set(file, "password", params);
  dini_IntSet(file, "level", 0);
  dini_IntSet(file, "score", GetPlayerScore(playerid));
  dini_IntSet(file, "money", GetPlayerMoney(playerid));
	dini_IntSet(file, "Cookies",GetPVarInt(playerid,"Cookies")+1);
  new string[128];
  format(string, 128, "You succesfully registered the nickname %s with password %s", pname, params);
  SendClientMessage(playerid, COLOR_YELLOW, string);
  logged[playerid] = 1;
  SendClientMessage(playerid, COLOR_YELLOW, "You have been automatically logged in!");
  return 1;}
///////////////////////////L O G I N//////////////////////////
dcmd_login(playerid, params[])
{
  new file[128];
  new string[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /login [password]");
  if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are not registered!");
  if(logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
  new tmp;
  tmp = dini_Int(file, "hashPW");
  if(udb_hash(params) != tmp)
  {
    format(string, 256, "You specified the wrong password for %s!", pname);
    SendClientMessage(playerid, COLOR_RED, string);
  }
  else
  {
    logged[playerid] = 1;
    level[playerid] = dini_Int(file, "level");
		SetPlayerScore(playerid, dini_Int(file, "score"));
		SetPVarInt(playerid,"Cookies", dini_Int(file, "Cookies"));
		GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
    SendClientMessage(playerid, COLOR_YELLOW, "You have succesfully logged in!");
    printf("%s (%i) logged in with password %s", pname, playerid, params);
  }
  return 1;
}
Reply


Messages In This Thread
Giving a variable problem - by -Rebel Son- - 05.06.2010, 23:26
Re: Giving a variable problem - by (SF)Noobanatior - 05.06.2010, 23:29
Re: Giving a variable problem - by -Rebel Son- - 05.06.2010, 23:32
Re: Giving a variable problem - by (SF)Noobanatior - 05.06.2010, 23:44
Re: Giving a variable problem - by -Rebel Son- - 05.06.2010, 23:54
Re: Giving a variable problem - by (SF)Noobanatior - 05.06.2010, 23:56
Re: Giving a variable problem - by -Rebel Son- - 05.06.2010, 23:57
Re: Giving a variable problem - by (SF)Noobanatior - 06.06.2010, 00:01
Re: Giving a variable problem - by -Rebel Son- - 06.06.2010, 00:07
Re: Giving a variable problem - by (SF)Noobanatior - 06.06.2010, 00:09

Forum Jump:


Users browsing this thread: 1 Guest(s)