Advertisement
Guest User

creating account command

a guest
Nov 15th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1.  
  2. //=============================================================
  3. - script UserCreate -1,{
  4.  
  5. OnCreateUser:
  6. //=============================================================
  7. // not available for normal players
  8. //=============================================================
  9. if(getgmlevel()==0) end;
  10. //=============================================================
  11. // on checking parameters
  12. //=============================================================
  13. if(getarraysize(.@atcmd_parameters$) < 3 && getarraysize(.@atcmd_parameters$) > 3) {
  14. dispbottom "Invalid syntax. Usage: @acreate <Username> <Password> <M/F>",0xFF0000;
  15. end;
  16. }
  17. //=============================================================
  18. // arrays
  19. //=============================================================
  20. 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";
  21. 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";
  22. setarray .@numbers$,1,2,3,4,5,6,7,8,9,10;
  23. //=============================================================
  24. // variables
  25. //=============================================================
  26. .@userid$ = .@atcmd_parameters$[0];
  27. .@pass$ = .@atcmd_parameters$[1];
  28. .@sex$ = strtoupper(.@atcmd_parameters$[2]);
  29. .@email$ = "a@a.com";
  30. .@cap = getarraysize(.@capitals$);
  31. .@small = getarraysize(.@small$);
  32. .@num = getarraysize(.@small$);
  33. .@i = getstrlen(.@userid$);
  34. .@j = getstrlen(.@pass$);
  35. //=============================================================
  36. // on checking username's length
  37. //=============================================================
  38. if(.@i<4||.@i>23){
  39. dispbottom "username must be more than 4 and not more than 23 characters length",0xFF0000;
  40. end;
  41. }
  42. //=============================================================
  43. // on checking username's letter's applicability
  44. //=============================================================
  45. for (.@x = 0; .@x <= .@i; .@x++) {
  46. for(.@a =0; .@a <=.@cap); .@a++){
  47. if(charat(.@userid$,.@x) ==.@capitals[.@a]) goto PASS;
  48. }
  49. for(.@b =0; .@b <=.@small); .@b++){
  50. if(charat(.@userid$,.@x) ==.@small[.@b]) goto PASS;
  51. }
  52. for(.@c =0; .@c <=.@num); .@c++){
  53. if(charat(.@userid$,.@x) ==.@numbers[.@c]) goto PASS;
  54. }
  55. dispbottom "username should be alphanumeric",0xFF0000;
  56. end;
  57. PASS:
  58. }
  59.  
  60. //=============================================================
  61. // on checking username's existence
  62. //=============================================================
  63. query_sql( "SELECT `account_id` FROM `login` WHERE `userid` = '"+.@userid$+"' LIMIT 1",.@limit );
  64. if ( .@limit > 0 ) {
  65. dispbottom "username already exist!",0xFF0000;
  66. end;
  67. }
  68. //=============================================================
  69. // on checking password's length
  70. //=============================================================
  71. if(.@j<4||.@j>23){
  72. dispbottom "password must be more than 4 and not more than 23 characters length",0xFF0000;
  73. end;
  74. }
  75. //=============================================================
  76. // on checking password's letter's applicability
  77. //=============================================================
  78. for (.@k = 0; .@k <= .@j; .@k++) {
  79. for(.@d =0; .@d <=.@cap); .@d++){
  80. if(charat(.@pass$,.@k) ==.@capitals[.@d]) goto PROCEED;
  81. }
  82. for(.@e =0; .@e <=.@small); .@e++){
  83. if(charat(.@pass$,.@k) ==.@small[.@e]) goto PROCEED;
  84. }
  85. for(.@f =0; .@f <=.@num); .@f++){
  86. if(charat(.@pass$,.@k) ==.@numbers[.@f]) goto PROCEED;
  87. }
  88. dispbottom "password should be alphanumeric",0xFF0000;
  89. end;
  90.  
  91. PROCEED:
  92. }
  93. //=============================================================
  94. // on checking gender's account
  95. //=============================================================
  96. if( (.@sex$ !="M")||(.@sex$!="F")){
  97. dispbottom ""+ .@sex$ +" is not a gender we can use..",0xFF0000;
  98. end;
  99. }
  100. //=============================================================
  101. // on process of creating
  102. //=============================================================
  103. dispbottom "Attempting to create account.";
  104. query_sql("INSERT INTO `login` (`userid`, `user_pass`, `sex`, `email`) VALUES ('"+ .@user$ +"', '"+ .@pass$ +"', '"+ .@sex$ +"', '"+ .@email$ +"')");
  105. dispbottom "Account created";
  106.  
  107. OnInit:
  108. bindatcmd("acreate",strnpcinfo(3)+"::OnCreateUser");
  109. end;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement