Clan System

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Folgendes Problem:


    Ich nutze das FS welches ich auf Deutsch umgeschrieben haben nun meine Frage wie Speichere ich es jetzt
    das beim einloggen die sachen geladen werden :/


    Code :


    #include <a_samp>
    #include <zcmd>
    //Variablen
    #define MAX_GROUPS 1000
    // Farben
    #define ORANGE 0xFF5A00FF


    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;
    }
    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:createclan(playerid, params[])
    {
    if(group[playerid][gid] != -1) return SendClientMessage(playerid,ORANGE,"[CLAN] Verlasse zunächst die Gruppe /cleave bevor du dir eine neue erstellst");
    if(strlen(params) > 49 || strlen(params) < 3) return SendClientMessage(playerid,ORANGE,"[CLAN] /createclan [Name des Clans mind. 3-50 Zeichen]");
    if(IsGroupTaken(params)) return SendClientMessage(playerid,ORANGE,"[CLAN] angegebener Clan Name existiert bereits wähle einen anderen Namen");
    CreateGroup(params, playerid);
    return 1;
    }


    COMMAND:cleave(playerid, params[])
    {
    if(group[playerid][gid] == -1) return SendClientMessage(playerid,ORANGE,"[CLAN] Du befindest dich in keinem Clan");
    LeaveGroup(playerid, 0);
    return 1;
    }


    COMMAND:cinvite(playerid, params[])
    {
    if(group[playerid][order] != 1) return SendClientMessage(playerid,ORANGE,"[CLAN] Du bist kein Leader und hast somit kein Recht Spieler zu Inviten");
    new cid;
    if(isnull(params)) return SendClientMessage(playerid,ORANGE,"[CLAN] /cinvite [SpielerID]");
    cid = strval(params);
    if(!IsPlayerConnected(cid)) return SendClientMessage(playerid,ORANGE,"Spieler ist nicht Online");
    if(group[cid][gid] == group[playerid][gid]) return SendClientMessage(playerid,ORANGE,"Spieler befindet sich bereits in deinem Clan");
    if(group[cid][invited] == group[playerid][gid]) return SendClientMessage(playerid,ORANGE,"Spieler hat bereits eine Invite Anfrage erhalten");
    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),"[CLAN] Du wurdest von %s ID: %d in den Clan %s ID: %d eingeladen /cannehmen um beizutreten",group[playerid][gid],groupinfo[group[playerid][gid]][grname],pname,playerid,group[playerid][gid]);
    SendClientMessage(cid,ORANGE,string);
    GetPlayerName(cid,pname,24);
    format(string, sizeof(string),"[CLAN] Du hast Spieler %s ID %d eine Clan einladung gesendet", pname, cid);
    SendClientMessage(playerid,ORANGE,string);
    return 1;
    }


    COMMAND:cleader(playerid, params[])
    {
    if(group[playerid][order] != 1) return SendClientMessage(playerid,ORANGE, "[CLAN] Du bist nicht der Leader des Clans und hast somit keine erlaubnis");
    new cid;
    if(isnull(params)) return SendClientMessage(playerid,ORANGE,"[CLAN] /cleader [SpielerID]");
    cid = strval(params);
    if(!IsPlayerConnected(cid)) return SendClientMessage(playerid,ORANGE,"[CLAN] Spieler ist nicht Online");
    if(cid == playerid) return SendClientMessage(playerid,ORANGE,"[CLAN] Du bist bereits der Clan Leader");
    if(group[playerid][gid] != group[cid][gid]) return SendClientMessage(playerid,ORANGE,"[CLAN] Spieler befindet sich nicht in deiner Gruppe");
    ChangeMemberOrder(group[playerid][gid],1);
    group[playerid][order] = GroupMembers(group[playerid][gid]);
    return 1;
    }


    COMMAND:cannehmen(playerid, params[])
    {
    if(group[playerid][gid] != -1) return SendClientMessage(playerid,ORANGE,"[CLAN] Du befindest dich bereits in einem Clan verlasse ihn zuerst /cleave");
    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,ORANGE,"[CLAN] /cannehmen [Clan ID]");
    grid = strval(params);
    if(!groupinfo[grid][active]) return SendClientMessage(playerid,ORANGE,"[CLAN] Der Clan existiert nicht oder hat dich nicht eingeladen");
    group[playerid][attemptjoin] = grid;
    new string[125], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(string, sizeof(string), "[CLAN] Du hast %s(ID:%d) eine Anfrage gesendet", groupinfo[grid][grname], grid);
    SendClientMessage(playerid,ORANGE,string);
    format(string, sizeof(string), "[CLAN] %s ID: %d hat dir eine Anfrage zum Clan gesendet, tippe /cannehmen %d zum Akzeptieren", pname, playerid, playerid);
    SendMessageToLeader(grid, string);
    return 1;
    }


    COMMAND:ckick(playerid, params[])
    {
    if(group[playerid][order] != 1) return SendClientMessage(playerid,ORANGE,"[CLAN] Du bist nicht der Leader um Member aus dem Clan zu werfen");
    new cid;
    if(isnull(params)) return SendClientMessage(playerid,ORANGE,"[CLAN] /ckick [SpielerID]");
    cid = strval(params);
    if(!IsPlayerConnected(cid)) return SendClientMessage(playerid,ORANGE,"[CLAN] Spieler ist nicht Online");
    if(cid == playerid) return SendClientMessage(playerid,ORANGE,"[CLAN] Du kannst dich nicht selber aus dem Clan werfen");
    if(group[playerid][gid] != group[cid][gid]) return SendClientMessage(playerid,ORANGE,"[CLAN] Spieler befindet sich nicht in deinem Clan");
    LeaveGroup(cid, 1);
    return 1;
    }


    COMMAND:c(playerid, params[])
    {
    if(group[playerid][gid] == -1) return SendClientMessage(playerid,ORANGE,"[CLAN] Du befindest dich in keinem Clan");
    if(isnull(params)) return SendClientMessage(playerid,ORANGE,"[CLAN] /c [Nachricht]");
    new pname[24], string[140+24];
    GetPlayerName(playerid, pname, 24);
    format(string,sizeof(string),"Spieler %s sagt: %s", pname,params);
    SendMessageToAllGroupMembers(group[playerid][gid], string);
    return 1;
    }



    COMMAND:clist(playerid, params[])
    {
    if(isnull(params) && group[playerid][gid] == -1) return SendClientMessage(playerid,ORANGE,"[CLAN] /clist [Clan ID]");
    if(isnull(params))
    {
    DisplayGroupMembers(group[playerid][gid],playerid);
    return 1;
    }
    new grid = strval(params);
    if(!groupinfo[grid][active]) return SendClientMessage(playerid,ORANGE,"[CLAN] Die angegebene Clan ID ist nicht Aktiv");
    DisplayGroupMembers(grid, playerid);
    return 1;
    }


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


    COMMAND:grl(playerid, params[])
    return cmd_cleave(playerid, params);


    COMMAND:grc(playerid, params[])
    return cmd_createclan(playerid, params);


    COMMAND:gri(playerid, params[])
    return cmd_cinvite(playerid, params);


    COMMAND:grlead(playerid, params[])
    return cmd_cleader(playerid, params);


    COMMAND:grj(playerid, params[])
    return cmd_cannehmen(playerid, params);


    COMMAND:grk(playerid, params[])
    return cmd_ckick(playerid, params);


    COMMAND:gm(playerid, params[])
    return cmd_c(playerid, params);


    COMMAND:grlist(playerid, params[])
    return cmd_clist(playerid, params);



    stock DisplayGroupMembers(groupid, playerid)
    {
    new amount[2], string[200], shortstr[55], pname[24];
    format(string, sizeof(string), "Group Members for %s(ID:%d)", groupinfo[groupid][grname], groupid);
    SendClientMessage(playerid, 0xFFFFFF, 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), "[LEADER]%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,ORANGE, string);
    return 1;
    }


    stock ListGroups(playerid)
    {
    new amount[2], string[200], shortstr[55];
    SendClientMessage(playerid,ORANGE, "Verfügbare Clans:");
    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,ORANGE,string);
    string = "";
    amount[0] = 0;
    }
    }
    }
    if(amount[1] == 0) SendClientMessage(playerid,ORANGE, "Kein Aktiver Clan zurzeit");
    if(amount[1] != 0) SendClientMessage(playerid,ORANGE, string);
    return 1;
    }




    stock SendMessageToLeader(groupi, message[])
    return SendClientMessage(groupinfo[groupi][leader],ORANGE, 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), "[CLAN] %s ist dem Clan beigetreten", pname);
    SendMessageToAllGroupMembers(groupi, string);
    format(string, sizeof(string), "[CLAN] Du bist dem Clan %s(ID:%d) beigetreten", groupinfo[groupi][grname] ,groupi);
    SendClientMessage(playerid,ORANGE,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(groupinfo[x][active] == 1)
    {
    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), "[CLAN] Du hast den Clan %s [ID: %d] erstellt", grpname, slotid);
    SendClientMessage(owner,ORANGE, 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), "[CLAN] Spieler %s [ID: %d] hat den Clan verlassen", pname, playerid);
    SendClientMessage(playerid,ORANGE,"[CLAN] Du hast den Clan verlassen");
    }
    if(reason == 1)
    {
    format(string, sizeof(string), "[CLAN] Spieler %s [ID: %d] hat den Clan verlassen (gekickt vom Leader)", pname, playerid);
    SendClientMessage(playerid,ORANGE,"[CLAN] Spieler wurde aus dem Clan gekickt");
    }
    if(reason == 2) format(string, sizeof(string), "[CLAN] Spieler %s [ID: %d] hat den Clan verlassen (Spieler hat den Server verlassen)", 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), "[CLAN] Spieler %s [ID: %d] wurde zum Clan Leader befördert", 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;
    }





    Mit Freundlichen Grüßen ,


    Toastiie1337