source: eyal282 (
https://forums.alliedmods.net/showthread.php?p=2617618)
Code:
// native int UsefulCommands_ApproximateClientRank(int client);
// returns approximate rank.
// Note: if client has no service medals, returns exact rank.
// Note: if client has one medal, returns exact rank ONLY if it's equipped.
// Note: if client has more than one medal, does not return exact rank, however if you wanna filter out newbies, will work fine.
// Note: if you kick a client based on his rank, you should ask him to temporarily equip a service medal if he reset his rank recently, and you should cache that his steam ID is an acceptable rank.
// Note: don't use this on Counter-Strike: Source lol.
public int Native_ApproximateClientRank(Handle caller, int numParams)
{
int PlayerResourceEnt = GetPlayerResourceEntity();
int client = GetNativeCell(1);
if(!IsClientInGame(client))
{
ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %i", client);
return -1;
}
char sCoin[64], value, rank = GetEntProp(PlayerResourceEnt, Prop_Send, "m_nPersonaDataPublicLevel", _, client);
IntToString(GetEntProp(PlayerResourceEnt, Prop_Send, "m_nActiveCoinRank", _, client), sCoin, sizeof(sCoin));
if(rank == -1)
rank = 0;
if(GetTrieValue(Trie_CoinLevelValues, sCoin, value))
rank += value;
return rank;
}
The trie contains service medals' IDs I guess, just look at the original plugin
__________________