How would I do this?
#7

pawn Код:
CMD:setleader(playerid, params[])
{
    if(GetAdminLevel(playerid) >= 2)
    {
        new ID,orgid;
        if (sscanf(params, "ud", ID,orgid)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setleader [playerid] [orgid]");
        if (!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, "That player is not connected");
        if (PlayerOrg[ID] != INVALID_ORG_ID) return SendClientMessage(playerid, COLOR_RED,"That player already belongs to an organization");
        if (orgid < 1 || orgid > OrgsCount) return SendClientMessage(playerid, COLOR_RED,"Invalid org. ID!");
        new string[140];
        format(string,sizeof(string),"Admin %s has made you leader of the faction %s!", PlayerName(playerid), GetOrgName(orgid));
        SendClientMessage(ID, COLOR_YELLOW, string);
        format(string,sizeof(string),"You have set %s the leader of %s", PlayerName(ID), GetOrgName(orgid));
        SendClientMessage(playerid, COLOR_YELLOW, string);
        PlayerOrg[ID] = orgid;
        PlayerLeader[ID] = 1;
        Organization[orgid][Leader] = PlayerName(ID);
        SaveLeaders();
        SavePlayerOrgInfo(ID);
        GiveOrgFeatures(ID);
    }
    return 1;
}
Add
pawn Код:
#define INVALID_ORG_ID 3425
You can change 3425 to a number that you will NEVER use for orgids.

Also OnPlayerDisconnect add this:
pawn Код:
PlayerOrg[playerid] = INVALID_ORG_ID;

If you get errors/warnings please post them with the lines.
Reply


Messages In This Thread
How would I do this? - by HenrySunseri - 24.07.2014, 16:54
Re: How would I do this? - by LivingLikeYouDo - 24.07.2014, 17:00
Re: How would I do this? - by HenrySunseri - 24.07.2014, 17:02
Re: How would I do this? - by LivingLikeYouDo - 24.07.2014, 17:30
Re: How would I do this? - by Stinged - 24.07.2014, 18:27
Re: How would I do this? - by HenrySunseri - 24.07.2014, 21:50
Re: How would I do this? - by Stinged - 24.07.2014, 21:56
Re: How would I do this? - by Threshold - 24.07.2014, 22:54
Re: How would I do this? - by Stinged - 24.07.2014, 23:04

Forum Jump:


Users browsing this thread: 1 Guest(s)