VIP system won't save data
#6

This is how the public OnPlayerConnect and OnPlayerDisconnect looks like

Код:
public OnPlayerConnect(playerid)
{
	PlayerInfo[playerid][pVIP] = 0; //Setting the VIP level 0 on player connect-
	Enablevheal[playerid] = 1; //Enabling the /vheal command on player connect--
	Enablevbonus[playerid] = 1; //Enabling the /vbonus command on player connect
	HasSpawnedCar[playerid] = 0;//-Setting the value to 0
	//-------------Checking and creating the player account in database---------
	if(fexist(getACC(playerid)))
	{
	   new string[256];
	   INI_Open(getACC(playerid));
	   PlayerInfo[playerid][pVIP] = INI_ReadInt("Level");
       format(string, sizeof(string),"Welcome %s Your VIP level has been successfully loaded [VIP Level: %d][VIP Rank: %s]",PlayerName(playerid),PlayerInfo[playerid][pVIP],Rank(playerid));
       print("\n----------------------------------------------------------");
       printf("_____[%s] Very Important Player Connected_____", PlayerName(playerid));
	   print("------------------------------------------------------------\n");
	   SendClientMessage(playerid, GREEN,string);
	}
    else
    {
	   MakeACC(playerid); //Creating the account if the account doesn't exists
	}
	return 1;
}
//Saving PLayer Stats on his disconnect=========================================
public OnPlayerDisconnect(playerid, reason)
{
	SaveLevel(playerid);
	return 1;
}
Here are some stocks:

Код:
//=============================STOCKS===========================================
stock PlayerName(playerid) 
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
//===================Account====================================================
stock getACC(playerid)
{
    new file[200];
    format(file, sizeof(file),"VIP/%s.ini",PlayerName(playerid));
    return file;
}
//============Vip Ranks Can be editted==========================================
stock Rank(playerid)
{
    new str[156];
    if(PlayerInfo[playerid][pVIP] == 0) str = ("Player");
    else if(PlayerInfo[playerid][pVIP] == 1) str = ("Donator Level 1");
    else if(PlayerInfo[playerid][pVIP] == 2) str = ("Donator Level 2");
    else if(PlayerInfo[playerid][pVIP] == 3) str = ("Donator Level 3");
    return str;
}
//=====================Creating the account=====================================
stock MakeACC(playerid)
{
   if(!fexist(getACC(playerid)))
   {
      new string[125];
	  format(string, sizeof(string),"%s",Rank(playerid));
      INI_Open(getACC(playerid));
      INI_WriteInt("Level",0);
      INI_WriteString("Rank",string);
      INI_Save();
      INI_Close();
      PlayerInfo[playerid][pVIP] = 0;
  }
  return 1;
}
//===========Saving the VIP level===============================================
stock SaveLevel(playerid)
{
   INI_Open(getACC(playerid));
   INI_WriteInt("Level",PlayerInfo[playerid][pVIP]);
   INI_WriteString("Rank",Rank(playerid));
   INI_Save();
   INI_Close();
   SendClientMessage(playerid, LIGHTGREEN,"VIP Level saved in accounts!");
   return 1;
}
Reply


Messages In This Thread
VIP system won't save data - by Jhony_Blaze - 10.12.2014, 20:52
Re: VIP system won't save data - by Jhony_Blaze - 10.12.2014, 21:27
Re: VIP system won't save data - by xCrazyMonkey - 11.12.2014, 06:32
Re: VIP system won't save data - by Sledgehammer - 11.12.2014, 06:36
Re: VIP system won't save data - by Accent - 11.12.2014, 06:37
Re: VIP system won't save data - by Jhony_Blaze - 11.12.2014, 09:50

Forum Jump:


Users browsing this thread: 2 Guest(s)