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;
- }
- //=============================================================
- // arrays
- //=============================================================
- setarray .@capitals$,"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";
- setarray .@small$,"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";
- setarray .@numbers$,1,2,3,4,5,6,7,8,9,10;
- //=============================================================
- // variables
- //=============================================================
- .@userid$ = .@atcmd_parameters$[0];
- .@pass$ = .@atcmd_parameters$[1];
- .@sex$ = strtoupper(.@atcmd_parameters$[2]);
- .@email$ = "a@a.com";
- .@cap = getarraysize(.@capitals$);
- .@small = getarraysize(.@small$);
- .@num = getarraysize(.@small$);
- .@i = getstrlen(.@userid$);
- .@j = getstrlen(.@pass$);
- //=============================================================
- // on checking username's length
- //=============================================================
- 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++) {
- for(.@a =0; .@a <=.@cap); .@a++){
- if(charat(.@userid$,.@x) ==.@capitals[.@a]) goto PASS;
- }
- for(.@b =0; .@b <=.@small); .@b++){
- if(charat(.@userid$,.@x) ==.@small[.@b]) goto PASS;
- }
- for(.@c =0; .@c <=.@num); .@c++){
- if(charat(.@userid$,.@x) ==.@numbers[.@c]) goto PASS;
- }
- dispbottom "username should be alphanumeric",0xFF0000;
- end;
- 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
- //=============================================================
- 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++) {
- for(.@d =0; .@d <=.@cap); .@d++){
- if(charat(.@pass$,.@k) ==.@capitals[.@d]) goto PROCEED;
- }
- for(.@e =0; .@e <=.@small); .@e++){
- if(charat(.@pass$,.@k) ==.@small[.@e]) goto PROCEED;
- }
- for(.@f =0; .@f <=.@num); .@f++){
- if(charat(.@pass$,.@k) ==.@numbers[.@f]) goto PROCEED;
- }
- dispbottom "password should be alphanumeric",0xFF0000;
- end;
- PROCEED:
- }
- //=============================================================
- // on checking gender's account
- //=============================================================
- if( (.@sex$ !="M")||(.@sex$!="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