Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================
- - script UserCreate -1,{
- OnCreateUser:
- //=============================================================
- // not available for normal players
- //=============================================================
- if(getgmlevel()==0) end;
- //=============================================================
- // on checking parameters
- //=============================================================
- if(getarraysize(.@atcmd_parameters$) < 3 && getarraysize(.@atcmd_parameters$) > 3) {
- dispbottom "Invalid syntax. Usage: @acreate <Username> <Password> <M/F>",0xFF0000;
- end;
- }
- //=============================================================
- // variables
- //=============================================================
- .@userid$ = .@atcmd_parameters$[0];
- .@pass$ = .@atcmd_parameters$[1];
- .@sex$ = strtoupper(.@atcmd_parameters$[2]);
- .@email$ = "a@a.com";
- //=============================================================
- // on checking username's length
- //=============================================================
- .@i = getstrlen(.@userid$);
- if(.@i<4||.@i>23){
- dispbottom "username must be more than 4 and not more than 23 characters length",0xFF0000;
- end;
- }
- //=============================================================
- // on checking username's letter's applicability
- //=============================================================
- for (.@x = 0; .@x <= .@i; .@x++) {
- //capital letters
- if(charat(.@userid$,.@x)!= ('A'||'B'||'C'||'D'||'E'||'F'||'G'||'H'||'I'||'J'||'K'||'L'||'M'||'N'||'O'||'P'||'Q'||'R'||'S'||'T'||'U'||'V'||'W'||'X'||'Y'||'Z')){
- //small letters
- if(charat(.@userid$,.@x)!= ('a'||'b'||'c'||'d'||'e'||'f'||'g'||'h'||'i'||'j'||'k'||'l'||'m'||'n'||'o'||'p'||'q'||'r'||'s'||'t'||'u'||'v'||'w'||'x'||'y'||'z')){
- //numbers
- if(charat(.@userid$,.@x)!= (1||2||3||4||5||6||7||8||9||0)){
- dispbottom "username should be alphanumeric"0xFF0000;
- end;
- }
- else goto PASS;
- }
- else goto PASS;
- }
- PASS:
- }
- //=============================================================
- // on checking username's existence
- //=============================================================
- query_sql( "SELECT `account_id` FROM `login` WHERE `userid` = '"+.@userid$+"' LIMIT 1",.@limit );
- if ( .@limit > 0 ) {
- dispbottom "username already exist!",0xFF0000;
- end;
- }
- //=============================================================
- // on checking password's length
- //=============================================================
- .@j = getstrlen(.@pass$);
- if(.@j<4||.@j>23){
- dispbottom "password must be more than 4 and not more than 23 characters length",0xFF0000;
- end;
- }
- //=============================================================
- // on checking password's letter's applicability
- //=============================================================
- for (.@k = 0; .@k <= .@j; .@k++) {
- //capital letters
- if(charat(.@pass$,.@k)!= ('A'||'B'||'C'||'D'||'E'||'F'||'G'||'H'||'I'||'J'||'K'||'L'||'M'||'N'||'O'||'P'||'Q'||'R'||'S'||'T'||'U'||'V'||'W'||'X'||'Y'||'Z')){
- //small letters
- if(charat(.@pass$,.@k)!= ('a'||'b'||'c'||'d'||'e'||'f'||'g'||'h'||'i'||'j'||'k'||'l'||'m'||'n'||'o'||'p'||'q'||'r'||'s'||'t'||'u'||'v'||'w'||'x'||'y'||'z')){
- //numbers
- if(charat(.@pass$,.@k)!= (1||2||3||4||5||6||7||8||9||0)){
- dispbottom "password should be alphanumeric"0xFF0000;
- end;
- }
- else goto PROCEED;
- }
- else goto PROCEED;
- }
- PROCEED:
- }
- //=============================================================
- // on checking gender's account
- //=============================================================
- if( .@sex$ != ('M'||'F')){
- dispbottom ""+ .@sex$ +" is not a gender we can use..",0xFF0000;
- end;
- }
- //=============================================================
- // on process of creating
- //=============================================================
- dispbottom "Attempting to create account.";
- query_sql("INSERT INTO `login` (`userid`, `user_pass`, `sex`, `email`) VALUES ('"+ .@user$ +"', '"+ .@pass$ +"', '"+ .@sex$ +"', '"+ .@email$ +"')");
- dispbottom "Account created";
- OnInit:
- bindatcmd("acreate",strnpcinfo(3)+"::OnCreateUser");
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement