Erm i need help please!
#1

Hey guyz.

I need a tag kicker that kicks names with numbers or other symbols,,
This includes:


[SDA]Namehere
Nameher2034
Reply
#2

heres some code i made for a rp server, that detects if the name is rp or not, maybe it can assist

Код:
CHC_IsUpper(ch)
{
  if(ch>64&&ch<91) return 1;
  return 0;
}

TooManyCaps(name[])
{
  new Float:caps,num,sz;
  sz=strlen(name[0]);
  while(sz--) {
  if(CHC_IsUpper(name[sz])) num++;
  }
  caps=floatdiv(num,float(strlen(name[0])-1)); //-1 because we don't include the _ in the percentage
  caps=floatmul(caps,float(100));
  if(caps>40) return 1; //40% seems to be the magic number for names
  return 0;
}

CapsOnEnd(name[])
{
  new sz;
  sz=strlen(name[0]);
  if(CHC_IsUpper(name[sz-1])) return 1;
  if(CHC_IsUpper(name[FirstSeperationLoc(name[0])-1])) return 1;
  return 0;
}

ConsecutiveCaps(name[])
{
  new sz,lastcaps;
  sz=strlen(name[0]);
  while(sz--) {
  if(CHC_IsUpper(name[sz])) {
  if(lastcaps==1) {
  return 1;
  }
  lastcaps=1;
  } else lastcaps=0;
  }
  return 0;
}

TooShortOnEnd(name[])
{
  new pnt;
  pnt=FirstSeperationLoc(name[0]);
  name[pnt]=0;
  if((strlen(name[0])<3)||strlen(name[pnt+1])<3) {
  name[pnt]='_'; //restore it for use later
	return 1;
	 }
  name[pnt]='_';
  return 0;
}

NumOccurences(str[],ch)
{
  new num=0,strl;
  strl=strlen(str);
  while(strl--) {
  if(str[strl]==ch) num++;
  }
  return num;
}

IsInvalid(x)
{
  if(x==95) return 0;
  if(x>64&&x<91) return 0;
  if(x>96&&x<123) return 0;
  return 1;
}

FirstSeperationLoc(str[])
{
  new strl;
  strl=strlen(str);
  while(strl--) {
  if(str[strl]=='_') return strl;
  }
  return 0;
}

InvalidCaps(str[])
{
  if(!CHC_IsUpper(str[0])||!CHC_IsUpper(str[FirstSeperationLoc(str[0])+1])) return 1;
  return 0;
}

NameIsRP(name[])
{
  new len;
  len=strlen(name[0]);
  if(InvalidCaps(name[0]) || NumOccurences(name[0],'_') != 1) return 0;
  while(len--) {
  if(IsInvalid(name[len])) return 0;
  }
  if(TooManyCaps(name[0])) return 0;
  if(ConsecutiveCaps(name[0])) return 0;
  if(CapsOnEnd(name[0])) return 0;
  if(TooShortOnEnd(name[0])) return 0;
  return 1;
}
Simply call this function in OnPlayerConnect, and kick them if the name isn't rp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)