[HELP] Roleplay character name check function
#1

PHP код:
checkName(playeridname[]){
    new 
find strfind(name"_"false);
    if(
find == 0) return playerDialogs(playeridUSERNAMEINVALID_DIALOG), 0;
    for(new 
istrlen(name); ji++){
        if(
== find) continue; // skips '_' character from being checked
        
else if(== 0){
            if(
name[i] >= 'A' && name[i] <= 'Z') continue;
            else {
playerDialogs(playeridFIRSTNAMENOTCAP_DIALOG); break;}
        }else if(
== find+1){
            if(
name[i] >= 'A' && name[i] <= 'Z') continue;
            else {
playerDialogs(playeridLASTNAMENOTCAP_DIALOG); break;}
        }else{
            if(
name[i] >= 'a' && name[i] <= 'z') continue;
            else if(
name[i] >= && name[i] <= 9) {playerDialogs(playeridUSERNAMEHASNUMBER_DIALOG); break;}
            else {
playerDialogs(playeridUSERNAMESPECIALCHARS_DIALOG); break;}
        }
    }
    
inline characterCheck(){
        if(
cache_num_rows() != 0){
            
cache_get_value(0"password"playerData[playerid][password], MAX_PASSWORD);
            
cache_get_value(0"salt"playerData[playerid][salt], MAX_SALT);
            
playerDialogs(playeridLOGIN_DIALOG);
        }else{
            
playerDialogs(playeridREGISTER_DIALOG);
        }
    }
    new 
query[38 MAX_USERNAME 13];
    
mysql_format(dbquerysizeof query"SELECT * FROM %e WHERE username = '%e'",
    
USER_TABLEplayerData[playerid][username]);
    
mysql_tquery_inline(dbqueryusing inline characterCheck);
    return 
1;

Just need a clarification on this code if does this work or not, I can't try this yet since I'm not on proper pc.

I just need to check if :
Код:
the username can be checked with '_'
Код:
caps on both lastname and firstname which looks like this Ross_Weis
Код:
check if there are numbers
Код:
finally if there are special chars.
I will not say that this is mine but the idea was brought up from many and many name checks I've seen out there...

This is for my server and since I'm a security check freak... and a security perfectionist... I wish this fully working for my server...

Dislaimer:
I also have not searched the forum so much to see if this has been already been made or not...

the username has already been fetch on OnPlayerConnect so that's already not a problem...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)