Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  2. {
  3. if (dialogid == 1) // First Dialog (Register Dialog)
  4. { // Open brackelet!
  5. new name[MAX_PLAYER_NAME], file[256], string[128]; // his name, .ini file, string
  6. GetPlayerName(playerid, name, sizeof(name)); // Will get player's name !
  7. format(file, sizeof(file), PATH, name); // Search about .ini file name !
  8. if(!response) return Kick(playerid); // If he hit Exit, will get kicked !
  9. if (!strlen(inputtext)) return // What Password he will write in box !
  10. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "-->{FF0000}H-Admin {0066CC}Register", "{FFFF00}Welcome !\n\n{FFFFFF}Account status: {FF0000}Not Registered\n\n{0066CC}Please enter your password below to continue register :", "Submit", "Exit"); // Register Dialog !
  11. dini_Create(file); // Dini will create .ini file for that player !
  12. dini_IntSet(file, "Password", udb_hash(inputtext)); // Will save his password ! He can login again just with his password !
  13. dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdmin] = 0); // Will save his Admin (0 now)
  14. dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500); // Will save his money, will be spawned with 500 $ !
  15. dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 1); // Will save his score, when he will be spawned with 1 Score !
  16. dini_IntSet(file, "Kills",PlayerInfo[playerid][pKills] = 0);
  17. dini_IntSet(file, "Deaths",PlayerInfo[playerid][pDeaths] = 0);
  18. dini_IntSet(file, "Bonus",PlayerInfo[playerid][Bonus] = 0);
  19. format(string, 128, "{FF0000}[--> Succesfully <--]: {FFFF00}%s {0066CC} you have been registered. Your password it's {FF0000}%s !", name, inputtext); // Chat Message !
  20. SendClientMessage(playerid, -1, string); // Will put this message on registered player's chat!
  21. gPlayerLogged[playerid] = 1; // Now, he is Auto-Logged (he don't need to put again his password, only if he exit and enter again on server !)
  22. } // Closing Brackelet
  23. if (dialogid == 2) // Dialog 2 (Login Dialog)
  24. { // Open brackelet
  25. new name[MAX_PLAYER_NAME], file[256]; // player's name, .ini file, string
  26. GetPlayerName(playerid, name, sizeof(name)); // Will get player's name !
  27. format(file, sizeof(file), PATH, name); // Search about .ini file from that player !
  28. if(!response) return Kick(playerid); // If he hit Exit he will be kicked !
  29. if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "-->{FF0000}H-Admin {0066CC}Login", "{FFFF00}Welcome !\n\n{FFFFFF}Account status: {15FF00}Registered\n\n{0066CC}Please enter your password below, to continue login :", "Submit", "Exit"); // Our Login Dialog !
  30. new tmp; // Variable !
  31. tmp = dini_Int(file, "Password"); // Password !
  32. if(udb_hash(inputtext) != tmp) // In that box if he don't put correct password from .ini file then :
  33. { // Open Brackelet
  34. SendClientMessage(playerid, -1, "{FF0000}Wrong password! {0066CC}Try another one !"); // He will cannot login !
  35. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "-->{FF0000}Login {0066CC}Account", "{FF0000}Wrong password !\n{0066CC}Please enter your real password to continue!", "Login", "Exit"); // And if his password it's wrong he will saw again our Login Dialog, to try again log in !
  36. } // Closin brackelet !
  37. else // Else
  38. { // Open brackelet !
  39. gPlayerLogged[playerid] = 1; // 1 = He it's logged !
  40. PlayerInfo[playerid][pAdmin] = dini_Int(file, "AdminLevel"); // If he have Admin, in .ini file will load his Admin before login !
  41. SetPlayerScore(playerid, PlayerInfo[playerid][pScore]); // Will sets his score from last time , from .ini file !
  42. GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid)); // He will get money from last time, from .ini file !
  43. SendClientMessage(playerid, -1, "{FF0000}[--> Succesfully <--]: {0066CC}You have been {FFFF00}successfully {0066CC}logged in!"); // This he will saw after Login !
  44. } // Closing brackelet *1 !
  45. }
  46. return 1;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement