[ create a new paste ] login | about

Link: http://codepad.org/kstJdsNT    [ raw code | fork ]

hurracane - C, pasted on Jan 16:
checkName()
{
	// player to check name on is self
	// if ignore_colours is set to true, you should not include the colours in the tag_to_filter var
	// script only 'supports' single and double colours, e.g. ^1 and ^^11
	// call the script for a player, e.g. 'if(player checkName())'
	// script will return true if the guy is wearing the tag and not a member
	// script will return false if the guy is a member or not wearing the tag
	
	tag_to_filter = "^^11[^^77LCTC^^11]";
	ignore_colours = true;
	
	// build a list of guids from cvar
	list_of_guids = [];
	for(i=0;i<99;i++)
		if(getCvar("memberguid_" + i) != "")
			list_of_guids[list_of_guids.size] = getCvar("memberguid_" + i);
	
	member = false;
	for(i=0;i<list_of_guids.size;i++)
		if(self getGuid() == list_of_guids[i])
			return false;
			
	name = self.name;
	newname = "";
	
	// filter out all colours
	if(ignore_colours)
	{
		for(char=0;char<name.size;char++)
		{
			// Check for single colours
			if((char != name.size-1 && char+1 != name.size-1) && (name[char] == "^"))
			{
				// The current character is not the last of second to last character
				// The current character is "^"
				
				// Determine wether it's a colour or not
				for(colour=0;colour<10;colour++) // smaller than 10 because it are the colours 0 to 9
					if(name[char+1] == colour)
						char++;
			}
			if((char != name.size-1 && char+1 != name.size-1) && (name[char] == "^" && name[char+1] == "^"))
			{
				// The current character is not the last of second to last character
				// The current character is "^" and the next character is "^" too
				
				// Determine wether it's a double colour or not
				if((char+2 != name.size-1))	// make sure the end of the name isn't reached
					for(colour=0;colour<10;colour++)
						if(name[char+2] == colour)
							for(colour2=0;colour2<10;colour2++)
								if((char+3 != name.size-1) && (char+3 <= name.size-1))
									if(name[char+3] == colour2)
										char += 3;
			}
			newname += name[char];
		}
	}
	else
		newname = name;
	
	if(isSubStr(newname, tag_to_filter))
		return true;
	else
		return false;
}
isSubStr(string, littlestring)
{
	if(littlestring.size > string.size)
		return false;

	for(i = 0; i < string.size - littlestring.size; i++)
	{
		if(getSubStr(string, i, littlestring.size) == littlestring)
			return true;
	}
	return false;
}
getSubStr(string, start, count)
{
	if(start + count > string.size)
	{
		iprintlnbold("getSubStr error");
		return "";
	}
	temp = "";
	for(i = start; i < start + count; i++)
		temp += string[i];
		
	return temp;
}


Create a new paste based on this one


Comments: