// Under "OnPlayerConnect" to set the saved value when connecting
new ClasseSystem[200], jogador[MAX_PLAYER_NAME];
GetPlayerName(playerid, jogador, sizeof(jogador));
format(ClasseSystem, sizeof(ClasseSystem), "CLASSES/%s.ini", jogador);
if(DOF2_FileExists(ClasseSystem))
{
CLASSEide[playerid] = DOF2_GetInt(ClasseSystem, "ClassId");
SetPlayerColor(playerid, DOF2_GetString(ClasseSystem, "NameColor");
checadorCLASSE[playerid][1] = DOF2_GetBool(ClasseSystem, "Checagem1");
checadorCLASSE[playerid][2] = DOF2_GetBool(ClasseSystem, "Checagem2");
checadorCLASSE[playerid][3] = DOF2_GetBool(ClasseSystem, "Checagem3");
checadorCLASSE[playerid][4] = DOF2_GetBool(ClasseSystem, "Checagem4");
checadorCLASSE[playerid][5] = DOF2_GetBool(ClasseSystem, "Checagem5");
checadorCLASSE[playerid][6] = DOF2_GetBool(ClasseSystem, "Checagem6");
checadorCLASSE[playerid][7] = DOF2_GetBool(ClasseSystem, "Checagem7");
checadorCLASSE[playerid][8] = DOF2_GetBool(ClasseSystem, "Checagem8");
checadorCLASSE[playerid][9] = DOF2_GetBool(ClasseSystem, "Checagem9");
checadorCLASSE[playerid][10] = DOF2_GetBool(ClasseSystem, "Checagem10");
checadorCLASSE[playerid][11] = DOF2_GetBool(ClasseSystem, "Checagem11");
checadorCLASSE[playerid][12] = DOF2_GetBool(ClasseSystem, "Checagem12");
}
else
{
DOF2_CreateFile(ClasseSystem);
}
// Under "OnPlayerSpawn" to save the value in every spawn
// This TXD is to show the skill name, who is saved in DOF2 too
PlayerTextDrawShow(playerid, sobrevivente[playerid]);
new formated[250];
format(formated, sizeof(formated), "%s", DOF2_GetString(ClasseSystem, "RankName",);
PlayerTextDrawSetString(playerid, sobrevivente[playerid], formated);
if(CLASSEide == 1)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetBool(ClasseSystem, "Checagem1", checadorCLASSE[playerid][1]);
DOF2_SetString(ClasseSystem, "RankName", "Sobrevivente");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetBool(ClasseSystem, "Checagem1", checadorCLASSE[playerid][1]);
DOF2_SetString(ClasseSystem, "RankName", "Sobrevivente");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 2)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0xFAA6FFFF");
DOF2_SetBool(ClasseSystem, "Checagem2", checadorCLASSE[playerid][2]);
DOF2_SetString(ClasseSystem, "RankName", "Medico");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0xFAA6FFFF");
DOF2_SetBool(ClasseSystem, "Checagem2", checadorCLASSE[playerid][2]);
DOF2_SetString(ClasseSystem, "RankName", "Medico");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 3)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0x6DFF4CFF");
DOF2_SetBool(ClasseSystem, "Checagem3", checadorCLASSE[playerid][3]);
DOF2_SetString(ClasseSystem, "RankName", "Engenheiro");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0x6DFF4CFF");
DOF2_SetBool(ClasseSystem, "Checagem3", checadorCLASSE[playerid][3]);
DOF2_SetString(ClasseSystem, "RankName", "Engenheiro");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 4)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0x00EEACFF");
DOF2_SetBool(ClasseSystem, "Checagem4", checadorCLASSE[playerid][4]);
DOF2_SetString(ClasseSystem, "RankName", "Ladrao");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0x00EEACFF");
DOF2_SetBool(ClasseSystem, "Checagem4", checadorCLASSE[playerid][4]);
DOF2_SetString(ClasseSystem, "RankName", "Ladrao");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 5)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0xFF0000FF");
DOF2_SetBool(ClasseSystem, "Checagem5", checadorCLASSE[playerid][5]);
DOF2_SetString(ClasseSystem, "RankName", "Terrorista");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0xFF0000FF");
DOF2_SetBool(ClasseSystem, "Checagem5", checadorCLASSE[playerid][5]);
DOF2_SetString(ClasseSystem, "RankName", "Terrorista");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 6)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0x7263A5FF");
DOF2_SetBool(ClasseSystem, "Checagem6", checadorCLASSE[playerid][6]);
DOF2_SetString(ClasseSystem, "RankName", "Pistoleiro");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0x7263A5FF");
DOF2_SetBool(ClasseSystem, "Checagem6", checadorCLASSE[playerid][6]);
DOF2_SetString(ClasseSystem, "RankName", "Pistoleiro");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 7)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0xFFDB00FF");
DOF2_SetBool(ClasseSystem, "Checagem7", checadorCLASSE[playerid][7]);
DOF2_SetString(ClasseSystem, "RankName", "Mercenario");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0xFFDB00FF");
DOF2_SetBool(ClasseSystem, "Checagem7", checadorCLASSE[playerid][7]);
DOF2_SetString(ClasseSystem, "RankName", "Mercenario");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 8)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0x5FAAFFFF");
DOF2_SetBool(ClasseSystem, "Checagem8", checadorCLASSE[playerid][8]);
DOF2_SetString(ClasseSystem, "RankName", "Mecanico");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0x5FAAFFFF");
DOF2_SetBool(ClasseSystem, "Checagem8", checadorCLASSE[playerid][8]);
DOF2_SetString(ClasseSystem, "RankName", "Mecanico");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 9)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0xFF7400FF");
DOF2_SetBool(ClasseSystem, "Checagem9", checadorCLASSE[playerid][9]);
DOF2_SetString(ClasseSystem, "RankName", "Assassino");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0xFF7400FF");
DOF2_SetBool(ClasseSystem, "Checagem9", checadorCLASSE[playerid][9]);
DOF2_SetString(ClasseSystem, "RankName", "Assassino");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 10)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0x005A18FF");
DOF2_SetBool(ClasseSystem, "Checagem20", checadorCLASSE[playerid][20]);
DOF2_SetString(ClasseSystem, "RankName", "Militar");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0x005A18FF");
DOF2_SetBool(ClasseSystem, "Checagem10", checadorCLASSE[playerid][10]);
DOF2_SetString(ClasseSystem, "RankName", "Militar");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 11)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0x0034A3FF");
DOF2_SetBool(ClasseSystem, "Checagem11", checadorCLASSE[playerid][11]);
DOF2_SetString(ClasseSystem, "RankName", "Cacador");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0x0034A3FF");
DOF2_SetBool(ClasseSystem, "Checagem11", checadorCLASSE[playerid][11]);
DOF2_SetString(ClasseSystem, "RankName", "Cacador");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
if(CLASSEide == 12)
{
if(DOF2_FileExists(ClasseSystem))
{
DOF2_SetString(ClasseSystem, "NameColor", "0xA200FFFF");
DOF2_SetBool(ClasseSystem, "Checagem12", checadorCLASSE[playerid][12]);
DOF2_SetString(ClasseSystem, "RankName", "Lendario");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
else
{
DOF2_SetString(ClasseSystem, "NameColor", "0xA200FFFF");
DOF2_SetBool(ClasseSystem, "Checagem12", checadorCLASSE[playerid][12]);
DOF2_SetString(ClasseSystem, "RankName", "Lendario");
DOF2_SetInt(ClasseSystem, "ClassId", CLASSEide[playerid]);
DOF2_SaveFile();
}
}
Hello there,
I'd like to start with some suggestions: And the first would be to use SQL, whether SQLite [I recommend if you don't wish to use UCP and doesn't require any other plugins] or MySQL, because they are languages that are used not just in SA-MP but also in other places (such as web, apps etc.) More over, your code is not in English and I'll try my best to help you with what I could grasp. Make a chart (flow-chart) how you want something to function and then start writing a code. Furthermore, instead of checking what their class is and setting data manually - you can use arrays and loop. |
//Under OnPlayerConnect
new Archives[70], jogador[MAX_PLAYER_NAME];
GetPlayerName(playerid, jogador, sizeof(jogador));
format(Archives, sizeof(Archives), "Classes/%s.ini", jogador);
if(!fexist(Archives))
{
DOF2_CreateFile(Archives);
DOF2_SetInt(Archives, "ClasseID", 1);
}
else
{
CLASSEide[playerid] = DOF2_GetInt(Archives, "ClassID");
}
// Under OnPlayerDisconnect
new Archives[70], jogador[MAX_PLAYER_NAME];
GetPlayerName(playerid, jogador, sizeof(jogador));
format(Archives, sizeof(Archives), "Classes/%s.ini", jogador);
if(!fexist(Archives))
{
DOF2_CreateFile(Archives);
DOF2_SetInt(Archives, "ClasseID", CLASSEide[playerid]);
DOF2::SaveFile();
}
else
{
DOF2_SetInt(Archives, "ClassID", CLASSEide[playerid]);
DOF2_SaveFile();
}
return 1;