Advertisement
Guest User

creating account command

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