CMD:makeleader(playerid, params[]) { if(PlayerInfo[playerid][AdminLevel] >= 1337) { new targetid, facid; if(sscanf(params,"ui",targetid, facid)) return SendClientMessage(playerid, COLOR_ADM,"** Usage: /makeleader [Target ID][Faction ID]");//if the command is misused it will tell them the correct way to use it if(targetid != INVALID_PLAYER_ID) { PlayerInfo[targetid][Faction] = facid; PlayerInfo[targetid][Facrank] = 10; PlayerInfo[targetid][Facleader] = facid; if(facid == 1) { SendClientMessage(targetid,COLOR_LIGHTBLUE,"You have been made the leader of the {F18100}Palomino Creek Police Department!"); } if(facid == 2) { SendClientMessage(targetid,COLOR_LIGHTBLUE,"You have been made the leader of the {00B4F0}Federal Bureau of Investigations!"); } if(facid == 3) { SendClientMessage(targetid,COLOR_LIGHTBLUE,"You have been made the leader of the {FF9494}Palomino Creek Fire/Medical Department!"); } if(facid == 4) { SendClientMessage(targetid,COLOR_LIGHTBLUE,"You have been made the leader of the {A0A0A0}Palomino Creek Goverment!"); } if(facid == 5) { SendClientMessage(targetid,COLOR_LIGHTBLUE,"You have been made the leader of the {00EB33}Palomino Creek News Agency!"); } if(facid == 6) { SendClientMessage(targetid,COLOR_LIGHTBLUE,"You have been made the leader of the {FFFFFF}Hitman Agency!"); } } } else { SendClientMessage(playerid, COLOR_ADM, "* [AdmCMD]: Only administrators level 1337 and higher are able to use this command."); } return 1; }
CMD:stats(playerid, params[]) { new money = PlayerInfo[playerid][Money]; new deaths = PlayerInfo[playerid][Deaths]; new kills = PlayerInfo[playerid][Kills]; new score = PlayerInfo[playerid][Score]; new admin = PlayerInfo[playerid][AdminLevel]; new fac = PlayerInfo[playerid][Faction]; new facrank = PlayerInfo[playerid][Facrank]; new facleader = PlayerInfo[playerid][Facleader]; new coca = PlayerInfo[playerid][Cocaine]; new name[MAX_PLAYER_NAME], string2[64+MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(string2, sizeof(string2), "* Showing statistics for [%s's] account *", name); SendClientMessage(playerid, COLOR_ADM, string2); new string[128]; format(string, sizeof(string), "[General] - [Money: %d] | [Deaths: %d] | [Kills: %d] | [Score: %d] | [Admin Level: %d]", money, deaths, kills, score, admin); SendClientMessage(playerid, COLOR_ORANGE, string); new string1[128]; format(string1, sizeof(string1), "[Faction/Family] - [Faction: %d] | [Faction Rank: %d] | [Faction Leader: %d]", fac, facrank, facleader); SendClientMessage(playerid, COLOR_GOLD, string1); new string3[64]; format(string3, sizeof(string3), "[Narcotics] - [Cocaine: %d]", coca); SendClientMessage(playerid, COLOR_ORANGE, string3); return 1; }
new string[128],factionname[24];
//using switch to assign the faction name to the string (more efficient than if/else statements)
switch(PlayerInfo[playerid][Faction])
{
case 0: { factionname = "None"; }
case 1: { factionname = "Faction A; }
case 2: { factionname = "Faction B; }
//etc.
}
format(string,sizeof(string),"Faction: %s",factionname);
SendClientMessage(playerid,-1,string);
To make it show a faction's name instead of the id, create a string variable in the /stats command and check what faction id the player is in and assign the name of the faction to the string variable based on the faction id of the player
pawn Код:
|
It'd be hard to come up with an example, but basically what you'll need is to create a database (I'm not sure what you use to save/load stats whether it be y_ini, MySQL, or anything like that) that keeps track of the members of each faction and what their rank is. Then you'd simply make the command and order the faction members from highest to lowest rank.
|