Ein neues Thema erstellen  Auf das Thema antworten  [ 6 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Plugin_tagprotect
BeitragVerfasst: 30.07.2003, 21:06 
Benutzeravatar

Registriert: 31.05.2003, 09:16
Beiträge: 790
wie kann ich es umschreiben, dass die tags.txt in
addons/adminmod/config/tagprotect
kommt?

oder kann es einer neuschreiben? kick und namechange reicht...

Code:
/**********************************************************
 Protect Tag by redeyez (redeyez@mindspring.com)

 Protect Clan Tags and/or Player names to certain WonID

 History:
 version 1.2 - Implemented the Command option.
		   Added more (rather verbose) Debug comments.
		   Removed some junk.
 version 1.1 - Fixed a cuple of bugs.
		   Add Command option in Tags.txt file
		   Not implemented yet.
 version 1.0 - First release of Protect Tag Plugin.

**********************************************************/

#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>

#define ACCESS_PROTECTTAG 8192
#define MAX_TAGS 100

new STRING_VERSION[MAX_DATA_LENGTH] = "1.2";

new TagTimer[MAX_PLAYERS];

new FileStatus = 0; /* Check if file exists flag */
new TotalTags = 0;
new ClanTag[MAX_TAGS][MAX_TEXT_LENGTH];
new Command[MAX_TAGS];
new TagType[MAX_TAGS];
new PlayerWonID[MAX_TAGS][MAX_TEXT_LENGTH];
new DebugUser[MAX_NAME_LENGTH];
new DebugFlag = 0;

public tag_debug (HLCommand, HLData, HLUserName, UserIndex)
{
	convert_string(HLUserName, DebugUser, MAX_NAME_LENGTH);

	if (DebugFlag)
	{
		printf ("[PROTECT TAG] Debug Off^n");
		messageex(DebugUser,"[PROTECT TAG] Debug Off",print_console);
		DebugFlag = 0;
	}
	else
	{
		printf ("[PROTECT TAG] Debug On^n");
		messageex(DebugUser,"[PROTECT TAG] Debug On",print_console);
		DebugFlag = 1;
	}
	return PLUGIN_HANDLED;
}

public load_tag_file()
{
	new gotLine;
	new lineNum = 0;
	new lineStr[MAX_TEXT_LENGTH];
	new Text[MAX_TEXT_LENGTH];

	TotalTags = 0;

	FileStatus = fileexists("TAGS.TXT");
	if ( FileStatus > 0 )
	{
		printf("[TAG PROTECT]Reading Tags.^n");
		do
		{
			gotLine = readfile("TAGS.TXT",lineStr, lineNum, MAX_TEXT_LENGTH);
			if (gotLine)
		      {
				if (DebugFlag)
				{
					printf ("Got tag %s^n",lineStr);
					printf ("Got Line # %s^n",TotalTags+1);
				}
				lineNum++;
				if ((strncmp(lineStr, "#", 1) == 0) || (strncmp(lineStr, "//", 2) == 0))
				{
					/* Ignoreing comment. */
				}
				else
				{
					strsplit(lineStr, ";", TagType[TotalTags], MAX_DATA_LENGTH , Command[TotalTags], MAX_DATA_LENGTH , ClanTag[TotalTags], MAX_DATA_LENGTH, PlayerWonID[TotalTags], MAX_DATA_LENGTH);
					TagType[TotalTags] = strtonum(TagType[TotalTags]);
					Command[TotalTags] = strtonum(Command[TotalTags]);
					if (DebugFlag)
					{
						printf("TAG: %s WONID: %s COMMAND: %i TAGTYPE: %i^n",ClanTag[TotalTags],PlayerWonID[TotalTags],Command[TotalTags],TagType[TotalTags]);
					}
					TotalTags++;
				}
			}
			if ( TotalTags > MAX_TAGS )
			{
				return PLUGIN_CONTINUE;
			}
		} while(gotLine);
		TotalTags--;
		snprintf(Text, MAX_TEXT_LENGTH, "[PROTECT TAG] TAGS.TXT file found: %i Tags",TotalTags);
		printf ("%s.^n",Text);
		if (DebugFlag)
		{
			messageex(DebugUser,Text,print_console);
		}
	}
	else
	{
		printf ("[PROTECT TAG] Cannot find TAGS.TXT file.^n");
		if (DebugFlag)
		{
			messageex(DebugUser,"[PROTECT TAG] Cannot find TAGS.TXT file.",print_console);
		}
	}
	return PLUGIN_HANDLED;
}

public  TagTrigger(Timer,WaitCount,RepeatCount,User) {
	new MyWONID;
	new UserIndex;
	new MyName[MAX_NAME_LENGTH];
	new searchIndex = 0;
	new Text[MAX_TEXT_LENGTH];
	new NameFound = 0;
	new TagFound = 0;
	new TagCommand = 0;

	convert_string(User, MyName, MAX_NAME_LENGTH);
	get_userindex(MyName, UserIndex);
	get_userWONID(MyName, MyWONID);

	/* Only continue if player has fully connected; WONID of 0 means they haven't */
	if ( MyWONID != 0 )
	{
		if (DebugFlag)
		{
			messageex(MyName,"[PROTECT TAG] AUTHENTICATING CLAN TAG...",print_console);
			printf ("%s",Text);
		}

		for ( searchIndex=1; searchIndex<=TotalTags; searchIndex++ )
		{
			if (TagType[searchIndex] == 0 )
			{
				if ( (strcasestr(MyName,ClanTag[searchIndex]) != -1) )
				{
					if (DebugFlag)
					{
						messageex(MyName,"^n[PROTECT TAG] TAG MATCH",print_console);
						snprintf(Text, MAX_TEXT_LENGTH, "^nsearchIndex: %i ClanTag: %s YourName: %s",searchIndex, ClanTag[searchIndex], MyName);
						messageex(MyName, Text, print_console);
					}

					if (MyWONID == strtonum(PlayerWonID[searchIndex]))
					{
						TagFound = 1;
						if (DebugFlag)
						{
							messageex(MyName,"AUTHENICATED",print_console);
							printf ("%s.^n",Text);
						}
						searchIndex=TotalTags+1;
					}
					else
					{
						TagFound = 2;
						if ( Command[searchIndex] > TagCommand )
						{
							TagCommand = Command[searchIndex];
						}
					}
				}
			}
		}
		if (DebugFlag)
		{
			if ( TagFound == 2 )
			{
				messageex(MyName, "FAILED TO AUTHENICATE",print_console);
				printf ("%s^n",Text);
			}

			if ( TagFound == 0 )
			{
				messageex(MyName, "DONE",print_console);
				printf ("%s^n",Text);
			}

			messageex(MyName,"[PROTECT TAG] AUTHENTICATING NAME...",print_console);
			printf ("%s",Text);
		}

		for ( searchIndex=1; searchIndex<=TotalTags; searchIndex++ )
		{
			if (TagType[searchIndex] == 1 )
			{
				if ( (strcasestr(MyName,ClanTag[searchIndex]) != -1) )
				{
					if (DebugFlag)
					{
						messageex(MyName,"^n[PROTECT TAG] NAME MATCH",print_console);
						snprintf(Text, MAX_TEXT_LENGTH, "^nsearchIndex: %i ClanTag: %s YourName: %s",searchIndex, ClanTag[searchIndex], MyName);
						messageex(MyName, Text, print_console);
					}

					if (MyWONID == strtonum(PlayerWonID[searchIndex]))
					{
						NameFound = 1;
						if (DebugFlag)
						{
							messageex(MyName,"AUTHENICATED",print_console);
							printf ("%s^n",Text);
						}
						searchIndex=TotalTags+1;
					}
					else
					{
						NameFound = 2;
						if ( Command[searchIndex] > TagCommand )
						{
							TagCommand = Command[searchIndex];
						}
					}
				}
			}
		}
		if (DebugFlag)
		{
			if ( NameFound == 2 )
			{
				messageex(MyName, "FAILED TO AUTHENICATE",print_console);
				printf ("%s^n",Text);
			}

			if ( NameFound == 0 )
			{
				messageex(MyName, "DONE",print_console);
				printf ("%s^n",Text);
			}
		}

		if ( (TagFound == 2) || (NameFound == 2) )
		{
			if ( TagCommand != 1 && TagCommand != 2 )
			{
				execclient(MyName, "name IMPOSTER");
			}
			if ( TagCommand == 1 )
			{
				kick(MyName);
			}
			if ( TagCommand == 2 )
			{
				ban(MyName,0);
			}
		}
		kill_timer(TagTimer[UserIndex]);
	}
	else
	{
		/* Repeat later when the player has hopefully finished connecting */
		if ( TagTimer[UserIndex] != 0 ) kill_timer(TagTimer[UserIndex]);
		TagTimer[UserIndex] = set_timer("TagTrigger",30,0,MyName);
	}
}




public plugin_connect(HLUserName, HLIP, UserIndex)
{
	new MyUserName[MAX_NAME_LENGTH];

	convert_string(HLUserName, MyUserName, MAX_NAME_LENGTH);

	if ( (UserIndex >= 1) && (UserIndex <= MAX_PLAYERS))
	{
		if ( TagTimer[UserIndex] != 0 ) kill_timer(TagTimer[UserIndex]);
		TagTimer[UserIndex] = set_timer("TagTrigger",30,0,MyUserName);

	}

	return PLUGIN_CONTINUE;
}

public plugin_disconnect(HLUserName, UserIndex) {
	if ( UserIndex >= 1 && UserIndex <= MAX_PLAYERS )
	{
		if ( TagTimer[UserIndex] != 0 ) kill_timer(TagTimer[UserIndex]);
	}

	return PLUGIN_CONTINUE;
}


public plugin_info(HLOldName,HLNewName,UserIndex)
{
	new Text[MAX_TEXT_LENGTH];
	new MyWONID;
	new NewName[MAX_NAME_LENGTH];
	new OldName[MAX_NAME_LENGTH];
	new NameFound = 0;
	new searchIndex = 0;
	new TagFound = 0;
	new TagCommand = 0;

	convert_string(HLNewName, NewName, MAX_NAME_LENGTH);
	convert_string(HLOldName, OldName, MAX_NAME_LENGTH);

	get_userWONID(OldName, MyWONID);

	/* Only bother if the name has changed. */
	if(streq(OldName,NewName)==0)
	{
		if (DebugFlag)
		{
			messageex(OldName,"[PROTECT TAG] YOUR NAME HAS CHANGED",print_console);
		}

		if ( (strcasestr(NewName,"IMPOSTER") != -1) )
		{
			return PLUGIN_CONTINUE;
		}

		if (DebugFlag)
		{
			messageex(OldName,"[PROTECT TAG] AUTHENTICATING CLAN TAG...",print_console);
			printf ("%s",Text);
		}

		for ( searchIndex=1; searchIndex<=TotalTags; searchIndex++ )
		{


			if (TagType[searchIndex] == 0 )
			{
				if ( (strcasestr(NewName,ClanTag[searchIndex]) != -1) )
				{
					if (DebugFlag)
					{
						messageex(OldName,"^n[PROTECT TAG] TAG MATCH",print_console);
						snprintf(Text, MAX_TEXT_LENGTH, "^nsearchIndex: %i ClanTag: %s YourName: %s",searchIndex, ClanTag[searchIndex], NewName);
						messageex(OldName, Text, print_chat);
					}

					if (MyWONID == strtonum(PlayerWonID[searchIndex]))
					{
						TagFound = 1;
						if (DebugFlag)
						{
							messageex(OldName,"AUTHENICATED",print_console);
							printf ("%s.^n",Text);
						}
						searchIndex=TotalTags+1;
					}
					else
					{
						TagFound = 2;
						if ( Command[searchIndex] > TagCommand )
						{
							TagCommand = Command[searchIndex];
						}
					}
				}
			}
		}

		if (DebugFlag)
		{
			if ( TagFound == 2 )
			{
				messageex(OldName, "FAILED TO AUTHENICATE",print_console);
				printf ("%s^n",Text);
			}

			if ( TagFound == 0 )
			{
				messageex(OldName, "DONE",print_console);
				printf ("%s^n",Text);
			}

			messageex(OldName,"[PROTECT TAG] AUTHENTICATING NAME...",print_console);
			printf ("%s",Text);
		}
		for ( searchIndex=1; searchIndex<=TotalTags; searchIndex++ )
		{
			if (TagType[searchIndex] == 1 )
			{
				if ( (strcasestr(NewName,ClanTag[searchIndex]) != -1) )
				{
					if (DebugFlag)
					{
						messageex(OldName,"^n[PROTECT TAG] NAME MATCH",print_console);
						snprintf(Text, MAX_TEXT_LENGTH, "^nsearchIndex: %i ClanTag: %s YourName: %s",searchIndex, ClanTag[searchIndex], NewName);
						messageex(OldName, Text, print_console);
					}

					if (MyWONID == strtonum(PlayerWonID[searchIndex]))
					{
						NameFound = 1;
						if (DebugFlag)
						{
							messageex(OldName,"AUTHENICATED",print_console);
							printf ("%s^n",Text);
						}
						searchIndex=TotalTags+1;
					}
					else
					{
						NameFound = 2;
						if ( Command[searchIndex] > TagCommand )
						{
							TagCommand = Command[searchIndex];
						}
					}
				}
			}
		}

		if (DebugFlag)
		{
			if ( NameFound == 2 )
			{
				messageex(OldName, "FAILED TO AUTHENICATE",print_console);
				printf ("%s^n",Text);
			}

			if ( NameFound == 0 )
			{
				messageex(OldName, "DONE",print_console);
				printf ("%s^n",Text);
			}
		}

		if ( (TagFound == 2) || (NameFound == 2) )
		{
			if ( TagCommand != 1 && TagCommand != 2 )
			{
				execclient(OldName, "name IMPOSTER");
			}
			if ( TagCommand == 1 )
			{
				kick(OldName);
			}
			if ( TagCommand == 2 )
			{
				ban(OldName,0);
			}
			return PLUGIN_HANDLED;
		}
	}
	return PLUGIN_CONTINUE;
}


public plugin_init()
{
	plugin_registerinfo("Protect Clan Tags Plugin", "Protect Clan Tags.", STRING_VERSION);
	plugin_registercmd("admin_loadtags", "load_tag_file", ACCESS_PROTECTTAG);
	plugin_registercmd("admin_tagdebug", "tag_debug",ACCESS_PROTECTTAG);
	load_tag_file();
	return PLUGIN_CONTINUE;
}


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 30.07.2003, 21:20 
AM.de Team

Registriert: 08.07.2002, 21:11
Beiträge: 2192
Mit meinen begrenzten Kenntnissen wuerde ich mal sagen, dass Du die Zeile
Code:
      {
         gotLine = readfile("TAGS.TXT",lineStr, lineNum, MAX_TEXT_LENGTH); 
auf das gewuenschte Verzeichnis editieren musst.

Sie befindet sich in der public load_tag_file() Funktion.

Keine Garantie :roll:

greez

[-=THH=-]Stillsetzhut

_________________
it's better to burn out, than to fade away


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 30.07.2003, 21:22 
AM.de Team

Registriert: 04.10.2002, 16:14
Beiträge: 1212
die hier auch
Code:
   FileStatus = fileexists("TAGS.TXT"); 


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 30.07.2003, 23:22 
AM.de Team
Benutzeravatar

Registriert: 23.11.2001, 00:00
Beiträge: 3842
Wohnort: Vor König Arthus
Dürfte ich mal fragen, warum Du so ein Plugin brauchst? Du hast doch schon mit Regex einen Tag-Protect eingerichtet.

_________________
Der schwarze Ritter triumphiert immer...
WING-Clan


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 31.07.2003, 07:18 
Benutzeravatar

Registriert: 31.05.2003, 09:16
Beiträge: 790
ja, hat auch mit regex wunderbar funktioniert...
gab aber paar problemchen... beim mapchange bin ich z.B. rausgeflogen wegen "nickname reserviert" - ein retry hat auch nix genutzt... musste ganz raus und wieder neu connecten...

aber sonst ging es auch mit regex... nur scheint mir das plugin die einfachere wahl zu sein... ich trage nur die wonid`s in die tags.txt und fertig...

bin eher der "test-typ" - halte mir mehrere optionen offen und teste die einfachste...


Nach oben
   
 Betreff des Beitrags:
BeitragVerfasst: 31.07.2003, 12:59 
Benutzeravatar

Registriert: 31.05.2003, 09:16
Beiträge: 790
funzt bei mir net richtig... scheint beim kick probleme zu haben...
habs aber geändert bekommen, mit der tags.txt... :lol:

nur funzt es nicht... kann mal einer bei sich testen?
ausserdem kommt ne compillerwarnung:
Code:
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>

#define ACCESS_PROTECTTAG 8192
#define MAX_TAGS 100

new STRING_VERSION[MAX_DATA_LENGTH] = "1.2";

new TagTimer[MAX_PLAYERS];

new FileStatus = 0; /* Check if file exists flag */
new TotalTags = 0;
new ClanTag[MAX_TAGS][MAX_TEXT_LENGTH];
new Command[MAX_TAGS];
new TagType[MAX_TAGS];
new PlayerWonID[MAX_TAGS][MAX_TEXT_LENGTH];
new DebugUser[MAX_NAME_LENGTH];
new DebugFlag = 0;

public tag_debug (HLCommand, HLData, HLUserName, UserIndex)
{
	convert_string(HLUserName, DebugUser, MAX_NAME_LENGTH);

	if (DebugFlag)
	{
		printf ("[PROTECT TAG] Debug Off^n");
		messageex(DebugUser,"[PROTECT TAG] Debug Off",print_console);
		DebugFlag = 0;
	}
	else
	{
		printf ("[PROTECT TAG] Debug On^n");
		messageex(DebugUser,"[PROTECT TAG] Debug On",print_console);
		DebugFlag = 1;
	}
	return PLUGIN_HANDLED;
}

public load_tag_file()
{
	new gotLine;
	new lineNum = 0;
	new lineStr[MAX_TEXT_LENGTH];
	new Text[MAX_TEXT_LENGTH];

	TotalTags = 0;

	FileStatus = fileexists("addons/adminmod/config/tags/tags.txt");
	if ( FileStatus > 0 )
	{
		printf("[TAG PROTECT]Reading Tags.^n");
		do
		{
			gotLine = readfile("addons/adminmod/config/tags/tags.txt",lineStr, lineNum, MAX_TEXT_LENGTH);
			if (gotLine)
		      {
				if (DebugFlag)
				{
					printf ("Got tag %s^n",lineStr);
					printf ("Got Line # %s^n",TotalTags+1);
				}
				lineNum++;
				if ((strncmp(lineStr, "#", 1) == 0) || (strncmp(lineStr, "//", 2) == 0))
				{
					/* Ignoreing comment. */
				}
				else
				{
					strsplit(lineStr, ";", TagType[TotalTags], MAX_DATA_LENGTH , Command[TotalTags], MAX_DATA_LENGTH , ClanTag[TotalTags], MAX_DATA_LENGTH, PlayerWonID[TotalTags], MAX_DATA_LENGTH);
					TagType[TotalTags] = strtonum(TagType[TotalTags]);
					Command[TotalTags] = strtonum(Command[TotalTags]);
					if (DebugFlag)
					{
						printf("TAG: %s WONID: %s COMMAND: %i TAGTYPE: %i^n",ClanTag[TotalTags],PlayerWonID[TotalTags],Command[TotalTags],TagType[TotalTags]);
					}
					TotalTags++;
				}
			}
			if ( TotalTags > MAX_TAGS )
			{
				return PLUGIN_CONTINUE;
			}
		} while(gotLine);
		TotalTags--;
		snprintf(Text, MAX_TEXT_LENGTH, "[PROTECT TAG] TAGS.TXT file found: %i Tags",TotalTags);
		printf ("%s.^n",Text);
		if (DebugFlag)
		{
			messageex(DebugUser,Text,print_console);
		}
	}
	else
	{
		printf ("[PROTECT TAG] Cannot find TAGS.TXT file.^n");
		if (DebugFlag)
		{
			messageex(DebugUser,"[PROTECT TAG] Cannot find TAGS.TXT file.",print_console);
		}
	}
	return PLUGIN_HANDLED;
}

public  TagTrigger(Timer,WaitCount,RepeatCount,User) {
	new MyWONID;
	new UserIndex;
	new MyName[MAX_NAME_LENGTH];
	new searchIndex = 0;
	new Text[MAX_TEXT_LENGTH];
	new NameFound = 0;
	new TagFound = 0;
	new TagCommand = 0;

	convert_string(User, MyName, MAX_NAME_LENGTH);
	get_userindex(MyName, UserIndex);
	get_userWONID(MyName, MyWONID);

	/* Only continue if player has fully connected; WONID of 0 means they haven't */
	if ( MyWONID != 0 )
	{
		if (DebugFlag)
		{
			messageex(MyName,"[PROTECT TAG] AUTHENTICATING CLAN TAG...",print_console);
			printf ("%s",Text);
		}

		for ( searchIndex=1; searchIndex<=TotalTags; searchIndex++ )
		{
			if (TagType[searchIndex] == 0 )
			{
				if ( (strcasestr(MyName,ClanTag[searchIndex]) != -1) )
				{
					if (DebugFlag)
					{
						messageex(MyName,"^n[PROTECT TAG] TAG MATCH",print_console);
						snprintf(Text, MAX_TEXT_LENGTH, "^nsearchIndex: %i ClanTag: %s YourName: %s",searchIndex, ClanTag[searchIndex], MyName);
						messageex(MyName, Text, print_console);
					}

					if (MyWONID == strtonum(PlayerWonID[searchIndex]))
					{
						TagFound = 1;
						if (DebugFlag)
						{
							messageex(MyName,"AUTHENICATED",print_console);
							printf ("%s.^n",Text);
						}
						searchIndex=TotalTags+1;
					}
					else
					{
						TagFound = 2;
						if ( Command[searchIndex] > TagCommand )
						{
							TagCommand = Command[searchIndex];
						}
					}
				}
			}
		}
		if (DebugFlag)
		{
			if ( TagFound == 2 )
			{
				messageex(MyName, "FAILED TO AUTHENICATE",print_console);
				printf ("%s^n",Text);
			}

			if ( TagFound == 0 )
			{
				messageex(MyName, "DONE",print_console);
				printf ("%s^n",Text);
			}

			messageex(MyName,"[PROTECT TAG] AUTHENTICATING NAME...",print_console);
			printf ("%s",Text);
		}

		for ( searchIndex=1; searchIndex<=TotalTags; searchIndex++ )
		{
			if (TagType[searchIndex] == 1 )
			{
				if ( (strcasestr(MyName,ClanTag[searchIndex]) != -1) )
				{
					if (DebugFlag)
					{
						messageex(MyName,"^n[PROTECT TAG] NAME MATCH",print_console);
						snprintf(Text, MAX_TEXT_LENGTH, "^nsearchIndex: %i ClanTag: %s YourName: %s",searchIndex, ClanTag[searchIndex], MyName);
						messageex(MyName, Text, print_console);
					}

					if (MyWONID == strtonum(PlayerWonID[searchIndex]))
					{
						NameFound = 1;
						if (DebugFlag)
						{
							messageex(MyName,"AUTHENICATED",print_console);
							printf ("%s^n",Text);
						}
						searchIndex=TotalTags+1;
					}
					else
					{
						NameFound = 2;
						if ( Command[searchIndex] > TagCommand )
						{
							TagCommand = Command[searchIndex];
						}
					}
				}
			}
		}
		if (DebugFlag)
		{
			if ( NameFound == 2 )
			{
				messageex(MyName, "FAILED TO AUTHENICATE",print_console);
				printf ("%s^n",Text);
			}

			if ( NameFound == 0 )
			{
				messageex(MyName, "DONE",print_console);
				printf ("%s^n",Text);
			}
		}

		if ( (TagFound == 2) || (NameFound == 2) )
		{
			if ( TagCommand != 1 && TagCommand != 2 )
			{
				execclient(MyName, "name IMPOSTER");
			}
			if ( TagCommand == 1 )
			{
				kick(MyName);
			}
			if ( TagCommand == 2 )
			{
				ban(MyName,0);
			}
		}
		kill_timer(TagTimer[UserIndex]);
	}
	else
	{
		/* Repeat later when the player has hopefully finished connecting */
		if ( TagTimer[UserIndex] != 0 ) kill_timer(TagTimer[UserIndex]);
		TagTimer[UserIndex] = set_timer("TagTrigger",30,0,MyName);
	}
}




public plugin_connect(HLUserName, HLIP, UserIndex)
{
	new MyUserName[MAX_NAME_LENGTH];

	convert_string(HLUserName, MyUserName, MAX_NAME_LENGTH);

	if ( (UserIndex >= 1) && (UserIndex <= MAX_PLAYERS))
	{
		if ( TagTimer[UserIndex] != 0 ) kill_timer(TagTimer[UserIndex]);
		TagTimer[UserIndex] = set_timer("TagTrigger",30,0,MyUserName);

	}

	return PLUGIN_CONTINUE;
}

public plugin_disconnect(HLUserName, UserIndex) {
	if ( UserIndex >= 1 && UserIndex <= MAX_PLAYERS )
	{
		if ( TagTimer[UserIndex] != 0 ) kill_timer(TagTimer[UserIndex]);
	}

	return PLUGIN_CONTINUE;
}


public plugin_info(HLOldName,HLNewName,UserIndex)
{
	new Text[MAX_TEXT_LENGTH];
	new MyWONID;
	new NewName[MAX_NAME_LENGTH];
	new OldName[MAX_NAME_LENGTH];
	new NameFound = 0;
	new searchIndex = 0;
	new TagFound = 0;
	new TagCommand = 0;

	convert_string(HLNewName, NewName, MAX_NAME_LENGTH);
	convert_string(HLOldName, OldName, MAX_NAME_LENGTH);

	get_userWONID(OldName, MyWONID);

	/* Only bother if the name has changed. */
	if(streq(OldName,NewName)==0)
	{
		if (DebugFlag)
		{
			messageex(OldName,"[PROTECT TAG] YOUR NAME HAS CHANGED",print_console);
		}

		if ( (strcasestr(NewName,"IMPOSTER") != -1) )
		{
			return PLUGIN_CONTINUE;
		}

		if (DebugFlag)
		{
			messageex(OldName,"[PROTECT TAG] AUTHENTICATING CLAN TAG...",print_console);
			printf ("%s",Text);
		}

		for ( searchIndex=1; searchIndex<=TotalTags; searchIndex++ )
		{


			if (TagType[searchIndex] == 0 )
			{
				if ( (strcasestr(NewName,ClanTag[searchIndex]) != -1) )
				{
					if (DebugFlag)
					{
						messageex(OldName,"^n[PROTECT TAG] TAG MATCH",print_console);
						snprintf(Text, MAX_TEXT_LENGTH, "^nsearchIndex: %i ClanTag: %s YourName: %s",searchIndex, ClanTag[searchIndex], NewName);
						messageex(OldName, Text, print_chat);
					}

					if (MyWONID == strtonum(PlayerWonID[searchIndex]))
					{
						TagFound = 1;
						if (DebugFlag)
						{
							messageex(OldName,"AUTHENICATED",print_console);
							printf ("%s.^n",Text);
						}
						searchIndex=TotalTags+1;
					}
					else
					{
						TagFound = 2;
						if ( Command[searchIndex] > TagCommand )
						{
							TagCommand = Command[searchIndex];
						}
					}
				}
			}
		}

		if (DebugFlag)
		{
			if ( TagFound == 2 )
			{
				messageex(OldName, "FAILED TO AUTHENICATE",print_console);
				printf ("%s^n",Text);
			}

			if ( TagFound == 0 )
			{
				messageex(OldName, "DONE",print_console);
				printf ("%s^n",Text);
			}

			messageex(OldName,"[PROTECT TAG] AUTHENTICATING NAME...",print_console);
			printf ("%s",Text);
		}
		for ( searchIndex=1; searchIndex<=TotalTags; searchIndex++ )
		{
			if (TagType[searchIndex] == 1 )
			{
				if ( (strcasestr(NewName,ClanTag[searchIndex]) != -1) )
				{
					if (DebugFlag)
					{
						messageex(OldName,"^n[PROTECT TAG] NAME MATCH",print_console);
						snprintf(Text, MAX_TEXT_LENGTH, "^nsearchIndex: %i ClanTag: %s YourName: %s",searchIndex, ClanTag[searchIndex], NewName);
						messageex(OldName, Text, print_console);
					}

					if (MyWONID == strtonum(PlayerWonID[searchIndex]))
					{
						NameFound = 1;
						if (DebugFlag)
						{
							messageex(OldName,"AUTHENICATED",print_console);
							printf ("%s^n",Text);
						}
						searchIndex=TotalTags+1;
					}
					else
					{
						NameFound = 2;
						if ( Command[searchIndex] > TagCommand )
						{
							TagCommand = Command[searchIndex];
						}
					}
				}
			}
		}

		if (DebugFlag)
		{
			if ( NameFound == 2 )
			{
				messageex(OldName, "FAILED TO AUTHENICATE",print_console);
				printf ("%s^n",Text);
			}

			if ( NameFound == 0 )
			{
				messageex(OldName, "DONE",print_console);
				printf ("%s^n",Text);
			}
		}

		if ( (TagFound == 2) || (NameFound == 2) )
		{
			if ( TagCommand != 1 && TagCommand != 2 )
			{
				execclient(OldName, "name IMPOSTER");
			}
			if ( TagCommand == 1 )
			{
				kick(OldName);
			}
			if ( TagCommand == 2 )
			{
				ban(OldName,0);
			}
			return PLUGIN_HANDLED;
		}
	}
	return PLUGIN_CONTINUE;
}


public plugin_init()
{
	plugin_registerinfo("Protect Clan Tags Plugin", "Protect Clan Tags.", STRING_VERSION);
	plugin_registercmd("admin_loadtags", "load_tag_file", ACCESS_PROTECTTAG);
	plugin_registercmd("admin_tagdebug", "tag_debug",ACCESS_PROTECTTAG);
	load_tag_file();
	return PLUGIN_CONTINUE;
}
un die tags.txt angehängt:


Dateianhänge:
tags.txt [1.54 KiB]
249-mal heruntergeladen
Nach oben
   
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen  Auf das Thema antworten  [ 6 Beiträge ] 


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Powered by phpBB® Forum Software © phpBB Limited
Deutsche Übersetzung durch phpBB.de
Original Design von "[ Half-Life Admin Mod © Alfred Reynolds 2000-2003 ] - [ site design by Jägermeister ]"