Advertisement
Guest User

Registrace, login a změna hesla

a guest
Aug 4th, 2016
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.97 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dof2>
  3. #include <dudb>
  4. #define Hesla "/Ucty/Hesla/%s.txt"
  5.  
  6. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  7.  
  8. new Text:TDEditor_TD0;
  9. new Text:TDEditor_TD1;
  10. new Text:TDEditor_TD2;
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.  
  15.     TDEditor_TD0 = TextDrawCreate(291.405975, -1.333245, "_");
  16.     TextDrawLetterSize(TDEditor_TD0, 0.384538, 7.911665);
  17.     TextDrawTextSize(TDEditor_TD0, 8.760105, 1072.000000);
  18.     TextDrawAlignment(TDEditor_TD0, 2);
  19.     TextDrawColor(TDEditor_TD0, -1);
  20.     TextDrawUseBox(TDEditor_TD0, 1);
  21.     TextDrawBoxColor(TDEditor_TD0, 255);
  22.     TextDrawSetShadow(TDEditor_TD0, 87);
  23.     TextDrawSetOutline(TDEditor_TD0, 212);
  24.     TextDrawBackgroundColor(TDEditor_TD0, 255);
  25.     TextDrawFont(TDEditor_TD0, 1);
  26.     TextDrawSetProportional(TDEditor_TD0, 0);
  27.     TextDrawSetShadow(TDEditor_TD0, 87);
  28.  
  29.     TDEditor_TD1 = TextDrawCreate(280.630065, 375.500213, "_");
  30.     TextDrawLetterSize(TDEditor_TD1, 0.384538, 7.911665);
  31.     TextDrawTextSize(TDEditor_TD1, 8.760105, 1072.000000);
  32.     TextDrawAlignment(TDEditor_TD1, 2);
  33.     TextDrawColor(TDEditor_TD1, -1);
  34.     TextDrawUseBox(TDEditor_TD1, 1);
  35.     TextDrawBoxColor(TDEditor_TD1, 255);
  36.     TextDrawSetShadow(TDEditor_TD1, 87);
  37.     TextDrawSetOutline(TDEditor_TD1, 212);
  38.     TextDrawBackgroundColor(TDEditor_TD1, 255);
  39.     TextDrawFont(TDEditor_TD1, 1);
  40.     TextDrawSetProportional(TDEditor_TD1, 0);
  41.     TextDrawSetShadow(TDEditor_TD1, 87);
  42.  
  43.     TDEditor_TD2 = TextDrawCreate(227.218048, 24.916673, "NAZEV_SERVERU");
  44.     TextDrawLetterSize(TDEditor_TD2, 0.648784, 3.349999);
  45.     TextDrawAlignment(TDEditor_TD2, 1);
  46.     TextDrawColor(TDEditor_TD2, -5963521);
  47.     TextDrawSetShadow(TDEditor_TD2, 0);
  48.     TextDrawSetOutline(TDEditor_TD2, 0);
  49.     TextDrawBackgroundColor(TDEditor_TD2, 255);
  50.     TextDrawFont(TDEditor_TD2, 2);
  51.     TextDrawSetProportional(TDEditor_TD2, 1);
  52.     TextDrawSetShadow(TDEditor_TD2, 0);
  53.     return 1;
  54. }
  55.  
  56. public OnPlayerConnect(playerid)
  57. {
  58.     new nick[MAX_PLAYER_NAME],  soubor[256];
  59.     GetPlayerName(playerid, nick, sizeof(nick));
  60.     format(soubor, sizeof(soubor), Hesla, nick);
  61.     if (DOF2_FileExists(soubor))
  62.     {
  63.     ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{73C0E6}Přihlašování...", "{66F2BE}Vítej zpátky na serveru XXX! Zde zadej svoje heslo:", "{FF80C0}LOGIN", "");
  64.     PlayAudioStreamForPlayer(playerid, "http://k007.kiwi6.com/hotlink/7r8pac2erw/Alesso_vs_OneRepublic_-_If_I_Lose_Myself_Alesso_Remix_.mp3");
  65.     TextDrawShowForPlayer(playerid,TDEditor_TD0);
  66.     TextDrawShowForPlayer(playerid,TDEditor_TD1);
  67.     TextDrawShowForPlayer(playerid,TDEditor_TD2);
  68.     }
  69.     else
  70.     {
  71.     ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{73C0E6}Registrace...","{66F2BE}Vítej na serveru XXX! Zde zadej svoje nové heslo:", "{FF80C0}REGISTRACE", "");
  72.     PlayAudioStreamForPlayer(playerid, "http://k007.kiwi6.com/hotlink/7r8pac2erw/Alesso_vs_OneRepublic_-_If_I_Lose_Myself_Alesso_Remix_.mp3");
  73.     TextDrawShowForPlayer(playerid,TDEditor_TD0);
  74.     TextDrawShowForPlayer(playerid,TDEditor_TD1);
  75.     TextDrawShowForPlayer(playerid,TDEditor_TD2);
  76.     }
  77.     return 1;
  78. }
  79.  
  80. public OnPlayerCommandText(playerid, cmdtext[])
  81. {
  82.     dcmd(changepass,10,cmdtext);
  83.     return 0;
  84. }
  85.  
  86. dcmd_changepass(playerid,params[])
  87. {
  88.     #pragma unused params
  89.     ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"{73C0E6}Změna hesla","{66F2BE}Zadej prosím svoje staré heslo","{FF80C0}Další","{FE635A}Zavřít");
  90.     return 1;
  91. }
  92.  
  93. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  94. {
  95.     if (dialogid == 1)
  96.     {
  97.         new nick[MAX_PLAYER_NAME], soubor[256], string[128];
  98.         GetPlayerName(playerid, nick, sizeof(nick));
  99.         format(soubor, sizeof(soubor), Hesla, nick);
  100.         if(!response) return Kick(playerid);
  101.         if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{73C0E6}Registrace...","{66F2BE}Vítej na serveru XXX! Zde zadej svoje nové heslo:", "{FF80C0}REGISTRACE", "");
  102.         TextDrawShowForPlayer(playerid,TDEditor_TD0);
  103.         TextDrawShowForPlayer(playerid,TDEditor_TD1);
  104.         TextDrawShowForPlayer(playerid,TDEditor_TD2);
  105.         DOF2_CreateFile(soubor);
  106.         DOF2_SetInt(soubor, "Heslo", udb_hash(inputtext));
  107.         DOF2_SaveFile();
  108.         format(string, 128, "Byl jsi úspěšně zaregistrovaný na jméno %s. Tvoje heslo je %s.", nick, inputtext);
  109.         SendClientMessage(playerid, 0x66F2BEFF, string);
  110.         StopAudioStreamForPlayer(playerid);
  111.         TextDrawHideForPlayer(playerid,TDEditor_TD0);
  112.         TextDrawHideForPlayer(playerid,TDEditor_TD1);
  113.         TextDrawHideForPlayer(playerid,TDEditor_TD2);
  114.     }
  115.     if (dialogid == 2)
  116.     {
  117.         new nick[MAX_PLAYER_NAME], soubor[256];
  118.         GetPlayerName(playerid, nick, sizeof(nick));
  119.         format(soubor, sizeof(soubor), Hesla, nick);
  120.         if(!response) return Kick(playerid);
  121.         new tmp;
  122.         tmp = DOF2_GetInt(soubor, "Heslo");
  123.         if(udb_hash(inputtext) != tmp)
  124.         ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{73C0E6}Přihlašování...", "{66F2BE}Vítej zpátky na serveru XXX! Zde zadej svoje heslo:\n{FE635A}Zadal jsi špatné heslo!", "{FF80C0}LOGIN", "");
  125.         TextDrawShowForPlayer(playerid,TDEditor_TD0);
  126.         TextDrawShowForPlayer(playerid,TDEditor_TD1);
  127.         TextDrawShowForPlayer(playerid,TDEditor_TD2);
  128.         if(!strcmp(inputtext,DOF2_GetString(soubor,"Heslo"),false))
  129.         {
  130.             ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{73C0E6}Přihlašování...", "{66F2BE}Vítej zpátky na serveru XXX! Zde zadej svoje heslo:", "{FF80C0}LOGIN", "");
  131.             TextDrawShowForPlayer(playerid,TDEditor_TD0);
  132.             TextDrawShowForPlayer(playerid,TDEditor_TD1);
  133.             TextDrawShowForPlayer(playerid,TDEditor_TD2);
  134.         }
  135.         else
  136.         {
  137.             SendClientMessage(playerid,0x66F2BEFF, "Byl jsi úspěšně přihlášený!!");
  138.             TextDrawHideForPlayer(playerid,TDEditor_TD0);
  139.             TextDrawHideForPlayer(playerid,TDEditor_TD1);
  140.             TextDrawHideForPlayer(playerid,TDEditor_TD2);
  141.             StopAudioStreamForPlayer(playerid);
  142.         }
  143.     }
  144.     if(dialogid == 3)
  145.     {
  146.     new nick[MAX_PLAYER_NAME], slozka[256];
  147.     GetPlayerName(playerid, nick, sizeof(nick));
  148.     format(slozka, sizeof(slozka), Hesla, nick);
  149.     if(response)
  150.     {
  151.     if(udb_hash(inputtext) != DOF2_GetInt(slozka, "Heslo"))
  152.     {
  153.     ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"{73C0E6}Změna hesla","{66F2BE}Zadej prosím svoje staré heslo\n{FE635A}Zadal jsi špatné heslo!","{FF80C0}Další","{FE635A}Zavřít");
  154.     }
  155.     else
  156.     {
  157.     ShowPlayerDialog(playerid,4,DIALOG_STYLE_INPUT,"{73C0E6}Změna hesla","{66F2BE}Zadej prosím svoje nové heslo","{FF80C0}Hotovo","{FE635A}Zavřít");
  158.     }
  159.     }
  160.     }
  161.     if(dialogid == 4)
  162.     {
  163.     new nick[MAX_PLAYER_NAME], slozka[256];
  164.     GetPlayerName(playerid, nick, sizeof(nick));
  165.     format(slozka, sizeof(slozka), Hesla, nick);
  166.     if(response)
  167.     {
  168.     DOF2_SetInt(slozka, "Heslo", udb_hash(inputtext));
  169.     DOF2_SaveFile();
  170.     SendClientMessage(playerid,0x66F2BEFF,"Heslo bylo úspěšně změněho! Svoje heslo si zapamatuj pro další přihlášení.");
  171.     }
  172.     }
  173.     return 1;
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement