SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/03/2019, 11:31 AM   #1
JesterlJoker
Huge Clucker
 
Join Date: Apr 2015
Location: Cagayan de Oro, Philippines
Posts: 273
Reputation: 27
Default [HELP] Roleplay character name check function

PHP Code:
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 :
Code:
the username can be checked with '_'
Code:
caps on both lastname and firstname which looks like this Ross_Weis
Code:
check if there are numbers
Code:
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...
__________________
Github: AtraXaz
Website: SynTacs
How about Buying Me a Coffee?
JesterlJoker is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if you are online, spawn character. SukMathcuck Scripting Help 5 12/12/2016 11:24 PM
How do you like to roleplay your character? DarkLored Everything and Nothing 14 08/05/2014 02:43 PM
how to check a certain character horsemeat Scripting Help 2 16/06/2013 02:19 PM
function only returning first character of string thefatshizms Scripting Help 4 03/03/2013 03:24 PM
How to check if a character is last in line? Riddick94 Scripting Help 4 04/08/2012 06:36 PM


All times are GMT. The time now is 08:21 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.