format(string, sizeof(string), "{FFFFFF}Clan: {FF0000}[%s] - {FFFFFF}Clan Rank: {FF0000}[%d]", ClanInfo[PlayerInfo[giveplayerid][user_clan]][ClanName]
format(ClanInfo[clanid][ClanName], 32, "%s", clanname);
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;
}
enum ClanData
{
ClanID,
ClanName[32],
ClanLeader[24],
ClanColor,
ColorSet,
ClanKills,
ClanDeaths,
ClanOfficial
};
new ClanInfo[MAX_CLANS][ClanData];
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.");
}
LoadClans();
for (new i = 0; i < MAX_CLANS; i ++)
{
SaveClan(i);
}
PlayerInfo[giveplayerid][user_clan]
Are you saving:
pawn Code:
|
#define MAX_CLAN_NAME_LEN (32)
forward LoadClans();
public LoadClans() {
new
query[45];
mysql_format(Database, query, sizeof query, "SELECT * FROM `clans` LIMIT %i", MAX_CLANS);
mysql_tquery(Database, query, "OnClansLoad");
return 1;
}
forward OnClansLoad();
public OnClansLoad() {
new
rows;
cache_get_row_count(rows);
if(!rows)
printf("[SERVER]: No clans were loaded from the MySQL Database.");
for(new i = 0; i != 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.", rows);
}
cache_get_field_content(i, "ClanName", ClanInfo[i][ClanName], Database, 130);
|
No idea why you're posting that, that's an old native from one of the old MySQL versions.
@Logic those are just comments that doesn't help, but he is actually looping through the rows, and your code is pretty much the same, except the fact that you created a variable that stores the count of rows. @willbedie All I can ask you to do is debug, as the loading/saving are both done correctly, check if the variables you're trying to access are those on which you loaded earlier the values, can you also check the mysql errors logs also? Because one column not created in the database could fuck the whole thing. |