y_extra_users.inc 2.4 KB

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