[Ajuda] Sistema Clan
#1

Por Favor Alguem min ajuda ? , eo seeguinte, Eu crio um clan quando relogo o clan Some , :/ Ta Aew O Comando ..

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

#define MAX_GROUPS 100

enum ginfo
{
    grname[75],
    leader,
    active
};

enum pginfo
{
    gid,
    order,
    invited,
    attemptjoin
};

new group[MAX_PLAYERS][pginfo];
new groupinfo[MAX_GROUPS][ginfo];

public OnFilterScriptInit()
{
    for(new x; x<MAX_PLAYERS; x++)
    {
        group[x][gid] = -1;
        group[x][order] = -1;
        group[x][invited] = -1;
        group[x][attemptjoin] = -1;
    }
    print("  Clan  ");
    return 1;
}

public OnPlayerConnect(playerid)
{
    group[playerid][gid] = -1;
    group[playerid][invited] = -1;
    group[playerid][attemptjoin] = -1;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    LeaveGroup(playerid, 2);
    return 1;
}

COMMAND:criarclan(playerid, params[])
{
    if(group[playerid][gid] != -1) return SendClientMessage(playerid, 0xFF0000, "Deixe o seu Clгn com {FFFFFF}/sairclan{FF0000} Antes de criar um Novo!");
    if(strlen(params) > 49 || strlen(params) < 3) return SendClientMessage(playerid, 0xFF0000, "Use: {FFFFFF}/criarclan{FF0000} (Nome do Clгn 3-50 Letras)!");
    if(IsGroupTaken(params)) return SendClientMessage(playerid, 0xFF0000, "Nome do grupo jб estб em uso!");
    CreateGroup(params, playerid);
    return 1;
}

COMMAND:sairclan(playerid, params[])
{
    if(group[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "Vocк nгo estб em um grupo para deixar um!");
    LeaveGroup(playerid, 0);
    return 1;
}

COMMAND:ajudaclan(playerid, params[])
{
    SendClientMessage(playerid, 0x9400D3, "<===Ajuda Clan===>");
    SendClientMessage(playerid, 0xFF0000, "/criarclan (criar um clгn)");
    SendClientMessage(playerid, 0xFF0000, "/clanconvidar (convidar alguem pro clan)");
    SendClientMessage(playerid, 0xFF0000, "/passarlider (passar tua lideranзa para alguem)");
    SendClientMessage(playerid, 0xFF0000, "/aceitarclan (aceitar algum clгn- ou pedir para entrar)");
    SendClientMessage(playerid, 0xFF0000, "/expulsar (expulsar alguem do clan)");
    SendClientMessage(playerid, 0xFF0000, "/ms (chat do clгn)");
    SendClientMessage(playerid, 0xFF0000, "/clanlist (ver membros de um determinado clгn)");
    SendClientMessage(playerid, 0xFF0000, "/clans (ver clгns criados eo ID)");
    SendClientMessage(playerid, 0xFF0000, "/clanconvidar (convidar alguem pro clan)");
    return 1;
}

COMMAND:clanconvidar(playerid, params[])
{
    if(group[playerid][order] != 1) return SendClientMessage(playerid, 0xFF0000, "Vocк nгo й o lнder do clan, vocк nгo pode convidar pessoas!");
    new cid;
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/convidarclan{FF0000} (player ID)");
    cid = strval(params);
    if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "O jogador nгo estб Online!");
    if(group[cid][gid] == group[playerid][gid]) return SendClientMessage(playerid, 0xFF0000, "Jogador jб estб em seu clгn!");
    if(group[cid][invited] == group[playerid][gid]) return SendClientMessage(playerid, 0xFF0000, "Jogador jб foi convidado para o seu clгn!");
    if(group[cid][attemptjoin] == group[playerid][gid]) return GroupJoin(cid, group[playerid][gid]);
    group[cid][invited] = group[playerid][gid];
    new string[125], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(string, sizeof(string), "Vocк foi convidado para se juntar ao Clгn {FFFFFF}%s(%d){FFCC66} de {FFFFFF}%s(%d). /aceitarclan %d", groupinfo[group[playerid][gid]][grname], group[playerid][gid], pname, playerid, group[playerid][gid]);
    SendClientMessage(cid, 0xFFCC66, string);
    GetPlayerName(cid, pname, 24);
    format(string, sizeof(string), "Vocк convidou {FFFFFF}%s(%d){FFCC66} para participar do seu Clгn!", pname, cid);
    SendClientMessage(playerid, 0xFFCC66, string);
    return 1;
}

COMMAND:passarlider(playerid, params[])
{
    if(group[playerid][order] != 1) return SendClientMessage(playerid, 0xFF0000, "Vocк nгo й o lнder do clгn, vocк nгo pode mudar o lнder!");
    new cid;
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Use: {FFFFFF}/passarlider{FF0000} (player ID)");
    cid = strval(params);
    if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "O jogador nгo estб conectado!");
    if(cid == playerid)  return SendClientMessage(playerid, 0xFF0000, "Vocк jб й lнder do clгn, bobo.");
    if(group[playerid][gid] != group[cid][gid]) return SendClientMessage(playerid, 0xFF0000, "O jogador nгo estб em seu clan!");
    ChangeMemberOrder(group[playerid][gid], 1);
    group[playerid][order] = GroupMembers(group[playerid][gid]);
    return 1;
}

COMMAND:aceitarclan(playerid, params[])
{
    if(group[playerid][gid] != -1) return SendClientMessage(playerid, 0xFF0000, "Vocк jб estб em um clan! Deixe o seu atual antes de se juntar a um outro!");
    new grid;
    if( (isnull(params) && group[playerid][invited] != -1 ) || ( strval(params) == group[playerid][invited] && group[playerid][invited] != -1) ) return GroupJoin(playerid, group[playerid][invited]);
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Use para aceitar ou participar: {FFFFFF}/aceitarclan{FF0000} (clan ID)");
    grid = strval(params);
    if(!groupinfo[grid][active]) return SendClientMessage(playerid, 0xFF0000, "O clan que vocк tentou Participar nгo existe!");
    group[playerid][attemptjoin] = grid;
    new string[125], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(string, sizeof(string), "Vocк pediu para entrar no clгn%s(ID:%d)", groupinfo[grid][grname], grid);
    SendClientMessage(playerid, 0xFFCC66, string);
    format(string, sizeof(string), "{FFFFFF}%s(%d) {FFCC66}pediu para participar do seu clгn. Use /aceitarclan %d para aceitar", pname, playerid, playerid);
    SendMessageToLeader(grid, string);
    return 1;
}

COMMAND:expulsar(playerid, params[])
{
    if(group[playerid][order] != 1) return SendClientMessage(playerid, 0xFF0000, "Vocк nгo й o lнder de um clгn, vocк nгo pode expulsar!");
    new cid;
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/expulsar{FF0000} (player ID)");
    cid = strval(params);
    if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, 0xFF0000, "O jogador nгo estб conectado!");
    if(cid == playerid)  return SendClientMessage(playerid, 0xFF0000, "Vocк nгo pode expulsar a si mesmo, idiota.");
    if(group[playerid][gid] != group[cid][gid]) return SendClientMessage(playerid, 0xFF0000, "O jogador nгo estб em seu clгn!");
    LeaveGroup(cid, 1);
    return 1;
}

COMMAND:clanmensagem(playerid, params[])
{
    if(group[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "Vocк nгo estб em um clan, nгo pode mandar mensagem!");
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000, "Usage: {FFFFFF}/ms{FF0000} (mesagem)");
    new pname[24], string[140+24];
    GetPlayerName(playerid, pname, 24);
    format(string, sizeof(string), "%s(%d): %s", pname, playerid, params);
    SendMessageToAllGroupMembers(group[playerid][gid], string);
    return 1;
}


COMMAND:clanlist(playerid, params[])
{
    if(isnull(params) && group[playerid][gid] == -1) return SendClientMessage(playerid, 0xFF0000, "Use: {FFFFFF}/clanlist{FF0000} (CLГN ID)");
    if(isnull(params))
    {
        DisplayGroupMembers(group[playerid][gid], playerid);
        return 1;
    }
    new grid = strval(params);
    if(!groupinfo[grid][active]) return SendClientMessage(playerid, 0xFF0000, "O ID do clan que vocк digitou nгo estб ativo!");
    DisplayGroupMembers(grid, playerid);
    return 1;
}

COMMAND:clans(playerid, params[])
{
    ListGroups(playerid);
    return 1;
}

COMMAND:src(playerid, params[])
    return cmd_sairclan(playerid, params);
   
COMMAND:aclan(playerid, params[])
    return cmd_ajudaclan(playerid, params);

COMMAND:crc(playerid, params[])
    return cmd_criarclan(playerid, params);

COMMAND:cvc(playerid, params[])
    return cmd_clanconvidar(playerid, params);

COMMAND:plider(playerid, params[])
    return cmd_passarlider(playerid, params);

COMMAND:acc(playerid, params[])
    return cmd_aceitarclan(playerid, params);

COMMAND:exp(playerid, params[])
    return cmd_expulsar(playerid, params);

COMMAND:ms(playerid, params[])
    return cmd_clanmensagem(playerid, params);

COMMAND:cllist(playerid, params[])
    return cmd_clanlist(playerid, params);


stock DisplayGroupMembers(groupid, playerid)
{
    new amount[2], string[200], shortstr[55], pname[24];
    format(string, sizeof(string), "<-- Membros do CLГN --> %s(ID:%d)", groupinfo[groupid][grname], groupid);
    SendClientMessage(playerid, 0x0000CD, string);
    string = "";
    for(new x; x<MAX_PLAYERS; x++)
    {
        if(group[x][gid] == groupid)
        {
            amount[0] ++;
            amount[1] ++;
            GetPlayerName(x, pname, 24);
            if(groupinfo[groupid][leader] != x) format(shortstr, sizeof(shortstr), "%s(%d),", pname, x);
            if(groupinfo[groupid][leader] == x) format(shortstr, sizeof(shortstr), "[LIDER DO CLГN]%s(%d),", pname, x);
            if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
            if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
            if(amount[0] == 6)
            {
                strdel(string, strlen(string)-1, strlen(string));
                SendClientMessage(playerid, 0xFFCC66, string);
                string = "";
                amount[0] = 0;
            }
        }
    }
    strdel(string, strlen(string)-1, strlen(string));
    if(amount[0] != 0) SendClientMessage(playerid, 0xFFCC66, string);
    return 1;
}

stock ListGroups(playerid)
{
    new amount[2], string[200], shortstr[55];
    SendClientMessage(playerid, 0xFF0000, "Clгns atuais:");
    for(new x=0; x<MAX_GROUPS; x++)
    {
        if(groupinfo[x][active])
        {
            amount[0] ++;
            amount[1] ++;
            format(shortstr, sizeof(shortstr), "%s(ID:%d)", groupinfo[x][grname], x);
            if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
            if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
            if(amount[0] == 4)
            {
                SendClientMessage(playerid, 0xFFCC66, string);
                string = "";
                amount[0] = 0;
            }
        }
    }
    if(amount[1] == 0) SendClientMessage(playerid, 0xFFFF00, "Atualmente nгo hб clгns ativos!");
    if(amount[1] != 0) SendClientMessage(playerid, 0xFFCC66, string);
    return 1;
}



stock SendMessageToLeader(groupi, message[])
    return SendClientMessage(groupinfo[groupi][leader], 0xFFCC66, message);

stock GroupJoin(playerid, groupi)
{
    group[playerid][gid] = groupi;
    group[playerid][order] = GroupMembers(groupi);
    group[playerid][attemptjoin] = -1;
    group[playerid][invited] = -1;
    new pname[24], string[130];
    GetPlayerName(playerid, pname, 24);
    format(string, sizeof(string), "%s juntou ao seu clгn!", pname);
    SendMessageToAllGroupMembers(groupi, string);
    format(string, sizeof(string), "Vocк entrou em um clгn %s(ID:%d)", groupinfo[groupi][grname] ,groupi);
    SendClientMessage(playerid, 0xFFCC66, string);
    return 1;
}

stock FindNextSlot()
{
    new id;
    while(groupinfo[id][active]) id ++;
    return id;
}

stock IsGroupTaken(grpname[])
{
    for(new x; x<MAX_GROUPS; x++) if(!strcmp(grpname, groupinfo[x][grname], true) && strlen(groupinfo[x][grname]) != 0) return 1;
    return 0;
}

stock GroupInvite(playerid, groupid)
    return group[playerid][invited] = groupid;

stock CreateGroup(grpname[], owner)
{
    new slotid = FindNextSlot();
    groupinfo[slotid][leader] = owner;
    format(groupinfo[slotid][grname], 75, "%s", grpname);
    groupinfo[slotid][active] = 1;
    group[owner][gid] = slotid;
    group[owner][order] = 1;
    new string[120];
    format(string, sizeof(string), "Vocк criou o clгn %s(ID:%d)", grpname, slotid);
    SendClientMessage(owner, 0xFFCC66, string);
    return slotid;
}

stock LeaveGroup(playerid, reason)
{
    new groupid = group[playerid][gid], orderid = group[playerid][order], string[100], pname[24];
    group[playerid][gid] = -1;
    group[playerid][order] = -1;
    GroupCheck(groupid, orderid);
    GetPlayerName(playerid, pname, 24);
    if(reason == 0)
    {
        format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} deixou o seu clгn!", pname, playerid);
        SendClientMessage(playerid, 0xFFCC66, "You have left your group");
    }
    if(reason == 1)
    {
        format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} deixou o seu clгn (Expulso pelo lнder)!", pname, playerid);
        SendClientMessage(playerid, 0xFFCC66, "You have been kicked from your group!");
    }
    if(reason == 2) format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} deixou o seu clгn (Desconectado)!", pname, playerid);
    SendMessageToAllGroupMembers(groupid, string);
    return 1;
}

stock GroupCheck(groupid, orderid)
{
    new gmems = GroupMembers(groupid);
    if(!gmems) groupinfo[groupid][active] = 0;
    if(gmems != 0) ChangeMemberOrder(groupid, orderid);
    return 1;
}

stock GroupMembers(groupid)
{
    if(!groupinfo[groupid][active]) return 0;
    new groupmembers;
    for(new i; i<MAX_PLAYERS; i++) if(group[i][gid] == groupid) groupmembers++;
    return groupmembers;
}

stock ChangeMemberOrder(groupid, orderid)
{
    for(new x; x<MAX_PLAYERS; x++)
    {
        if(group[x][gid] != groupid || group[x][order] < orderid) continue;
        group[x][order] --;
        if(group[x][order] == 1)
        {
            groupinfo[groupid][leader] = x;
            new string[128], pname[24];
            GetPlayerName(x, pname, 24);
            format(string, sizeof(string), "{FFFFFF}%s(%d){FFCC66} foi promovido a lнder do novo clгn!", pname, x);
            SendMessageToAllGroupMembers(groupid, string);
        }
    }
    return 1;
}

stock SendMessageToAllGroupMembers(groupid, message[])
{
    if(!groupinfo[groupid][active]) return 0;
    for(new x; x<MAX_PLAYERS; x++) if(group[x][gid] == groupid) SendClientMessage(x, 0xFFCC66, message);
    return 1;
}
Reply
#2

Tem o salvamento dele
Reply
#3

Como assim o Salvamento , a pasta ( clans) na pasta Scriptfiles ?
Reply
#4

Vocк tem que salvar o clan e a conta do usuario que informa o clan que ele esta .
Eu te aconselho usar DOF2 e mais facil.
Reply
#5

Como Salva ? Pelo dof 2 , min ensina por favor presiso de tua ajuda ,,,
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)