Advertisement
CreativityLacker

Code

Feb 8th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.48 KB | None | 0 0
  1. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  2. {
  3.     switch(dialogid)
  4.     {
  5.         case DIALOG_REGISTER:
  6.         {
  7.             if (!response) return Kick(playerid);
  8.             if(response)
  9.             {
  10.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
  11.                 RegisterUser(playerid, inputtext);
  12.                 ShowPlayerDialog(playerid, DIALOG_RESULT, DIALOG_STYLE_MSGBOX,"Success!","You've been successfully registered on our server!","Ok","");
  13.                 pInfo[playerid][LoggedIn] = true;
  14.             }
  15.         }
  16.  
  17.         case DIALOG_LOGIN:
  18.         {
  19.             if (!response) return Kick (playerid);
  20.             if(response)
  21.             {
  22.                 if(strcmp(inputtext, pInfo[playerid][Password], false) == 0)
  23.                 {
  24.                     INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  25.                     GivePlayerMoney(playerid, pInfo[playerid][Money]);
  26.                     ShowPlayerDialog(playerid, DIALOG_RESULT, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
  27.                     pInfo[playerid][LoggedIn] = true;
  28.                     GivePlayerMoney(playerid, pInfo[playerid][Money]);
  29.                 }
  30.                 else
  31.                 {
  32.                     ShowPlayerDialog(playerid, DIALOG_RESULT, DIALOG_STYLE_PASSWORD,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
  33.                 }
  34.                 return 1;
  35.             }
  36.         }
  37.     }
  38.     return 1;
  39. }
  40.  
  41. stock ResetUser(pid)
  42. {
  43.     format(pInfo[pid][IP], 20, "NA");
  44.     pInfo[pid][Password] = -1;
  45.     pInfo[pid][ALevel] = 0;
  46.     pInfo[pid][VIPLevel] = 0;
  47.     pInfo[pid][LoggedIn] = false;
  48.     pInfo[pid][Helper] = 0;
  49.     pInfo[pid][Kills] = 0;
  50.     pInfo[pid][Deaths] = 0;
  51.     pInfo[pid][Money] = 0;
  52.     ResetPlayerMoney_(pid);
  53.     pInfo[pid][Experience] = 0;
  54.     pInfo[pid][Rank] = 0;
  55.     pInfo[pid][Spree] = 0;
  56.     pInfo[pid][Banned] = 0;
  57.     pInfo[pid][Inzone] = -1;
  58.     pInfo[pid][Weed] = 0;
  59.     pInfo[pid][Seeds] = 0;
  60.     pInfo[pid][Job] = INVALID_JOB;
  61.     ResetPlayerWeapons_(pid);
  62.     return 1;
  63. }
  64.  
  65. stock RegisterUser(pid, pass[])
  66. {
  67.     if(fexist(getini(pid))) return 0;
  68.     if(!IsPlayerConnected(pid)) return 0;
  69.     else
  70.     {
  71.         new INI:uh = INI_Open(getini(pid));
  72.         INI_SetTag(uh, "data");
  73.         INI_WriteString(uh, "Name", pname(pid) );
  74.         INI_WriteString(uh, "IP", pip(pid) );
  75.         format(pInfo[pid][Password], 129, "%s",pass);
  76.         INI_WriteString(uh, "Password", pass);
  77.         INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
  78.         INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
  79.         INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
  80.         INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
  81.         INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
  82.         INI_WriteInt(uh, "VIPLevel", pInfo[pid][VIPLevel]);
  83.         INI_WriteInt(uh, "Banned", 0);
  84.         INI_WriteInt(uh, "Weed", pInfo[pid][Weed]);
  85.         INI_WriteInt(uh, "Seed", pInfo[pid][Seeds]);
  86.         INI_Close(uh);
  87.     }
  88.     return 1;
  89. }
  90.  
  91. stock SaveUser(pid)
  92. {
  93.     if(!fexist(getini(pid))) return 0;
  94.     if(!IsPlayerConnected(pid)) return 0;
  95.     else
  96.     {
  97.         new INI:uh = INI_Open(getini(pid));
  98.         INI_SetTag(uh, "data");
  99.         INI_WriteString(uh, "Name", pname(pid) );
  100.         INI_WriteString(uh, "IP", pInfo[pid][IP] );
  101.         INI_WriteString(uh, "Password", pInfo[pid][Password]);
  102.         INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
  103.         INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
  104.         INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
  105.         INI_WriteInt(uh, "Money", pInfo[pid][Money]);
  106.         INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
  107.         INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
  108.         INI_WriteInt(uh, "VIPLevel", pInfo[pid][VIPLevel]);
  109.         INI_WriteInt(uh, "Banned", pInfo[pid][Banned]);
  110.         INI_WriteInt(uh, "Weed", pInfo[pid][Weed] );
  111.         INI_WriteInt(uh, "Seed", pInfo[pid][Seeds] );
  112.         INI_Close(uh);
  113.     }
  114.     return 1;
  115. }
  116.  
  117. stock LoadUser_data(playerid,name[],value[])
  118. {
  119.     INI_String("Password",pInfo[pid][Password]);
  120.     INI_Int("Money",pInfo[pid][Money]);
  121.     INI_Int("AdminLevel",pInfo[pid][ALevel]);
  122.     INI_Int("VIPLevel", pInfo[pid][VIPLevel]);
  123.     INI_Int("Kills",pInfo[pid][Kills]);
  124.     INI_Int("Deaths",pInfo[pid][Deaths]);
  125.     INI_Int("Helper", pInfo[pid][Helper]);
  126.     INI_Int("Password", pInfo[pid][Helper]);
  127.     INI_Int("Experience", pInfo[pid][Experience]);
  128.     SetPlayerScore(playerid, pInfo[pid][Experience]);
  129.     INI_Int("Banned", pInfo[pid][Banned]);
  130.     INI_Int("Weed", pInfo[pid][Weed]);
  131.     INI_Int("Seed", pInfo[pid][Seeds]);
  132.     return 1;
  133. }
  134.  
  135. public OnPlayerConnect(playerid)
  136. {
  137.     ResetUser(playerid);
  138.     TextDrawShowForPlayer(playerid, sInfo[Website]);
  139.     RemoveBuildings(playerid);
  140.     if(IsPlayerNPC(playerid))
  141.     {
  142.         SetPlayerSkin(playerid, 161);
  143.         SetPlayerColor(playerid, PINK);
  144.         pInfo[playerid][ALevel] = 5;
  145.         pInfo[playerid][Helper] = 0;
  146.         sInfo[npcis] = playerid;
  147.         pInfo[playerid][LoggedIn] = true;
  148.         return 1;
  149.     }
  150.     else
  151.     {
  152.         ShowBases(playerid);
  153.         if(fexist(getbanini(playerid)))
  154.         {
  155.             SendClientMessage(playerid, RED, "[ERROR] You're banned! Stop ban evading! ");
  156.             KickEx(playerid);
  157.         }
  158.         else
  159.         {
  160.             for(new x = 0; x < MAX_ZONES; x++)
  161.             {
  162.                 SetPlayerMapIcon(playerid, x, GZ[x][Cappoint][0], GZ[x][Cappoint][1], GZ[x][Cappoint][2], 19, 0);
  163.             }
  164.             new cstr[140];
  165.             if(fexist(getini(playerid)))
  166.             {
  167.                 INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  168.                 pInfo[playerid][LoggedIn] = false;
  169.                 ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","Type your password below to login.","Login","Quit");
  170.                 format(cstr, 140, "[LATEST JOIN] %s has joined", pname(playerid) );
  171.                 CreateNews(NEWS_JOIN, cstr);
  172.             }
  173.             else
  174.             {
  175.                 pInfo[playerid][LoggedIn] = false;
  176.                 ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registering...","Type your password below to register a new account.","Register","Quit");
  177.                 SendClientMessage(playerid, CYAN, "[SeRbErSShSHhs] W3lcUm t0 d4 sErVer");
  178.                 format(cstr, 140, "[LATEST JOIN] %s has joined", pname(playerid) );
  179.                 CreateNews(NEWS_JOIN, cstr);
  180.             }
  181.         }
  182.     }
  183.     return 1;
  184. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement