15.04.2018, 22:43
yeah but it's big function, better to search in forums by keyword 'sorting'
you must change the value in command:makeleader
you must change the value in command:makeleader
PHP код:
CMD:makeleader(playerid, params[])
{
new targetid, factionid, string[128], targetname[24], playername[24];
if(sscanf(params, "ui", targetid, factionid)) return SendClientMessage(playerid, -1, "Usage: /makeleader [playerid][factionid]"); //Checks if they typed in anything for the playerid and factionid parameters, and if they don't, return a client message.
if(pInfo[playerid][pAdminLevel] < 5) return SendClientMessage(playerid, -1, "You are not an admin"); //Checks if they are an admin. Remember, change this to your admin variable, or use !IsPlayerAdmin to check if they aren't rcon admin.
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Invalid playerid!"); //Sends a message if the player is not connected
if(0 < factionid < 3) //Checks if the factionid is between 0 and 3, and if so, continue. You can also type this like so: if(factionid >= 1 && factionid <= 2) or if(factionid == 1 || factionid == 2)
{
GetPlayerName(playerid, playername, sizeof(playername)); //Gets the players name and saves it to the variable playername
GetPlayerName(targetid, targetname, sizeof(targetname)); //Gets the targets name and saves it to the variable targetname
format(string, sizeof(string), "You made %s leader of faction id %i!", targetname, factionid); //Formats the string that you will receive
SendClientMessage(playerid, -1, string); //Sends a message to the person who changes the other persons faction in a random color
format(string, sizeof(string), "You were made leader of faction id %i by %s", factionid, playername);//Formats the string that the player will receive
SendClientMessage(playerid, -1, string); //Sends a message to the person who is made the faction leader
pInfo[targetid][pFaction] = factionid;
if(factionid == 1) pInfo[targetid][pRank] = 15; // for lspd
else if(factionid == 2) pInfo[targetid][pRank] = 17; // for hospital
else pInfo[targetid][pRank] = 6; // for default/other factions.
//Leader, use a switch case or if/else if statement if you want to make it so certain factions have seperate highest ranks
}
else return SendClientMessage(playerid, -1, "Invalid factionid. Factionid's: 1-2"); //Sends a message if the faction is NOT between 0 and 3
return 1;// Returns 1 to end the command, as we NEED to return a value.
}