new NewName[2][MAX_PLAYER_NAME];
split(PlayerName(playerid),NewName,'_');
toupper(NewName[0][1]);
toupper(NewName[1][1]);
format(string,sizeof(string),"%s_%s",NewName[0],NewName[1]);
SetPlayerName(playerid,string);
native toupper(c);
toupper(NewName[0][1]);
pawn Код:
|
new NewName[2][MAX_PLAYER_NAME];
split(PlayerName(playerid),NewName,'_');
printf("%s_%s",NewName[0],NewName[1]);
new pos;
pos = strfind(PlayerName(playerid),NewName[1]);
printf("%s_%s",NewName[0],NewName[1]);
format(string,sizeof(string),"%s_%s",NewName[0],NewName[1]);
new letter1[10];
format(letter1,10,"%s",toupper(NewName[0][0]));
new letter2[10];
format(letter2,10,"%s",toupper(NewName[1][0]));
strdel(string,0,0);
strins(string,letter1,0,24);
strdel(string,pos,pos);
strins(string,letter2,pos,24);
SetPlayerName(playerid,string);
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(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(IsUpper(name[sz-1])) return 1;
if(IsUpper(name[FirstSeperationLoc(name[0])-1])) return 1;
return 0;
}
ConsecutiveCaps(name[])
{
new sz,lastcaps;
sz=strlen(name[0]);
while(sz--) {
if(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(!IsUpper(str[0])||!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;
}
#define toupper(%0) \
(((%0) >= 'a' && (%0) <= 'z') ? ((%0) & ~0x20) : (%0))
#define tolower(%0) \
(((%0) >= 'A' && (%0) <= 'Z') ? ((%0) | 0x20) : (%0))
pawn Код:
|
toupper(NewName[0][0]);
toupper(NewName[1][0]);
C:\Users\Connor\Dropbox\RC6\gamemodes\wl-rp.pwn(3957) : warning 215: expression has no effect C:\Users\Connor\Dropbox\RC6\gamemodes\wl-rp.pwn(3958) : warning 215: expression has no effect Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 2 Warnings.