Faction ranks

My current problem is that I am making a faction system, I have a table for the faction data, like, name, bank accounts, location.. and I have a second table with all the rank information, like rank number, rank name, factionid... I have a rank field in my players data table, now what I'm wanting to do is set it up so the script can see what rank I am by using the player rank field and then looking for that rank in the faction ranks table, if that's possible.

And your problem is?

That I don't know how to check what rank a player currently is. I just can't seem to figure out what I should do, I've loaded both the server faction ranks & the current player rank.


Can you send us your currently code and explain what exactly do you want to do.

The code please ?
Use pastebin

Don't see how this code will help but here you go.
forward OnServerLoadFactionRanks(factionid);
public OnServerLoadFactionRanks(factionid) {
	new rows, fields;
	cache_get_data(rows, fields);
	if(rows > 0) {
		for(new i = 0; i < rows; i++) {
			RankInfor[loadedFactionRanks][rankID] = cache_get_row_int(i, 0);
			RankInfor[loadedFactionRanks][rankNumber] = cache_get_row_int(i, 1);
			cache_get_row(i, 2, RankInfor[loadedFactionRanks][rankName], connection, 32);		
		printf("[FACTIONS] %d ranks have been loaded (%d MS).", loadedFactionRanks, cache_get_query_exec_time(UNIT_MILLISECONDS));
	return 1;

I don't understand what you want to do?

Do you want to retrieve the name of the rank according to player's rank number and their faction with a query? If so, can you post the structure of those tables?

And from what I see from the code above, you load each rank data separately when you can do that with just one query.

Hmm. I've just tried something, but it doesn't work. Presuming somethings wrong;
GetPlayerFactionRank(playerid) {
	new query[144], Cache: get_rank, rank[32];
	format(query, sizeof query, "SELECT rankname FROM server_faction_names WHERE factionid = %d AND rank = %d", PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pFactionRank]);
	get_rank = mysql_query(connection, query);
	printf("%s", query);
	cache_get_field_content(0, "rankname", "rank", connection, sizeof rank);
	return rank;

Use the GetPlayerFactionRank on a command to see if it works.

Forum Jump:

Users browsing this thread: 1 Guest(s)