y_extra_users.inc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Include pretty much 90% of YSI in one fell swoop!
  2. //#include "..\y_users"
  3. #include "..\y_inline"
  4. loadtext core[ysi_players], core[ysi_extras], core[ysi_dialog];
  5. YCMD:login(playerid, params[], help)
  6. {
  7. if (help)
  8. {
  9. Text_Send(playerid, $YSI_LOGIN_HELP);
  10. }
  11. else
  12. {
  13. if (Player_IsLoggedIn(playerid))
  14. {
  15. Text_Send(playerid, $YSI_LOGIN_ALREADY);
  16. return 1;
  17. }
  18. if (!isnull(params))
  19. {
  20. Player_TryLogin(playerid, params);
  21. return 1;
  22. }
  23. inline Response(pid, dialogid, response, listitem, string:text0[])
  24. {
  25. #pragma unused pid, dialogid, listitem
  26. if (response)
  27. {
  28. Player_TryLogin(playerid, text0);
  29. }
  30. }
  31. Text_PasswordBox(playerid, using inline Response, $YSI_EXTRA_LOGIN_TITLE, $YSI_EXTRA_LOGIN_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
  32. }
  33. return 1;
  34. }
  35. YCMD:register(playerid, params[], help)
  36. {
  37. if (help)
  38. {
  39. Text_Send(playerid, $YSI_REGISTER_HELP);
  40. }
  41. else
  42. {
  43. if (Player_IsLoggedIn(playerid))
  44. {
  45. Text_Send(playerid, $YSI_LOGIN_ALREADY);
  46. return 1;
  47. }
  48. new
  49. pass[32];
  50. if (!isnull(params))
  51. {
  52. // Store the password localy in the function.
  53. strcpy(pass, params);
  54. inline Response2(pid2, dialogid2, response2, listitem2, string:text2[])
  55. {
  56. #pragma unused listitem2, dialogid2, pid2
  57. if (response2)
  58. {
  59. if (strcmp(pass, text2))
  60. {
  61. Text_Send(playerid, $YSI_EXTRA_REGISTER_MISMATCH);
  62. }
  63. else
  64. {
  65. Player_TryRegister(playerid, text2);
  66. }
  67. }
  68. }
  69. Text_PasswordBox(playerid, using inline Response2, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_CONFIRM_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
  70. return 1;
  71. }
  72. // Didn't type any text, ask for the password twice.
  73. inline Response1(pid1, dialogid1, response1, listitem1, string:text1[])
  74. {
  75. #pragma unused listitem1, dialogid1, pid1
  76. if (response1)
  77. {
  78. inline Response2(pid2, dialogid2, response2, listitem2, string:text2[])
  79. {
  80. #pragma unused listitem2, dialogid2, pid2
  81. if (response2)
  82. {
  83. if (strcmp(text1, text2))
  84. {
  85. Text_Send(playerid, $YSI_EXTRA_REGISTER_MISMATCH);
  86. }
  87. else
  88. {
  89. Player_TryRegister(playerid, text2);
  90. }
  91. }
  92. }
  93. Text_PasswordBox(playerid, using inline Response2, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_CONFIRM_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
  94. }
  95. }
  96. Text_PasswordBox(playerid, using inline Response1, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_REGISTER_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
  97. }
  98. return 1;
  99. }