Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <ocmd>
- #include <dini>
- /* Settings */
- #define MAX_CLANS 50 //Maximale Clans
- #define C_FILE "/Clans.ini" //Wo die Clans gespeichert werden
- #define GetClanID(%0) GetPVarInt(%0,"ClanID")
- #define GetClanRank(%0) GetPVarInt(%0,"ClanRank")
- #define SetClanID(%0,%1) SetPVarInt(%0,"ClanID",%1)
- #define SetClanRank(%0,%1) SetPVarInt(%0,"ClanRank",%1)
- /* Settings */
- #define Rot 0xE10000FF
- #define HBlau 0x00FFFFFF
- #define Blau 0x2E9AFEFF
- #define Orange 0xFFAB00FF
- #define Weiss 0xFFFFFFFF
- #define Grau 0xA0A0A0FF
- #define dClans 6050 //Dialog
- forward ClanShow();
- new PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];
- #define dInt dini_Int
- #define dIntSet dini_IntSet
- #define dGet dini_Get
- #define dSet dini_Set
- #define dFloatSet dini_FloatSet
- #define dFloat dini_Float
- #define dExist dini_Exists
- new fmex[128];
- #define SCMToAllF(%0,%1,%2) format(fmex,128,%1,%2) && SendClientMessageToAll(%0, fmex)
- #define SCMF(%0,%1,%2) format(fmex,128,%2) && SendClientMessage(%0,%1,fmex)
- #define SCMToAll(%0,%1) format(fmex,128,%1) && SendClientMessageToAll(%0,%1)
- enum ECS{
- ClanID,
- ClanName[64],
- ClanTag[8]
- }
- new Clan[MAX_CLANS][ECS];
- public OnFilterScriptInit(){
- print("\n--------------------------------------");
- print(" Dynamisches Clansystem by ErikSon");
- print("--------------------------------------\n");
- SetTimer("ClanShow",888*60,true);
- for(new i = 0; i<MAX_PLAYERS; i++){
- if(!IsPlayerConnected(i))continue;
- GetPlayerName(i,PlayerName[i],MAX_PLAYER_NAME);
- }
- return LoadClans();
- }
- public OnFilterScriptExit()return SaveClans();
- public OnPlayerConnect(playerid)return GetPlayerName(playerid,PlayerName[playerid],MAX_PLAYER_NAME);
- public ClanShow(){
- new _string[32];
- for(new playerid = 0; playerid<MAX_PLAYERS; playerid++){
- if(!IsPlayerConnected(playerid))continue;
- if(GetClanID(playerid) > 0){
- if(strfind(PlayerName[playerid],Clan[GetClanID(playerid)][ClanTag],true) == -1){
- format(_string,sizeof(_string),"%s[%s]",PlayerName[playerid],Clan[GetClanID(playerid)][ClanTag]);
- SetPlayerName(playerid,_string);
- }
- }
- }
- return 1;
- }
- stock LoadClans(){
- new str[128],cd[64]; format(cd,sizeof(cd),C_FILE);
- if(!dExist(cd))dini_Create(cd);
- for(new i = 1; i<MAX_CLANS; i++){
- format(str,128,"Clan%i_ClanID",i);
- if(dInt(cd,str) <= 0)continue;
- Clan[i][ClanID] = dInt(cd,str);
- format(str,128,"Clan%i_ClanName",i);
- format(Clan[i][ClanName],32,"%s",dGet(cd,str));
- format(str,128,"Clan%i_Tag",i);
- format(Clan[i][ClanTag],8,"%s",dGet(cd,str));
- }
- return 1;
- }
- stock SaveClans(){
- new str[128],cd[64]; format(cd,sizeof(cd),C_FILE);
- if(!dExist(cd))dini_Create(cd);
- for(new i = 1; i<MAX_CLANS; i++){
- if(Clan[i][ClanID] <= 0)continue;
- format(str,128,"Clan%i_ClanID",i);
- dIntSet(cd,str,Clan[i][ClanID]);
- format(str,128,"Clan%i_ClanName",i);
- dSet(cd,str,Clan[i][ClanName]);
- format(str,128,"Clan%i_Tag",i);
- dSet(cd,str,Clan[i][ClanTag]);
- }
- return 1;
- }
- ocmd:clans(playerid){
- new string[512],buffer[512];
- for(new i = 1; i<MAX_CLANS; i++){
- if(Clan[i][ClanID] == 0)continue;
- format(buffer,sizeof(buffer),"%d | %s%c",Clan[i][ClanID],Clan[i][ClanName],(i >= MAX_CLANS) ? '\0' : '\n'),strins(string,buffer,strlen(string),sizeof(string));
- }
- return ShowPlayerDialog(playerid,dClans,DIALOG_STYLE_MSGBOX,"Clans",string,"Okay","");
- }
- ocmd:clanhelp(playerid){
- SCMF(playerid,Orange,"===============> Clanbefehle <===============");
- SCMF(playerid,Rot,"/c(lan), /cinvite, /cuninvite, /clans");
- return SCMF(playerid,Orange,"===============> Clanbefehle <===============");
- }
- ocmd@2:c,clan(playerid,params[]){
- new text[128],string[140];
- if(GetClanID(playerid) <1)return SCMF(playerid,Rot,"Du bist in keinem Clan!");
- if(sscanf(params,"s",text))return SCMF(playerid,Rot,"Benutzung: /c(lan) [Text]");
- format(string,140,"[%s] %s: %s",Clan[GetClanID(playerid)][ClanTag],PlayerName[playerid],text);
- for(new i=0; i<MAX_PLAYERS; i++){
- if(!IsPlayerConnected(i))continue;
- if(GetClanID(i) != GetClanID(playerid))continue;
- SCMF(i,HBlau,string);
- }
- return 1;
- }
- ocmd@2:cinvite,ceinladen(playerid,params[]){
- new pID,string[128];
- if(GetClanID(playerid) <1)return SCMF(playerid,Rot,"Du bist in keinem Clan!");
- if(GetClanRank(playerid) <2)return SCMF(playerid,Rot,"Du bist nicht der Leader des Clans!");
- if(sscanf(params,"u",pID))return SCMF(playerid,Rot,"Benutzung: /cinvite [Spieler]");
- if(!IsPlayerConnected(pID))return SCMF(playerid,Rot,"Dieser Spieler ist nicht online!");
- if(GetClanID(playerid) != 0)return SCMF(playerid,Rot,"Der Spieler '%s' ist bereits / noch in einem Clan!",PlayerName[pID]);
- format(string,128,"[%s] %s hat den Spieler %s in den Clan eingeladen.",Clan[GetClanID(playerid)][ClanTag],PlayerName[playerid],PlayerName[pID]);
- for(new i=0; i<MAX_PLAYERS; i++){
- if(!IsPlayerConnected(i))continue;
- if(GetClanID(i) != GetClanID(playerid))continue;
- SCMF(i,HBlau,string);
- }
- SetPVarInt(pID,"CEingeladen",GetClanID(playerid));
- SCMF(pID,Orange,"[%s] %s von dem Clan '%s' hat dir eine Clan-Einladung geschickt.",Clan[GetClanID(playerid)][ClanTag],PlayerName[playerid],Clan[GetClanID(playerid)][ClanName]);
- return SCMF(pID,Blau,"Tippe '/ceinladung annehmen | /ceinladung ablehnen' um die Einladung anzunehmen / abzulehnen.");
- }
- ocmd:ceinladung(playerid,params[]){
- new string[128],a[16];
- if(GetPVarInt(playerid,"CEingeladen") <= 0)return SCMF(playerid,Rot,"Du hast keine Einladung eines Clans erhalten!");
- if(sscanf(params,"s",a))return SCMF(playerid,Rot,"Benutzung: /ceinladung [annehmen / ablehnen]");
- if(strcmp(a,"annehmen",false)){
- format(string,128,"Spieler '%s' hat die Einladung in den Clan angenommen.",PlayerName[playerid]);
- SCMF(playerid,Blau,"Du hast die Einladung in den Clan '%s' angemommen.",Clan[GetPVarInt(playerid,"CEingeladen")][ClanName]);
- for(new i=0; i<MAX_PLAYERS; i++){
- if(!IsPlayerConnected(i))continue;
- if(GetClanID(i) != GetPVarInt(playerid,"CEingeladen"))continue;
- SCMF(i,Blau,string);
- }
- SetClanID(playerid,GetPVarInt(playerid,"CEingeladen"));
- return SetClanRank(playerid,1),SetPVarInt(playerid,"CEingeladen",0);
- }
- else if(strcmp(a,"ablehnen",false)){
- format(string,128,"Spieler '%s' hat die Einladung in den Clan abgelehnt.",PlayerName[playerid]);
- for(new i=0; i<MAX_PLAYERS; i++){
- if(!IsPlayerConnected(i))continue;
- if(GetClanID(i) != GetPVarInt(playerid,"CEingeladen"))continue;
- SCMF(i,Blau,string);
- }
- return SetPVarInt(playerid,"CEingeladen",0);
- }
- return 1;
- }
- ocmd@2:cuninvite,ckick(playerid,params[]){
- new pID,string[128];
- if(GetClanID(playerid) <1)return SCMF(playerid,Rot,"Du bist in keinem Clan!");
- if(GetClanRank(playerid) <2)return SCMF(playerid,Rot,"Du bist nicht der Leader des Clans!");
- if(sscanf(params,"u",pID))return SCMF(playerid,Rot,"Benutzung: /cuninvite [Spieler]");
- if(!IsPlayerConnected(pID))return SCMF(playerid,Rot,"Dieser Spieler ist nicht online!");
- if(GetClanID(pID) <= 0)return SCMF(playerid,Rot,"Der Spieler '%s' ist in keinem Clan!");
- if(GetClanID(pID) != GetClanID(playerid))return SCMF(playerid,Rot,"Der Spieler '%s' ist nicht in deinem Clan!",PlayerName[pID]);
- format(string,128,"%s hat den Spieler %s aus dem Clan ausgeschlossen.",PlayerName[playerid],PlayerName[pID]);
- for(new i=0; i<MAX_PLAYERS; i++){
- if(!IsPlayerConnected(i))continue;
- if(GetClanID(i) != GetClanID(playerid))continue;
- SCMF(i,Orange,string);
- }
- SetClanID(pID,0);
- return SCMF(pID,Orange,"%s von dem Clan '%s' hat dich aus dem Clan ausgeschlossen.",PlayerName[playerid],Clan[GetClanID(playerid)][ClanName]);
- }
- ocmd:cclan(playerid,p[]){
- if(!IsPlayerAdmin(playerid))return 1;
- new cn[32],ct[8];
- if(sscanf(p,"ss",cn,ct))return SCMF(playerid,Rot,"Benutzung: /cclan [Clan-Name] [Clan-Tag |max 8 Zeichen|]");
- for(new i = 1; i<MAX_CLANS; i++){
- if(Clan[i][ClanID] >= 1)continue;
- Clan[i][ClanID] = i;
- format(Clan[i][ClanName],32,"%s",cn), format(Clan[i][ClanTag],8,"%s",ct);
- SaveClans();
- return SCMF(playerid,Blau,"Clan %i | '[%s]%s' erfolgreich erstellt.",i,ct,cn);
- }
- return 1;
- }
- ocmd:dclan(playerid,p[]){
- if(!IsPlayerAdmin(playerid))return 1;
- new cid;
- if(sscanf(p,"i",cid))return SCMF(playerid,Rot,"Benutzung: /dclan [Clan-ID]");
- if(Clan[cid][ClanID] <= 0)return SCMF(playerid,Rot,"Dieser Clan existiert nicht!");
- SCMF(playerid,Blau,"Du hast den Clan '%s' erfolgreich gelöscht.",Clan[cid][ClanName]);
- return Clan[cid][ClanID] = 0, format(Clan[cid][ClanTag],5,""),format(Clan[cid][ClanName],32,"");
- }
- ocmd:makecleader(playerid,p[]){
- if(!IsPlayerAdmin(playerid))return 1;
- new pID,wert;
- if(sscanf(p,"ui",pID,wert))return SCMF(playerid,Rot,"Benutzung: /makecleader [Spieler] [Clan-ID ( Siehe '/clans' )]");
- if(wert <= 0){
- if(GetClanID(pID) > 0){
- SetClanID(pID,0);
- SetPlayerName(pID,PlayerName[pID]);
- SCMF(playerid,Grau,"Du hast den Spieler '%s' aus seinem Clan rausgenommen.",PlayerName[pID]);
- return SCMF(pID,Grau,"Admin %s hat dich aus deinem Clan rausgenommen.",PlayerName[playerid]);
- }
- return 1;
- }
- else if(Clan[wert][ClanID] <= 0)return SCMF(playerid,Rot,"Dieser Clan existiert nicht!");
- else if(GetClanID(pID) > 0)SetPlayerName(pID,PlayerName[pID]);
- SetClanID(pID,wert),SetClanRank(pID,2);
- SCMF(playerid,Grau,"Du hast den Spieler '%s' in den Clan '%s' eingeladen.",PlayerName[pID],Clan[wert][ClanName]);
- return SCMF(pID,Grau,"Admin %s hat dich in den Clan '%s' eingalden.",PlayerName[playerid],Clan[wert][ClanName]);
- }
- stock sscanf(string[], format[], {Float,_}:...){
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (string[stringPos] && string[stringPos] <= ' ')
- {
- stringPos++;
- }
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = string[stringPos];
- do
- {
- stringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = stringPos;
- while(changepos < 16 && string[strpos] && string[strpos] != delim)
- {
- changestr[changepos++] = string[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- stringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = stringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = string[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - stringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, string[stringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- stringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
- {
- stringPos++;
- }
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
- {
- stringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement