stock LoadClans()
{
mysql_tquery(sql, "SELECT * FROM `clans`", "tLoadClans");
return 1;
}
forward tLoadClans();
public tLoadClans()
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
for(new i = 0; i < rows; i++)
{
ClanDB[i][ClanID] = cache_get_field_content_int(0, "clanid");
cache_get_field_content(0, "clan_name", ClanDB[i][ClanName]);
ClanDB[i][ClanLevel] = cache_get_field_content_int(0, "clan_level");
ClanDB[i][ClanEXP] = cache_get_field_content_int(0, "clan_exp");
ClanDB[i][ClanMaxEXP] = cache_get_field_content_int(0, "clan_max_exp");
ClanDB[i][ClanColor] = cache_get_field_content_int(0, "clan_color");
new str[32];
format(str, sizeof(str), "ca %d", ClanDB[i][ClanMaxEXP]);
printf(str);
}
}
}
ca 0
ca 0
forward tLoadClans();
public tLoadClans()
{
new rows, fields, str[128];
cache_get_data(rows, fields);
if(rows)
{
for(new i = 0; i < rows; i++)
{
ClanDB[i][ClanID] = cache_get_field_content_int(i, "clanid");
cache_get_field_content(i, "clan_name", ClanDB[i][ClanName]);
ClanDB[i][ClanLevel] = cache_get_field_content_int(i, "clan_level");
ClanDB[i][ClanEXP] = cache_get_field_content_int(i, "clan_exp");
ClanDB[i][ClanMaxEXP] = cache_get_field_content_int(i, "clan_max_exp");
ClanDB[i][ClanColor] = cache_get_field_content_int(i, "clan_color");
format(str, sizeof(str), "[%d] clanid: %d, exp: %d, max exp: %d",i, ClanDB[i][ClanID], ClanDB[i][ClanEXP], ClanDB[i][ClanMaxEXP]);
printf(str);
}
}
}
[0] clanid: 1, exp: 0, max exp: 0
[1] clanid: 7, exp 0, max exp: 300
You have data, you know how it looks like,
think logically how you can solve the problem, you're a scripter |
ClanDB[i][ClanID] = cache_get_field_content_int(ClanDB[i][ClanID], "clanid");
cache_get_field_content(ClanDB[i][ClanID], "clan_name", ClanDB[i][ClanName]);
ClanDB[i][ClanLevel] = cache_get_field_content_int(ClanDB[i][ClanID], "clan_level");
ClanDB[i][ClanEXP] = cache_get_field_content_int(ClanDB[i][ClanID], "clan_exp");
ClanDB[i][ClanMaxEXP] = cache_get_field_content_int(ClanDB[i][ClanID], "clan_max_exp");
ClanDB[i][ClanColor] = cache_get_field_content_int(ClanDB[i][ClanID], "clan_color");
format(str, sizeof(str), "[%d] clanid: %d, exp: %d, max exp: %d",i, ClanDB[i][ClanID], ClanDB[i][ClanEXP], ClanDB[i][ClanMaxEXP]);
printf(str);
[0] clanid: 1, exp: 0, max exp: 300
[1] clanid: 1, exp: 0, max exp: 300
ClanDB[i][ClanID] = cache_get_field_content_int(i, "clanid");
cache_get_field_content(i, "clan_name", ClanDB[ClanDB[i][ClanID]][ClanName]);
ClanDB[ClanDB[i][ClanID]][ClanLevel] = cache_get_field_content_int(i, "clan_level");
ClanDB[ClanDB[i][ClanID]][ClanEXP] = cache_get_field_content_int(i, "clan_exp");
ClanDB[ClanDB[i][ClanID]][ClanMaxEXP] = cache_get_field_content_int(i, "clan_max_exp");
ClanDB[ClanDB[i][ClanID]][ClanColor] = cache_get_field_content_int(i, "clan_color");
format(str, sizeof(str), "[%d] clanid: %d, exp: %d, max exp: %d",i, ClanDB[i][ClanID], ClanDB[i][ClanEXP], ClanDB[i][ClanMaxEXP]);
printf(str);
[0] clanid: 1, exp: 0, max exp: 0
[1] clanid: 7, exp: 0, max exp: 0
new fixer[][];
for(new i=0;i<rows;i++) {fixer=mysql}
for(new i=0;i<rows;i++) {
ClanDB[fixer[i][ClanID]][name]=fixer[i][name];
}
How about simple solution such as temporary holder ?
create a new array with roughly the same size as ClanDB, insert data into it and then create another loop where you switch data between them like so pawn Code:
|