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



Faction ranks - Luis- - 04.07.2016

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.


Re: Faction ranks - SickAttack - 04.07.2016

And your problem is?


Re: Faction ranks - Luis- - 05.07.2016

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.


Re: Faction ranks - Mencent - 05.07.2016

Hello!

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


Re: Faction ranks - Napst34 - 05.07.2016

The code please ?
Use pastebin


Re: Faction ranks - Luis- - 05.07.2016

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);		
			
			loadedFactionRanks++;
		}
		printf("[FACTIONS] %d ranks have been loaded (%d MS).", loadedFactionRanks, cache_get_query_exec_time(UNIT_MILLISECONDS));
	}
	return 1;
}



Re: Faction ranks - Napst34 - 05.07.2016

I don't understand what you want to do?


Re: Faction ranks - Konstantinos - 05.07.2016

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.


Re: Faction ranks - Luis- - 05.07.2016

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);
	cache_delete(get_rank);
	return rank;
}



Re: Faction ranks - Napst34 - 05.07.2016

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