Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- forward @LoadUserData(playerid, name[], value[]);
- public OnPlayerConnect(playerid)
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- if(!fexist(UserPath(playerid)))
- {
- // registered
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Account", "Register account\n\nEnter a password", "Register", "Quit");
- }
- else
- {
- // login
- INI_ParseFile(UserPath(playerid), "LoadUserData_%s", .bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account", "Login to your account\n\nEnter your password", "Login", "Quit");
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case 1:
- {
- if(!response)
- {
- Kick(playerid);
- }
- else
- {
- new INI:File = INI_Open(UserPath(playerid)), buf[129];
- WP_Hash(buf, sizeof(buf), inputtext);
- INI_SetTag(File,"Data");
- INI_WriteString(File, "Password", buf);
- INI_WriteInt(File, "Kills", 0);
- INI_WriteInt(File, "Deaths", 0);
- INI_Close(File);
- SendClientMessage(playerid, Green, "Registered");
- }
- }
- case 2:
- {
- if(!response)
- {
- Kick(playerid);
- }
- else
- {
- new buf[129];
- WP_Hash(buf, sizeof (buf), inputtext);
- if(!strcmp(buf, PlayerInfo[playerid][pPassword]))
- {
- INI_ParseFile(UserPath(playerid), "LoadUserData_%s", .bExtra = true, .extra = playerid);
- SendClientMessage(playerid, Green, "Logged in");
- }
- else
- {
- SendClientMessage(playerid, Red, "Wrong password);
- }
- return 1;
- }
- }
- }
- return 1;
- }
- @LoadUserData(playerid, name[], value[])
- {
- INI_String("Password", PlayerInfo[playerid][pPassword], 129);
- INI_Int("Kills", PlayerInfo[playerid][pKills]);
- INI_Int("Deaths", PlayerInfo[playerid][pDeaths]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128], pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), USER_FILE_PATH, pName);
- return string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement