Uso dini.
Meu sistema de registro/logar funciona assim.
Existem dois: LoadPlayerConfig e SavePlayerConfig.
pawn Код:
//Save Account System
forward SavePlayerConfig(playerid);
forward LoadPlayerConfig(playerid);
public SavePlayerConfig(playerid)
{
new FilePath[256];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(FilePath, sizeof(FilePath), "%s%s.ini",UserFiles,pname);
if(!dini_Exists(FilePath))
{
}
else if(PlayerInfo[playerid][Loged] == 1)
{
dini_Set(FilePath, "Name", PlayerInfo[playerid][Name]);
dini_IntSet(FilePath, "Level", PlayerInfo[playerid][Level]);
dini_IntSet(FilePath, "WantedLevel", PlayerInfo[playerid][WantedLevel]);
dini_IntSet(FilePath, "Money", GetPlayerMoneyEx(playerid));
dini_IntSet(FilePath, "Job", PlayerInfo[playerid][Job]);
dini_IntSet(FilePath, "Org", PlayerInfo[playerid][Org]);
dini_IntSet(FilePath, "Warnings", PlayerInfo[playerid][Warnings]);
dini_IntSet(FilePath, "Banned", PlayerInfo[playerid][Banned]);
dini_IntSet(FilePath, "Admin", PlayerInfo[playerid][Admin]);
dini_IntSet(FilePath, "VipLevel", PlayerInfo[playerid][VipLevel]);
dini_IntSet(FilePath, "Kills", PlayerInfo[playerid][Kills]);
dini_IntSet(FilePath, "Deaths", PlayerInfo[playerid][Deaths]);
dini_IntSet(FilePath, "BankMoney", PlayerInfo[playerid][BankMoney]);
dini_IntSet(FilePath, "GameTime", PlayerInfo[playerid][GameTime]);
dini_IntSet(FilePath, "Respect", PlayerInfo[playerid][Respect]);
dini_IntSet(FilePath, "Cargo", PlayerInfo[playerid][Cargo]);
dini_IntSet(FilePath, "JailTime", PlayerInfo[playerid][JailTime]);
dini_IntSet(FilePath, "Jails", PlayerInfo[playerid][Jails]);
dini_IntSet(FilePath, "Crims", PlayerInfo[playerid][Crims]);
dini_IntSet(FilePath, "SkillMecanico", PlayerInfo[playerid][SkillMecanico]);
dini_IntSet(FilePath, "Skin", PlayerInfo[playerid][Skin]);
dini_IntSet(FilePath, "Lider", PlayerInfo[playerid][Lider]);
dini_IntSet(FilePath, "NecessaryToUp", PlayerInfo[playerid][NecessaryToUp]);
dini_IntSet(FilePath, "MobileNumber", PlayerInfo[playerid][MobileNumber]);
dini_IntSet(FilePath, "ToUpSkillMecanico", PlayerInfo[playerid][ToUpSkillMecanico]);
dini_IntSet(FilePath, "SpawnAtHome", PlayerInfo[playerid][SpawnAtHome]);
dini_IntSet(FilePath, "Contrato", PlayerInfo[playerid][Contrato]);
dini_IntSet(FilePath, "CarandiruTime", PlayerInfo[playerid][CarandiruTime]);
dini_IntSet(FilePath, "pMats", PlayerInfo[playerid][pMats]);
dini_IntSet(FilePath, "Drogas", PlayerInfo[playerid][Drogas]);
dini_IntSet(FilePath, "PenaR", PlayerInfo[playerid][PenaR]);
dini_IntSet(FilePath, "TraficoDelay", PlayerInfo[playerid][TraficoDelay]);
dini_IntSet(FilePath, "Agenda", PlayerInfo[playerid][Agenda]);
dini_IntSet(FilePath, "VipId", PlayerInfo[playerid][VipId]);
dini_IntSet(FilePath, "JobTime", PlayerInfo[playerid][JobTime]);
dini_IntSet(FilePath, "LNautica", PlayerInfo[playerid][LNautica]);
dini_IntSet(FilePath, "LAerea", PlayerInfo[playerid][LAerea]);
dini_IntSet(FilePath, "LTerrestre", PlayerInfo[playerid][LTerrestre]);
dini_IntSet(FilePath, "PorteDeArmas", PlayerInfo[playerid][PorteDeArmas]);
dini_IntSet(FilePath, "Iscas", PlayerInfo[playerid][Iscas]);
dini_IntSet(FilePath, "ValorDaPesca", PlayerInfo[playerid][ValorDaPesca]);
dini_IntSet(FilePath, "SkinCasual", PlayerInfo[playerid][SkinCasual]);
dini_IntSet(FilePath, "Xp", PlayerInfo[playerid][Xp]);
dini_IntSet(FilePath, "Doenca", PlayerInfo[playerid][Doenca]);
dini_IntSet(FilePath, "HospitalTime", PlayerInfo[playerid][HospitalTime]);
dini_IntSet(FilePath, "Vacina", PlayerInfo[playerid][Vacina]);
dini_IntSet(FilePath, "Cigarro", PlayerInfo[playerid][Cigarro]);
dini_IntSet(FilePath, "Terco", PlayerInfo[playerid][Terco]);
dini_IntSet(FilePath, "GalinhaPreta", PlayerInfo[playerid][GalinhaPreta]);
dini_IntSet(FilePath, "MacumbaDelay", PlayerInfo[playerid][MacumbaDelay]);
dini_IntSet(FilePath, "RezaDelay", PlayerInfo[playerid][RezaDelay]);
dini_IntSet(FilePath, "Harpao", PlayerInfo[playerid][Harpao]);
dini_IntSet(FilePath, "NoteBook", PlayerInfo[playerid][NoteBook]);
dini_IntSet(FilePath, "Mochila", PlayerInfo[playerid][Mochila]);
dini_IntSet(FilePath, "Estilo", PlayerInfo[playerid][Estilo]);
dini_IntSet(FilePath, "Aplicacao", PlayerInfo[playerid][Aplicacao]);
dini_IntSet(FilePath, "Tutorial", Tutorial[playerid]);
dini_IntSet(FilePath, "Nomedopai", PlayerInfo[playerid][Nomedopai]);
dini_IntSet(FilePath, "Nomedamae", PlayerInfo[playerid][Nomedamae]);
dini_IntSet(FilePath, "Anonascido", PlayerInfo[playerid][Anonascido]);
dini_IntSet(FilePath, "Mesnascido", PlayerInfo[playerid][Mesnascido]);
dini_IntSet(FilePath, "Dianascido", PlayerInfo[playerid][Dianascido]);
printf("Conta de %s salva com sucesso.",PlayerInfo[playerid][Name]);
}
}
public LoadPlayerConfig(playerid)
{
new FilePath[256];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(FilePath, sizeof(FilePath), "%s%s.ini",UserFiles,pname);
if(!dini_Exists(FilePath))
{
dini_Create(FilePath);
dini_Set(FilePath, "Name", PlayerInfo[playerid][Name]);
dini_IntSet(FilePath, "Level",1);
dini_IntSet(FilePath, "Money",0);
dini_IntSet(FilePath, "WantedLevel",0);
dini_IntSet(FilePath, "Job", 0);
dini_IntSet(FilePath, "Org", 0);
dini_Set(FilePath, "Ip", PlayerInfo[playerid][Ip]);
dini_IntSet(FilePath, "Warnings", 0);
dini_IntSet(FilePath, "Banned", 0);
dini_IntSet(FilePath, "Admin", 0);
dini_IntSet(FilePath, "VipLevel", 0);
dini_IntSet(FilePath, "Kills", 0);
dini_IntSet(FilePath, "Deaths", 0);
dini_IntSet(FilePath, "BankMoney", 500);
dini_IntSet(FilePath, "GameTime", 0);
dini_IntSet(FilePath, "Respect", 0);
dini_IntSet(FilePath, "Cargo", 0);
dini_IntSet(FilePath, "JailTime", -1);
dini_IntSet(FilePath, "Jails", 0);
dini_IntSet(FilePath, "Crims", 0);
dini_IntSet(FilePath, "SkillMecanico", 0);
dini_IntSet(FilePath, "Skin", 95);
dini_IntSet(FilePath, "Lider", 0);
dini_IntSet(FilePath, "NecessaryToUp", 6);
dini_IntSet(FilePath, "MobileNumber", 0);
dini_IntSet(FilePath, "ToUpSkillMecanico", 50);
dini_IntSet(FilePath, "SpawnAtHome", 0);
dini_IntSet(FilePath, "Contrato", 0);
dini_IntSet(FilePath, "CarandiruTime", -1);
dini_IntSet(FilePath, "pMats", 0);
dini_IntSet(FilePath, "Drogas", 0);
dini_IntSet(FilePath, "PenaR", 0);
dini_IntSet(FilePath, "TraficoDelay", 0);
dini_IntSet(FilePath, "Agenda", 0);
dini_IntSet(FilePath, "VipId", -1);
dini_IntSet(FilePath, "VipDays", -1);
dini_IntSet(FilePath, "JobTime", 0);
dini_IntSet(FilePath, "LNautica", 0);
dini_IntSet(FilePath, "LAerea", 0);
dini_IntSet(FilePath, "LTerrestre", 0);
dini_IntSet(FilePath, "PorteDeArmas", 0);
dini_IntSet(FilePath, "Iscas", 0);
dini_IntSet(FilePath, "ValorDaPesca", 0);
dini_IntSet(FilePath, "SkinCasual", 95);
dini_IntSet(FilePath, "Xp", 95);
dini_IntSet(FilePath, "Doenca", 0);
dini_IntSet(FilePath, "HospitalTime", -1);
dini_IntSet(FilePath, "Vacina", 0);
dini_IntSet(FilePath, "Cigarro", 0);
dini_IntSet(FilePath, "Terco", 0);
dini_IntSet(FilePath, "GalinhaPreta", 0);
dini_IntSet(FilePath, "MacumbaDelay", 0);
dini_IntSet(FilePath, "RezaDelay", 0);
dini_IntSet(FilePath, "Harpao", 0);
dini_IntSet(FilePath, "NoteBook", 0);
dini_IntSet(FilePath, "Mochila", 0);
dini_IntSet(FilePath, "Estilo", 0);
dini_IntSet(FilePath, "Aplicacao", 0);
dini_IntSet(FilePath, "Tutorial", 1);
dini_IntSet(FilePath, "Nomedopai", PlayerInfo[playerid][Nomedopai]);
dini_IntSet(FilePath, "Anonascido", PlayerInfo[playerid][Anonascido]);
dini_IntSet(FilePath, "Mesnascido", PlayerInfo[playerid][Mesnascido]);
dini_IntSet(FilePath, "Dianascido", PlayerInfo[playerid][Dianascido]);
GivePlayerMoneyEx(playerid,500);
SetPlayerScore(playerid,1);
printf("Conta de %s criada com sucesso.",PlayerInfo[playerid][Name]);
}
else
{
ResetPlayerMoneyEx(playerid);
SetPlayerScore(playerid, dini_Int(FilePath, "Level"));
PlayerInfo[playerid][Level] = dini_Int(FilePath, "Level");
PlayerInfo[playerid][WantedLevel] = dini_Int(FilePath, "WantedLevel");
GivePlayerMoneyEx(playerid,dini_Int(FilePath, "Money"));
PlayerInfo[playerid][Job] = dini_Int(FilePath, "Job");
PlayerInfo[playerid][Org] = dini_Int(FilePath, "Org");
PlayerInfo[playerid][Warnings] = dini_Int(FilePath, "Warnings");
PlayerInfo[playerid][Banned] = dini_Int(FilePath, "Banned");
PlayerInfo[playerid][Admin] = dini_Int(FilePath, "Admin");
PlayerInfo[playerid][VipLevel] = dini_Int(FilePath, "VipLevel");
PlayerInfo[playerid][Kills] = dini_Int(FilePath, "Kills");
PlayerInfo[playerid][Deaths] = dini_Int(FilePath, "Deaths");
PlayerInfo[playerid][BankMoney] = dini_Int(FilePath, "BankMoney");
PlayerInfo[playerid][GameTime] = dini_Int(FilePath, "GameTime");
PlayerInfo[playerid][Respect] = dini_Int(FilePath, "Respect");
PlayerInfo[playerid][Cargo] = dini_Int(FilePath, "Cargo");
PlayerInfo[playerid][JailTime] = dini_Int(FilePath, "JailTime");
PlayerInfo[playerid][Jails] = dini_Int(FilePath, "Jails");
PlayerInfo[playerid][Crims] = dini_Int(FilePath, "Crims");
PlayerInfo[playerid][SkillMecanico] = dini_Int(FilePath, "SkillMecanico");
PlayerInfo[playerid][Lider] = dini_Int(FilePath, "Lider");
PlayerInfo[playerid][Skin] = dini_Int(FilePath, "Skin");
PlayerInfo[playerid][Cargo] = dini_Int(FilePath, "Cargo");
PlayerInfo[playerid][NecessaryToUp] = dini_Int(FilePath, "NecessaryToUp");
PlayerInfo[playerid][SpawnAtHome] = dini_Int(FilePath, "SpawnAtHome");
PlayerInfo[playerid][Contrato] = dini_Int(FilePath, "Contrato");
PlayerInfo[playerid][CarandiruTime] = dini_Int(FilePath, "CarandiruTime");
PlayerInfo[playerid][pMats] = dini_Int(FilePath, "pMats");
PlayerInfo[playerid][Drogas] = dini_Int(FilePath, "Drogas");
PlayerInfo[playerid][PenaR] = dini_Int(FilePath, "PenaR");
PlayerInfo[playerid][MobileNumber] = dini_Int(FilePath, "MobileNumber");
PlayerInfo[playerid][ToUpSkillMecanico] = dini_Int(FilePath, "ToUpSkillMecanico");
PlayerInfo[playerid][TraficoDelay] = dini_Int(FilePath, "TraficoDelay");
PlayerInfo[playerid][Agenda] = dini_Int(FilePath, "Agenda");
PlayerInfo[playerid][VipId] = dini_Int(FilePath, "VipId");
PlayerInfo[playerid][VipDays] = dini_Int(FilePath, "VipDays");
PlayerInfo[playerid][JobTime] = dini_Int(FilePath, "JobTime");
PlayerInfo[playerid][LNautica] = dini_Int(FilePath, "LNautica");
PlayerInfo[playerid][LAerea] = dini_Int(FilePath, "LAerea");
PlayerInfo[playerid][LTerrestre] = dini_Int(FilePath, "LTerrestre");
PlayerInfo[playerid][PorteDeArmas] = dini_Int(FilePath, "PorteDeArmas");
PlayerInfo[playerid][Iscas] = dini_Int(FilePath, "Iscas");
PlayerInfo[playerid][ValorDaPesca] = dini_Int(FilePath, "ValorDaPesca");
PlayerInfo[playerid][SkinCasual] = dini_Int(FilePath, "SkinCasual");
PlayerInfo[playerid][Xp] = dini_Int(FilePath, "Xp");
PlayerInfo[playerid][Doenca] = dini_Int(FilePath, "Doenca");
PlayerInfo[playerid][HospitalTime] = dini_Int(FilePath, "HospitalTime");
PlayerInfo[playerid][Vacina] = dini_Int(FilePath, "Vacina");
PlayerInfo[playerid][Cigarro] = dini_Int(FilePath, "Cigarro");
PlayerInfo[playerid][Terco] = dini_Int(FilePath, "Terco");
PlayerInfo[playerid][GalinhaPreta] = dini_Int(FilePath, "GalinhaPreta");
PlayerInfo[playerid][MacumbaDelay] = dini_Int(FilePath, "MacumbaDelay");
PlayerInfo[playerid][RezaDelay] = dini_Int(FilePath, "RezaDelay");
PlayerInfo[playerid][Harpao] = dini_Int(FilePath, "Harpao");
PlayerInfo[playerid][NoteBook] = dini_Int(FilePath, "NoteBook");
PlayerInfo[playerid][Mochila] = dini_Int(FilePath, "Mochila");
PlayerInfo[playerid][Estilo] = dini_Int(FilePath, "Estilo");
PlayerInfo[playerid][Aplicacao] = dini_Int(FilePath, "Aplicacao");
Tutorial[playerid] = dini_Int(FilePath, "Tutorial");
printf("Conta de %s carregada com sucesso.",PlayerInfo[playerid][Name]);
}
return 1;
}