Guest User

OnPlayerDialog

a guest
Dec 24th, 2012
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.00 KB | None | 0 0
  1. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  2. {
  3.     if (dialogid == 1)
  4.     {
  5.         new file[256], string[131];
  6.         format(file, sizeof(file), SERVER_USER_FILE, GetPlayerNameEx(playerid));
  7.         if(!response) return Kick(playerid);
  8.         if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{CC0000}Registration", "GMNAME \nIt seems like you are not registered, type your password to continue.", "Register", "Cancel");
  9.         dini_Create(file);
  10.         dini_IntSet(file, "Password", udb_hash(inputtext));
  11.         dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel] = 0);
  12.         dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 0);
  13.         dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
  14.         dini_IntSet(file, "Job",PlayerInfo[playerid][pJob] = 0);
  15.         dini_IntSet(file, "Color",PlayerInfo[playerid][pColor] = 0);
  16.         dini_IntSet(file, "Vw",PlayerInfo[playerid][pVw] = 0);
  17.         dini_IntSet(file, "Int",PlayerInfo[playerid][pInt] = 0);
  18.         dini_IntSet(file, "Warns",PlayerInfo[playerid][pWarns] = 0);
  19.         dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 0);
  20.         if(PlayerInfo[playerid][pReg] == 0) { GivePlayerCash(playerid, 250); }
  21.         dini_IntSet(file, "Reg",PlayerInfo[playerid][pReg] = 1);
  22.         format(string, 131, "You succesfully registered the name %s with password %s, you have been auto logged in.", GetPlayerNameEx(playerid), inputtext);
  23.         SCM(playerid, COLOR_WHITE, string);
  24.         gPlayerLogged[playerid] = 1;
  25.         SpawnPlayer(playerid);
  26.     }
  27.     if (dialogid == 2)
  28.     {
  29.         new file[256];
  30.         format(file, sizeof(file), SERVER_USER_FILE, GetPlayerNameEx(playerid));
  31.         if(!response) return Kick(playerid);
  32.         if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{CC0000}Login", "GMNAME \nYou are registered thanks for joining us , type your password to continue.", "Login", "Cancel");
  33.         new tmp;
  34.         tmp = dini_Int(file, "Password");
  35.         if(udb_hash(inputtext) != tmp) {
  36.             SCM(playerid, COLOR_RED, "Wrong Password, try again.");
  37.             ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{CC0000}Login", "GMNAME \n{CC0000}WRONG PASSWORD\n{CC0000}Type in your password correctly to continue.", "Login", "Cancel");
  38.         }
  39.         else
  40.         {
  41.             gPlayerLogged[playerid] = 1;
  42.             PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
  43.             PlayerInfo[playerid][pSkin] = dini_Int(file, "Skin");
  44.             PlayerInfo[playerid][pReg] = dini_Int(file, "Reg");
  45.             SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
  46.             SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
  47.             SetPlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  48.             GivePlayerCash(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));//
  49.             SCM(playerid,COLOR_RED, "Successfully logged in!");
  50.             SpawnPlayer(playerid);
  51.         }
  52.     }
  53.     return 1;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment