Who can help me with this ?
#2

Here's an example, I made this a second ago for you. It has not been tested, only compiled -- so it is bound to have bugs. Please beware that this isn't the most efficient way to do it, and that you need a register system for this. I highly recommend you to revise this yourself, because I am very tired and didn't bother making it advanced.

I left out the /fmute because I didn't really know what you wanted it to do, anyway, here it is:

Commands:

/createfaction - creates a faction but only if you have 20m
/deletefaction - deletes a faction if you own one
/finvite - invites someone to your faction (auto invite)
/fkick - kicks someone from your faction (auto kick)
/fchat - faction chat

pawn Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>

enum PlayerInfo
{
    FactionOwner[20],
    FactionMember[20],
    FactionRank[15],
    bool: FactionOwned,
    bool: FactionMemb,
}

new pInfo[MAX_PLAYERS][PlayerInfo];

CMD:createfaction(playerid, params[])
{
    new fname[20];
   
    if(sscanf(params, "s[20]", fname)) return SendClientMessage(playerid, -1, "/createfaction [name]");
    if(strlen(fname) > 20 || strlen(fname) < 1) return SendClientMessage(playerid, -1, "You can't have less than 1 letter, or more than 20!");
    if(GetPlayerMoney(playerid) < 20000000) return SendClientMessage(playerid, -1, "You need atleast $20,000,000 in order to make a faction!");

    CreateFaction(playerid, fname);
    pInfo[playerid][FactionOwned] = true;

    pInfo[playerid][FactionOwner] = fname;
    pInfo[playerid][FactionMember] = fname;

    SendClientMessage(playerid, -1, "You have purchased a faction!");

    return true;
}

CMD:deletefaction(playerid, params[])
{
    new path[40];

    if(!pInfo[playerid][FactionOwned]) return SendClientMessage(playerid, -1, "You don't own a faction!");

    format(path, sizeof(path), "Factions/%s.ini", pInfo[playerid][FactionOwner]);
    fremove(path);

    pInfo[playerid][FactionOwner] = EOS;
    pInfo[playerid][FactionRank] = EOS;
    pInfo[playerid][FactionOwned] = false;

    SendClientMessage(playerid, -1, "You have deleted your faction!");

    return true;
}

CMD:finvite(playerid, params[])
{
    new target, string[50];

    if(!pInfo[playerid][FactionOwned]) return SendClientMessage(playerid, -1, "You don't own a faction!");
    if(sscanf(params, "u", target)) return SendClientMessage(playerid, -1, "/finvite [id/name]");

    format(string, sizeof(string), "You have been invited to join the %s!", pInfo[playerid][FactionOwner]);
    SendClientMessage(playerid, -1, string);

    SendClientMessage(playerid, -1, "You have successfully invited a player to your faction!");

    pInfo[target][FactionMember] = pInfo[playerid][FactionOwner];
    pInfo[target][FactionMemb] = true;

    return true;
}

CMD:fkick(playerid, params[])
{
    new target, string[50];
   
    if(!pInfo[playerid][FactionOwned]) return SendClientMessage(playerid, -1, "You don't own a faction!");
    if(sscanf(params, "u", target)) return SendClientMessage(playerid, -1, "/fkick [id/name]");

    format(string, sizeof(string), "You have been uninvited from the %s!", pInfo[playerid][FactionOwner]);
    SendClientMessage(playerid, -1, string);

    SendClientMessage(playerid, -1, "You have successfully uninvited a player from your faction!");

    pInfo[target][FactionMember] = EOS;
    pInfo[target][FactionMemb] = false;

    return true;
}

CMD:fchat(playerid, params[])
{
    new text[80], string[110], pname[MAX_PLAYER_NAME];
   
    if(!pInfo[playerid][FactionMemb]) return SendClientMessage(playerid, -1, "You're not part of a faction!");
    if(sscanf(params, "s[80]", text)) return SendClientMessage(playerid, -1, "/fchat [text]");
    if(strlen(text) > 80 || strlen(text) < 1) return SendClientMessage(playerid, -1, "You can't have less than 1 letter, or more than 80!");

    format(string, sizeof(string), "%s: %s", pname, text);
    SendFactionMessage(playerid, string);

    return true;
}

stock CreateFaction(playerid, name[])
{
    new holder[45], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
   
    format(holder, sizeof(holder), "Factions/%s.ini", name);
    new File:loc = fopen(holder, io_write);

    if(loc)
    {
        format(holder, sizeof(holder), "Faction: %s | Owner: %s", name, pname);
        fwrite(loc, holder);
        fclose(loc);
    }
   
    return true;
}

stock SendFactionMessage(playerid, text[])
{
    for(new i; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
            if(pInfo[playerid][FactionMember] == pInfo[i][FactionMember])
            {
                SendClientMessage(i, -1, text);
            }
        }
    }

    return true;
}
Reply


Messages In This Thread
Who can help me with this ? - by killing - 23.06.2014, 04:10
Re: Who can help me with this ? - by Dignity - 23.06.2014, 04:39
Re: Who can help me with this ? - by killing - 23.06.2014, 05:04
Re: Who can help me with this ? - by killing - 23.06.2014, 05:06
Re: Who can help me with this ? - by Dignity - 23.06.2014, 06:06
Re: Who can help me with this ? - by killing - 23.06.2014, 08:29
Re: Who can help me with this ? - by Dignity - 23.06.2014, 08:30
Re: Who can help me with this ? - by killing - 23.06.2014, 08:31
Re: Who can help me with this ? - by DaniceMcHarley - 23.06.2014, 08:34
Re: Who can help me with this ? - by Dignity - 23.06.2014, 08:34

Forum Jump:


Users browsing this thread: 1 Guest(s)