Loading a value from an .ini file [Help needed]
#1

Hello, I'm having an issue with loading a saved player skin. Whenever a player chooses or buys a skin it will be saved.
if they respawn it will be loaded but if they logout and then log in again they will get the defaut skin, which in my case is skin id 3. If they then proceed onto dying and then respawning after logging out then in again they will still have skin id 3. However, here is the super hilarious part which kinda shocked me abit. If they player types the wrong password one or more times in the login dialog the skin will load and everything is normal, if they then die they will spawn with their either selected or bought skin! Strange? haha.

Here is the main login AND register code:

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if (dialogid == REGISTER)
	{
		new name[MAX_PLAYER_NAME], string[128], str[128], str1[128];
  		GetPlayerName(playerid, name, sizeof(name));
		if(!response) return Kick(playerid);
		format(str1, 128, "{FFFFFF}Welcome to my server\n\n{DDCA22}Account:{FFFFFF} %s\n\nPlease Enter Your Password Below", name);if(!strlen(inputtext)) return
        ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "Registration", str1, "Register", "");
		dini_Create(Pos(playerid));
        IsLogged[playerid] = 1;
        registered[playerid] = 1;
        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		dini_IntSet(Pos(playerid), "Password", udb_hash(inputtext));
		dini_IntSet(Pos(playerid), "Banned", 0);
		dini_IntSet(Pos(playerid), "AdminLevel",PlayerInfo[playerid][AdminLevel] = 0);
		format(string, 128, "You Have Succesfully Registered The Account {0DF2F2}'%s' {FFFF00}With The Password {0DF2F2}'%s'", name, inputtext);
        format(str, 128, "You Have Been Automatically Logged In, Play Fairly Following The Rules");
		SendClientMessage(playerid, COLOR_YELLOW, string);
		SendClientMessage(playerid,COLOR_YELLOW, str);
		ShowPlayerDialog(playerid, SKIN, DIALOG_STYLE_MSGBOX, "Skin Selection", "{FFFFFF}As This Is The First Time You Have Connected To The Server,\nWe Want You To Select Your Skin On Your Own\nChoice Suiting Your Character", "Alright","");
		return 1;
	}

	if (dialogid == LOGIN)
	{
      new name[MAX_PLAYER_NAME], str1[128], tmp=dini_Int(Pos(playerid), "Password");
      if(!response) return Kick(playerid);
      GetPlayerName(playerid, name, sizeof(name));
      format(str1, 128, "{FFFFFF}Welcome to Freedom Roleplays Clan\n\n{DDCA22}Account:{FFFFFF} %s\n\nPlease Enter Your Password Below", name);
	  if (!strlen(inputtext)) return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login Account",str1, "Login", "");
      if(udb_hash(inputtext) == tmp)
	  {
	    LoadStats(playerid);
		IsLogged[playerid] = 1;
		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		SendClientMessage(playerid,0x00FFFF00, "You've successfully logged in!");
		SetSpawnInfo(playerid,0,dini_Int(Pos(playerid),"Skin"),dini_Int(Pos(playerid), "X1"),dini_Int(Pos(playerid), "Y1"), dini_Int(Pos(playerid), "Z1"),0, 0, 0, 0, 0, 0, 0 );
		SpawnPlayer(playerid);
		PlayerConnect(playerid);
		format(str1, 128,"Experience: {FFFFFF}Level %d",GetPlayerScore(playerid));
		SendClientMessage(playerid,0x10F441AA,str1);
		if(GetPlayerBusinessID(playerid) != -1)
		{
			format(File,sizeof(File),"Business/%i.ini",GetPlayerBusinessID(playerid));
			format(str1,sizeof(str1),"Business Name: {FFFFFF}'%s'",dini_Get(File, "Name"));
			SendClientMessage(playerid,COLOR_YELLOW, str1);
		}
		if(PlayerInfo[playerid][VIP]>= 1)
		{
			new mode[128],str[256];
      		if(PlayerInfo[playerid][VIP]==1)
			{mode = "{FFFF00}Silver Premium Account";}
			if(PlayerInfo[playerid][VIP]==2)
			{mode = "{0000BB}Golden Premium Account";}
			if(PlayerInfo[playerid][VIP]==3)
			{mode = "{ADFF2F}Luxury Premium Account";}
			format(str,sizeof(str),"Account Status : %s",mode);
			SendClientMessage(playerid,-1,str);
		}
	  }
      else
      {
     		SendClientMessage(playerid,-1, "Access Denied.");
      		ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login Account", "{FFFFFF}The Password That You Entered Was Invalid\n\nPlease Enter The Password Again.", "Login", "");
	  }
	  return 1;
	}
Here is the onplayerspawn code:
Код:
public OnPlayerSpawn(playerid)
{
	if(registered[playerid] == 1)
	{
	    SetupPlayerForClassSelection(playerid);
	    registered[playerid]=0;
		ResetPlayerWeapons(playerid);
	    SetPlayerInterior(playerid,0);
		GivePlayerMoney(playerid, 25000);
	    SetPlayerVirtualWorld(playerid,0);
	}
	PlayerData[playerid][CP] = -1;
	PlayerData[playerid][Step] = 0;
	PlayerData[playerid][InPickUp] = 0;
    SetPlayerVirtualWorld(playerid, 0);
    return 1;
}
Any help is highly appriciated! So pre-thanks My first post here so please correct me if I made a mistake.
Reply


Messages In This Thread
Loading a value from an .ini file [Help needed] - by Trent2 - 17.01.2014, 19:21

Forum Jump:


Users browsing this thread: 1 Guest(s)