SA-MP Forums Archive
GetLeaderFaction - 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: GetLeaderFaction (/showthread.php?tid=587157)



GetLeaderFaction - norton2 - 28.08.2015

How to create stock "GetLeaderFaction" and extracted from my MySQL database name of the player who is leader the faction?
Exemple:
Код HTML:
new string[64];
format(string, sizeof(string), "The Ballas - Leader: %s", GetLeaderFaction(5)); //5 = Faction ID
SendClientMessage(playerid, -1, string);



Re: GetLeaderFaction - Logofero - 28.08.2015

Start up.

Learn:
https://sampwiki.blast.hk/wiki/MySQL
https://sampforum.blast.hk/showthread.php?tid=56564


Re: GetLeaderFaction - Evocator - 28.08.2015

Sadly to return the string, you cant thread the query. So;
Код:
GetFactionLeader(id)
{
	mysql_format(g_SQL, Query, sizeof (Query), "SELECT `Nick` FROM `Factions` WHERE `id` = '%i'", id);

	new 
		name[MAX_PLAYER_NAME + 1],
		Cache:result = mysql_query(g_SQL, Query)
	;

    if (cache_num_rows()) {
	   	cache_get_field_content(0, "Nick", name);
	}
	else 
	{
		format(name, sizeof (name), "None");
	}

	cache_delete(result);
	return name;
}



Re: GetLeaderFaction - norton2 - 28.08.2015

Ralfie, thank you very much!!! +REP.


Re: GetLeaderFaction - Logofero - 28.08.2015

Quote:
Originally Posted by norton2
Посмотреть сообщение
Ralfie, thank you very much!!! +REP.
and we do not want to learn