Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_ini>
- #define MAILER_URL "phphoster09.comyr.com/mailer.php" // This has to be defined BEFORE you include mailer. CUSTOM
- #include <mailer>
- native WP_Hash(buffer[], len, const str[]);
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- #define DIALOG_SUCCESS_1 3
- #define DIALOG_SUCCESS_2 4
- #define DIALOG_PASS 5
- #define DIALOG_MAIL 6
- #define PATH "/User/%s.ini"
- #define COL_WHITE "{FFFFFF}"
- #define COL_RED "{F81414}"
- #define COL_GREEN "{00FF22}"
- #define COL_LIGHTBLUE "{00CED1}"
- #define COLOR_RED 0xFF0000FF
- #define SCM SendClientMessage
- #define SCMTA SendClientMessageToAll
- enum pInfo
- {
- pPass[129],
- pCash,
- pAdmin,
- pKills,
- pDeaths,
- pScore,
- pJailed,
- pBanned,
- pWarn,
- pMail[300],
- pSPass,
- pCMail,
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_String("Password",PlayerInfo[playerid][pPass], 129);
- INI_Int("Cash",PlayerInfo[playerid][pCash]);
- INI_Int("Admin Level",PlayerInfo[playerid][pAdmin]);
- INI_Int("Kills",PlayerInfo[playerid][pKills]);
- INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
- INI_Int("Score",PlayerInfo[playerid][pScore]);
- INI_Int("IsJailed",PlayerInfo[playerid][pJailed]);
- INI_Int("IsBanned",PlayerInfo[playerid][pBanned]);
- INI_Int("Warnings",PlayerInfo[playerid][pWarn]);
- INI_Int("SecondPass",PlayerInfo[playerid][pSPass]);
- INI_String("Mail",PlayerInfo[playerid][pMail], 300);
- INI_Int("Email Check",PlayerInfo[playerid][pCMail]);
- return 1;
- }
- forward KickPublic(playerid);
- public KickPublic(playerid) { Kick(playerid); }
- stock KickWithMessage(playerid, message[])
- {
- SendClientMessage(playerid,COLOR_RED, message);
- SetTimerEx("KickPublic", 1000, 0, "d", playerid); //Delay of 1 second before kicking the player so he recieves the message
- }
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
- stock AutoSave(playerid)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerData");
- INI_WriteString(File, "Password", PlayerInfo[playerid][pPass]);
- INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
- INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
- INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
- INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
- INI_WriteInt(File,"Score",GetPlayerScore(playerid));
- INI_WriteInt(File,"IsJailed",PlayerInfo[playerid][pJailed]);
- INI_WriteInt(File,"IsBanned",PlayerInfo[playerid][pBanned]);
- INI_WriteInt(File,"Warnings",PlayerInfo[playerid][pWarn]);
- INI_WriteInt(File,"SecondPass",PlayerInfo[playerid][pSPass]);
- INI_WriteString(File, "Mail", PlayerInfo[playerid][pMail]);
- INI_WriteInt(File,"Email Check",PlayerInfo[playerid][pCMail]);
- INI_Close(File);
- return 1;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Advanced Register System By Rockhopper");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
- if(PlayerInfo[playerid][pBanned] >= 1)
- {
- KickWithMessage(playerid,"You are banned from the server!!");
- return 0;
- }
- else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Forgot Pass");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerData");
- INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
- INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
- INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
- INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
- INI_WriteInt(File,"Score",GetPlayerScore(playerid));
- INI_WriteInt(File,"IsJailed",PlayerInfo[playerid][pJailed]);
- INI_WriteInt(File,"IsBanned",PlayerInfo[playerid][pBanned]);
- INI_WriteInt(File,"Warnings",PlayerInfo[playerid][pWarn]);
- INI_WriteInt(File,"SecondPass",PlayerInfo[playerid][pSPass]);
- INI_WriteString(File, "Mail", PlayerInfo[playerid][pMail]);
- INI_WriteInt(File,"Email Check",PlayerInfo[playerid][pCMail]);
- INI_Close(File);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- PlayerInfo[killerid][pKills]++;
- PlayerInfo[playerid][pDeaths]++;
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch( dialogid )
- {
- case DIALOG_REGISTER:
- {
- if (!response) return Kick(playerid);
- if(response)
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Making your account ..",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerData");
- new HashPass[129];
- WP_Hash(HashPass, sizeof(HashPass), inputtext);
- INI_WriteString(File, "Password", HashPass);
- INI_WriteInt(File,"Cash",0);
- INI_WriteInt(File,"Admin",-1);
- INI_WriteInt(File,"Kills",0);
- INI_WriteInt(File,"Deaths",0);
- INI_WriteInt(File,"Score",0);
- INI_WriteInt(File,"IsJailed",0);
- INI_WriteInt(File,"IsBanned",0);
- INI_WriteInt(File,"Warnings",0);
- PlayerInfo[playerid][pSPass] = 100*random(10) + random(10) + random(10);
- INI_Close(File);
- ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Account created!",""COL_GREEN"You've created an account successfuly. ","Ok","");
- ShowPlayerDialog(playerid, DIALOG_MAIL, DIALOG_STYLE_INPUT, ""COL_WHITE"Setting up Mail",""COL_WHITE"Type your email ID for password recovery purposes \n You can't enter it later and if lost your password it \n can't be recovered ","Set","Abort");
- }
- }
- case DIALOG_LOGIN:
- {
- if ( !response ) {
- if(PlayerInfo[playerid][pCMail] < 1)
- {
- SCM(playerid,COLOR_RED,"You didn't set up your email now you can't login using the recovery system.. Account will be deleted within 30 days ");
- KickWithMessage(playerid,"This is the result of not setting up your email on time ");
- }
- else {
- new tm[300];
- format(tm, 300, PlayerInfo[playerid][pMail]);
- new str[500];//CUSTIOM ||
- format(str, sizeof(str),"Hello welcome to the Password Recovery System Please Follow Below to reset your password. The following is your PIN. Using this PIN you can reset your password immedeaitly ! PIN :- %d . You need to login with your PIN Then you will be able to change your password immediately! Go Soon ! ",PlayerInfo[playerid][pSPass]);
- SendMail( tm, "sampaccountsys@phphoster09.comyr.com", "Server System", "Password Recovery", str );
- KickWithMessage(playerid,"We have sent you an email.. Please follow the instructions there. If it hasn't come try again or Contact an Admin!");
- }
- }
- else if( response )
- {
- new HashPass[129];
- WP_Hash(HashPass, sizeof(HashPass), inputtext);
- if(strcmp(HashPass, PlayerInfo[playerid][pPass]) == 0)
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
- GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
- SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
- ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
- if(PlayerInfo[playerid][pCMail] < 1)
- {
- SCM(playerid,COLOR_RED,"You haven't registered your Mail Please do it Now ! ");
- ShowPlayerDialog(playerid, DIALOG_MAIL, DIALOG_STYLE_INPUT, ""COL_WHITE"Setting up Mail",""COL_WHITE"Type your email ID for password recovery purposes \n You can't enter it later and if lost your password it \n can't be recovered ","Set","Abort");
- }
- }
- else if(strval(inputtext) == PlayerInfo[playerid][pSPass])
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
- GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
- SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
- ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Change your pass",""COL_RED"We have detected that you have logged in using you PIN So please change your password ","Ok","");
- ShowPlayerDialog(playerid, DIALOG_PASS, DIALOG_STYLE_PASSWORD,""COL_WHITE"Recovering...",""COL_WHITE"Type your new password below ..","Change","Quit");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Forgot Pass");
- }
- return 1;
- }
- }
- case DIALOG_PASS:
- {
- if (!response) return Kick(playerid);
- if(response)
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_PASS, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Changing Your Pass..",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your new password yo chnage it.","Change","Quit");
- INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
- GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
- SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
- SCM(playerid,COLOR_RED,"You have sucessfully saved your new password !");
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerData");
- new HashPass[129];
- WP_Hash(HashPass, sizeof(HashPass), inputtext);
- INI_WriteString(File, "Password", HashPass);
- PlayerInfo[playerid][pSPass] = 100*random(10) + random(10) + random(10);
- INI_Close(File);
- ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Account created!",""COL_GREEN"You've changed your password successfuly. ","Ok","");
- }
- }
- case DIALOG_MAIL:
- {
- if(!response){
- SCM(playerid,COLOR_RED,"You will be asked on your next login to set it..If you won't its your bad ... ");
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerData");
- PlayerInfo[playerid][pCMail] = 0;
- return 1;
- }
- if(response)
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_MAIL, DIALOG_STYLE_INPUT, ""COL_WHITE"Setting up Mail","Type a Valid Email Address \n"COL_WHITE"Type your email ID for password recovery purposes \n You can't enter it later and if lost your password it \n can't be recovered ","Set","Abort");
- format(PlayerInfo[playerid][pMail], 300, inputtext);
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"PlayerData");
- PlayerInfo[playerid][pCMail] = 1;
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement