Guest User

Untitled

a guest
Mar 16th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. // Include pretty much 90% of YSI in one fell swoop!
  2.  
  3. //#include "..\y_users"
  4. #include "..\y_inline"
  5.  
  6. #include <YSI\y_hooks>
  7. #include <YSI\y_dialog>
  8.  
  9. #define MAX_LOGIN_ATTEMPTS 4
  10.  
  11. loadtext core[ysi_players], core[ysi_extras], core[ysi_dialog];
  12.  
  13.  
  14. new pLoginAttempts[MAX_PLAYERS];
  15.  
  16. login(playerid)
  17. {
  18. pLoginAttempts[playerid]++;
  19. if(pLoginAttempts[playerid] == MAX_LOGIN_ATTEMPTS)
  20. {
  21. Kick(playerid);
  22. }
  23. else
  24. {
  25. if (Player_IsLoggedIn(playerid))
  26. {
  27. Text_Send(playerid, $YSI_LOGIN_ALREADY);
  28. return 1;
  29. }
  30.  
  31. inline Response(pid, dialogid, response, listitem, string:text0[])
  32. {
  33. #pragma unused pid, dialogid, listitem
  34. if (response)
  35. {
  36. if (isnull(text0))
  37. {
  38. login(playerid);
  39. return 1;
  40. }
  41. if(!Player_TryLogin(playerid, text0)) login(playerid);
  42. }
  43. else login(playerid);
  44. }
  45. Text_PasswordBox(playerid, using inline Response, $YSI_EXTRA_LOGIN_TITLE, $YSI_EXTRA_LOGIN_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
  46. }
  47. return 1;
  48. }
  49.  
  50.  
  51.  
  52. register(playerid)
  53. {
  54. pLoginAttempts[playerid]++;
  55. if(pLoginAttempts[playerid] == MAX_LOGIN_ATTEMPTS)
  56. {
  57. Kick(playerid);
  58. }
  59.  
  60. if (Player_IsLoggedIn(playerid))
  61. {
  62. Text_Send(playerid, $YSI_LOGIN_ALREADY);
  63. return 1;
  64. }
  65.  
  66. // Didn't type any text, ask for the password twice.
  67. inline Response1(pid1, dialogid1, response1, listitem1, string:text1[])
  68. {
  69. #pragma unused listitem1, dialogid1, pid1
  70. if (response1)
  71. {
  72. inline Response2(pid2, dialogid2, response2, listitem2, string:text2[])
  73. {
  74. #pragma unused listitem2, dialogid2, pid2
  75. if (response2)
  76. {
  77. if (strcmp(text1, text2) || (isnull(text1) || isnull(text2)))
  78. {
  79. Text_Send(playerid, $YSI_EXTRA_REGISTER_MISMATCH);
  80. register(playerid);
  81. }
  82. else
  83. {
  84. if(!Player_TryRegister(playerid, text2)) register(playerid);
  85. }
  86. }
  87. else register(playerid);
  88. }
  89. Text_PasswordBox(playerid, using inline Response2, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_CONFIRM_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
  90. }
  91. else register(playerid);
  92. }
  93. Text_PasswordBox(playerid, using inline Response1, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_REGISTER_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
  94. return 1;
  95. }
  96.  
  97. CMD:changepass(playerid, arg[])
  98. {
  99. inline Response1(pid1, dialogid1, response1, listitem1, string:text1[])
  100. {
  101. #pragma unused listitem1, dialogid1, pid1
  102. if (response1)
  103. {
  104. if(strlen(text1) < 6) SendClientMessage(playerid, STEALTH_YELLOW, "Password is too short!");
  105. else
  106. {
  107. inline Response2(pid2, dialogid2, response2, listitem2, string:text2[])
  108. {
  109. #pragma unused listitem2, dialogid2, pid2
  110. if (response2)
  111. {
  112. if (strcmp(text1, text2) || (isnull(text1) || isnull(text2))) SendClientMessage(playerid, STEALTH_YELLOW, "Passwords did not match please try again");
  113. else
  114. {
  115. SendClientMessage(playerid, STEALTH_GREEN, "Password has been changed!");
  116. Player_ChangePassword(playerid, text1);
  117. }
  118. }
  119. else SendClientMessage(playerid, STEALTH_YELLOW, "Cancelled changing password!");
  120. }
  121. Dialog_ShowCallback(playerid, using inline Response2, DIALOG_STYLE_PASSWORD, "Re-enter your new password", "New Password", "Ok", "Cancel");
  122. }
  123. }
  124. else SendClientMessage(playerid, STEALTH_YELLOW, "Cancelled changing password!");
  125. }
  126. Dialog_ShowCallback(playerid, using inline Response1, DIALOG_STYLE_PASSWORD, "Enter your new password", "New Password", "Ok", "Cancel");
  127. return 1;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment