SA-MP Forums Archive
MySQL Reading / Saving Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Reading / Saving Problem (/showthread.php?tid=629866)



MySQL Reading / Saving Problem - SkyFlare - 05.03.2017

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?


Re: MySQL Reading / Saving Problem - JessThompson - 05.03.2017

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);


Re: MySQL Reading / Saving Problem - SkyFlare - 05.03.2017

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


Re: MySQL Reading / Saving Problem - JessThompson - 05.03.2017

No problemo :P