Who can help me with this ?
#1

I want a faction system /createfaction when we do this it says you must have atleast 20m to start your faction. /deletefaction /finvite /fmute /fkick pls i need this this type of fs is not there
Reply
#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
#3

Thanks alot its working great ))
Can i get this purchse weapons for faction ? and instead of typing /fchat we use = [txt] ?
Reply
#4

Can you change the color of faction chat ? and when someone chat in faction so it shows Faction Chat : before players text ? If you can i would be very thank full to you
Reply
#5

What color do you want?
Reply
#6

i want yellow color
Reply
#7

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[130], 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), "Faction Chat: %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, 0xFFEA00FF, text);
            }
        }
    }

    return true;
}
Reply
#8

bro i do /createfaction and then invite my self to faction when i disconnect from server and re join i am not in clan why ?
Reply
#9

Because you're not saving it at all try reading some tutorials about the saving systems (y_ini or w/e).
Reply
#10

Quote:
Originally Posted by killing
Посмотреть сообщение
bro i do /createfaction and then invite my self to faction when i disconnect from server and re join i am not in clan why ?
Quote:
Originally Posted by Mionee
you need a register system for this.
You need to save the variables.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)