Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include pretty much 90% of YSI in one fell swoop!
- //#include "..\y_users"
- #include "..\y_inline"
- #include <YSI\y_hooks>
- #include <YSI\y_dialog>
- #define MAX_LOGIN_ATTEMPTS 4
- loadtext core[ysi_players], core[ysi_extras], core[ysi_dialog];
- new pLoginAttempts[MAX_PLAYERS];
- login(playerid)
- {
- pLoginAttempts[playerid]++;
- if(pLoginAttempts[playerid] == MAX_LOGIN_ATTEMPTS)
- {
- Kick(playerid);
- }
- else
- {
- if (Player_IsLoggedIn(playerid))
- {
- Text_Send(playerid, $YSI_LOGIN_ALREADY);
- return 1;
- }
- inline Response(pid, dialogid, response, listitem, string:text0[])
- {
- #pragma unused pid, dialogid, listitem
- if (response)
- {
- if (isnull(text0))
- {
- login(playerid);
- return 1;
- }
- if(!Player_TryLogin(playerid, text0)) login(playerid);
- }
- else login(playerid);
- }
- Text_PasswordBox(playerid, using inline Response, $YSI_EXTRA_LOGIN_TITLE, $YSI_EXTRA_LOGIN_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
- }
- return 1;
- }
- register(playerid)
- {
- pLoginAttempts[playerid]++;
- if(pLoginAttempts[playerid] == MAX_LOGIN_ATTEMPTS)
- {
- Kick(playerid);
- }
- if (Player_IsLoggedIn(playerid))
- {
- Text_Send(playerid, $YSI_LOGIN_ALREADY);
- return 1;
- }
- // Didn't type any text, ask for the password twice.
- inline Response1(pid1, dialogid1, response1, listitem1, string:text1[])
- {
- #pragma unused listitem1, dialogid1, pid1
- if (response1)
- {
- inline Response2(pid2, dialogid2, response2, listitem2, string:text2[])
- {
- #pragma unused listitem2, dialogid2, pid2
- if (response2)
- {
- if (strcmp(text1, text2) || (isnull(text1) || isnull(text2)))
- {
- Text_Send(playerid, $YSI_EXTRA_REGISTER_MISMATCH);
- register(playerid);
- }
- else
- {
- if(!Player_TryRegister(playerid, text2)) register(playerid);
- }
- }
- else register(playerid);
- }
- Text_PasswordBox(playerid, using inline Response2, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_CONFIRM_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
- }
- else register(playerid);
- }
- Text_PasswordBox(playerid, using inline Response1, $YSI_EXTRA_REGISTER_TITLE, $YSI_EXTRA_REGISTER_PROMPT, $DIALOG_OK, $DIALOG_CANCEL);
- return 1;
- }
- CMD:changepass(playerid, arg[])
- {
- inline Response1(pid1, dialogid1, response1, listitem1, string:text1[])
- {
- #pragma unused listitem1, dialogid1, pid1
- if (response1)
- {
- if(strlen(text1) < 6) SendClientMessage(playerid, STEALTH_YELLOW, "Password is too short!");
- else
- {
- inline Response2(pid2, dialogid2, response2, listitem2, string:text2[])
- {
- #pragma unused listitem2, dialogid2, pid2
- if (response2)
- {
- if (strcmp(text1, text2) || (isnull(text1) || isnull(text2))) SendClientMessage(playerid, STEALTH_YELLOW, "Passwords did not match please try again");
- else
- {
- SendClientMessage(playerid, STEALTH_GREEN, "Password has been changed!");
- Player_ChangePassword(playerid, text1);
- }
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "Cancelled changing password!");
- }
- Dialog_ShowCallback(playerid, using inline Response2, DIALOG_STYLE_PASSWORD, "Re-enter your new password", "New Password", "Ok", "Cancel");
- }
- }
- else SendClientMessage(playerid, STEALTH_YELLOW, "Cancelled changing password!");
- }
- Dialog_ShowCallback(playerid, using inline Response1, DIALOG_STYLE_PASSWORD, "Enter your new password", "New Password", "Ok", "Cancel");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment