03.04.2019, 23:24
Hey, so I have been dealing with this issue for a pretty long time.
So basically, after restarting the server, infos do save in the MySQL Database but not on the enumerator. Here's an example:
My /stats looks like this before restarting:
And here's how it looks after restarting:
^^ I call this when the clan gets created.
Here's how I save my data:
And the enumerator:
Loading clans:
Under OnGameModeInit:
OnGameModeExit
Still can't seem to fix it, some help would be really appreciated!
So basically, after restarting the server, infos do save in the MySQL Database but not on the enumerator. Here's an example:
My /stats looks like this before restarting:
And here's how it looks after restarting:
pawn Code:
format(string, sizeof(string), "{FFFFFF}Clan: {FF0000}[%s] - {FFFFFF}Clan Rank: {FF0000}[%d]", ClanInfo[PlayerInfo[giveplayerid][user_clan]][ClanName]
pawn Code:
format(ClanInfo[clanid][ClanName], 32, "%s", clanname);
Here's how I save my data:
pawn Code:
SaveClan(clanid)
{
new query[200];
mysql_format(Database, query, sizeof(query), "UPDATE `clans` SET `ClanName` = '%e', `ClanLeader` = '%e', `ClanColor` = '%i', `ColorSet` = '%i', `ClanKills` = '%i', `ClanDeaths` = '%i', `ClanOfficial` = '%i' WHERE `ClanID` = '%i'",
ClanInfo[clanid][ClanName], ClanInfo[clanid][ClanLeader], ClanInfo[clanid][ClanColor], ClanInfo[clanid][ColorSet], ClanInfo[clanid][ClanKills], ClanInfo[clanid][ClanDeaths], ClanInfo[clanid][ClanOfficial], clanid);
mysql_query(Database, query);
return 1;
}
pawn Code:
enum ClanData
{
ClanID,
ClanName[32],
ClanLeader[24],
ClanColor,
ColorSet,
ClanKills,
ClanDeaths,
ClanOfficial
};
new ClanInfo[MAX_CLANS][ClanData];
pawn Code:
forward LoadClans();
public LoadClans()
{
new query[150];
mysql_format(Database, query, sizeof(query), "SELECT * FROM `clans`");
mysql_tquery(Database, query, "OnClansLoad");
return 1;
}
forward OnClansLoad();
public OnClansLoad()
{
if(cache_num_rows())
{
for(new i = 0; i < cache_num_rows(); i ++)
{
cache_get_value_name_int(i, "ClanID", ClanInfo[i][ClanID]);
cache_get_value_name(i, "ClanName", ClanInfo[i][ClanName]);
cache_get_value_name(i, "ClanLeader", ClanInfo[i][ClanLeader]);
cache_get_value_name_int(i, "ClanColor", ClanInfo[i][ClanColor]);
cache_get_value_name_int(i, "ColorSet", ClanInfo[i][ColorSet]);
cache_get_value_name_int(i, "ClanKills", ClanInfo[i][ClanKills]);
cache_get_value_name_int(i, "ClanDeaths", ClanInfo[i][ClanDeaths]);
cache_get_value_name_int(i, "ClanOfficial", ClanInfo[i][ClanOfficial]);
}
printf("[SERVER]: %d clans were loaded from the MySQL Database.", cache_num_rows());
}
else printf("[SERVER]: No clans were loaded from the MySQL Database.");
}
pawn Code:
LoadClans();
pawn Code:
for (new i = 0; i < MAX_CLANS; i ++)
{
SaveClan(i);
}