Erm i need help please! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Erm i need help please! (
/showthread.php?tid=131609)
Erm i need help please! -
Saurik - 04.03.2010
Hey guyz.
I need a tag kicker that kicks names with numbers or other symbols,,
This includes:
[SDA]Namehere
Nameher2034
Re: Erm i need help please! -
CHC - 04.03.2010
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