Advertisement
Guest User

creating account command

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