MySQL Reading / Saving Problem
#1

So my Faction System has been having problems displaying the Faction Name.
but not initially.

When I create the faction eg: LSPD.
It will show correctly in /f(actionchat, /stats & /factionlist
but after the server gets turned off & retarted it is not reading or displaying correctly.
its just empty.
like this "Faction: | Rank: Cadet"
it should be "Faction: LSPD | Rank: Cadet"

OnGameModeInit
Code:
mysql_tquery(g_SQL, "SELECT * FROM `factions` ORDER BY `id` ASC", "FactionLoad", "");
mysql_tquery(g_SQL, "SELECT * FROM `factionranks` ORDER BY `id` ASC", "LoadFactionRanks", "");
Code:
public FactionLoad()
{
	new rows = cache_num_rows();

	for(new i = 0; i < rows && i < MAX_FACTIONS; i ++)
    {
        new factionid;
        cache_get_value_name_int(i, "id", factionid);
        cache_get_value_name(i, "name", FactionInfo[factionid][Name]);
        cache_get_value_name_int(i, "rank", FactionInfo[factionid][Rank]);
    }
}
Stats Displaying Faction & Rank.
Code:
format(string, sizeof(string), "{00A5FF}** Faction: %s | Rank: %s", FactionInfo[Player[i][Faction]][Name], FactionRanks[Player[i][Faction]][Player[i][FactionRank]]);
	SendClientMessage(i, COLOR_LIGHTBLUE, string);
Anyone know whats wrong here?
Reply
#2

You must provide a length on the loading,

https://sampwiki.blast.hk/wiki/MySQL/R40...get_value_name (Read the red box)

so

cache_get_value_name(i, "name", FactionInfo[factionid][Name], 30);
cache_get_value_name(i, "leader", FactionInfo[factionid][Leader], 30);
Reply
#3

Ohh, how simple XD thank you very much, fixed it perfectly.
Reply
#4

No problemo :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)