Diogo_Bras

Fini Login Box

Apr 24th, 2011
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.13 KB | None | 0 0
  1. //Includes
  2. #include <a_samp>
  3. #include <Fini>
  4.  
  5. //Defines
  6. #define FILTERSCRIPT
  7.  
  8. #define REGISTRO 1
  9. #define LOGIN    2
  10.  
  11. //News
  12. new Matou[MAX_PLAYERS];
  13. new Morreu[MAX_PLAYERS];
  14.  
  15. //Calbacks
  16. public OnFilterScriptInit()
  17. {
  18.     print(" Criado Por Jonathan Feitosa");
  19.     return 1;
  20. }
  21.  
  22. public OnFilterScriptExit()
  23. {
  24.     for(new i=0; i<MAX_PLAYERS; i++)
  25.     SalvarPlayer(i);
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerRequestClass(playerid, classid)
  30. {
  31.     return 1;
  32. }
  33.  
  34. public OnPlayerConnect(playerid)
  35. {
  36.     new Nome[MAX_PLAYER_NAME];
  37.     GetPlayerName(playerid, Nome, sizeof(Nome));
  38.     new String[100];
  39.     format(String, sizeof(String), "Players/%s.ini", Nome);
  40.     if(!Fini_Exists(String))
  41.     {
  42.         format(String, sizeof(String), "{7FFFD4}Nick: {1E90FF}%s  {1E90FF}Não Registrado\n\n{FFFFFF} Digite Uma Senha Para Continuar", Nome);
  43.         ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro", String, "Registrar", "Cancelar");
  44.     }
  45.     else
  46.     {
  47.         format(String, sizeof(String), "{7FFFD4}Nick: {1E90FF}%s  {1E90FF}Registrado\n\n{FFFFFF} Digite Sua Senha Para Logar-Se", Nome);
  48.         ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Registro", String, "Logar", "Cancelar");
  49.     }
  50.     return 1;
  51. }
  52. public OnPlayerDisconnect(playerid, reason)
  53. {
  54.     SalvarPlayer(playerid);
  55.     return 1;
  56. }
  57.  
  58. public OnPlayerCommandText(playerid, cmdtext[])
  59. {
  60.     if (strcmp("/JFS", cmdtext, true, 8) == 0)
  61.     {
  62.         return 1;
  63.     }
  64.     return 0;
  65. }
  66.  
  67. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  68. {
  69.     if(dialogid == REGISTRO)
  70.     {
  71.         if(response)
  72.         {
  73.             if(!strlen(inputtext))
  74.             {
  75.                 new Nome[MAX_PLAYER_NAME];
  76.                 GetPlayerName(playerid, Nome, sizeof(Nome));
  77.                 new sStr[100];
  78.                 format(sStr, sizeof(sStr), "{7FFFD4}Nick: {1E90FF}%s  {1E90FF}Não Registrado\n\n{FFFFFF} Digite Uma Senha Para Continuar", Nome);
  79.                 ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro", sStr, "Registrar", "Cancelar");
  80.                 SendClientMessage(playerid,0x1E90FFAA,"Senha invalida, digite uma senha válida");
  81.                 return 1;
  82.             }
  83.             new sStr[100];
  84.             Fini_Create(sStr);
  85.             Fini_OpenFile(sStr);
  86.             Fini_SetStr("Senha",inputtext);
  87.             Fini_SetVal("Dinheiro", GetPlayerMoney(playerid));
  88.             Fini_SetVal("Matou", false);
  89.             Fini_SetVal("Morreu", false);
  90.             Fini_SaveFile();
  91.             Fini_CloseFile();
  92.             ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", "{1E90FF}Pronto você se registrou agora digite Sua Senha Para Logar-Se", "Logar", "Cancelar");
  93.             return true;
  94.         }
  95.         else
  96.         {
  97.             SendClientMessage(playerid, 0xFF0000AA, "Você Foi Kickado Porque Não Quis Se Registrar!!");
  98.             Kick(playerid);
  99.             return true;
  100.         }
  101.     }
  102.     if(dialogid == LOGIN)
  103.     {
  104.         if(response)
  105.         {
  106.             if(!strlen(inputtext))
  107.             {
  108.                 new Nome[MAX_PLAYER_NAME];
  109.                 GetPlayerName(playerid, Nome, sizeof(Nome));
  110.                 new sStr[100];
  111.                 format(sStr, sizeof(sStr), "{7FFFD4}Nick: {1E90FF}%s  {1E90FF}Registrado\n\n{FFFFFF} Digite Sua Senha Para Logar-Se", Nome);
  112.                 ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Registro", sStr, "Logar", "Cancelar");
  113.                 SendClientMessage(playerid,0x1E90FFAA,"Senha Incorreta !");
  114.                 return 1;
  115.             }
  116.             new Nome[MAX_PLAYER_NAME];
  117.             GetPlayerName(playerid, Nome, sizeof(Nome));
  118.             new sStr[100];
  119.             format(sStr, sizeof(sStr), "Players/%s.ini", Nome);
  120.             if(!strcmp(Fini_GetStr("Senha"),inputtext,true))
  121.             {
  122.                 SetarPlayer(playerid);
  123.                 SendClientMessage(playerid,0x00FF00AA,"Você Foi Logado Com Sucesso > Escolha Sua Skin!");
  124.                 return true;
  125.             }
  126.             else
  127.             {
  128.                 SendClientMessage(playerid,0x00FF00AA,"Senha incorreta digite-a novamente");
  129.                 format(sStr, sizeof(sStr), "{7FFFD4}Nick: {1E90FF}%s  {1E90FF}Registrado\n\n{FFFFFF} Digite Sua Senha Para Logar-Se", Nome);
  130.                 ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Registro", sStr, "Logar", "Cancelar");
  131.             }
  132.             return true;
  133.         }
  134.         else
  135.         {
  136.             SendClientMessage(playerid, 0xFF0000AA, "Você não quis se logar, por este motivo será Kickado");
  137.             Kick(playerid);
  138.             return true;
  139.         }
  140.     }
  141.     return 1;
  142. }
  143.  
  144. SalvarPlayer(playerid)
  145. {
  146.     new sStr[50], Nome[MAX_PLAYER_NAME];
  147.     GetPlayerName(playerid, Nome, sizeof(Nome));
  148.     format(sStr, sizeof(sStr), "Players/%s.ini", Nome);
  149.     if(!Fini_Exists(sStr))
  150.     {
  151.         format(sStr, sizeof(sStr), "Players/%s.ini", Nome);
  152.         Fini_Create(sStr);
  153.     }
  154.     Fini_OpenFile(sStr);
  155.     {
  156.         Fini_SetVal("Dinheiro", GetPlayerMoney(playerid));
  157.         Matou[playerid] = Fini_GetValue("Matou");
  158.         Morreu[playerid] = Fini_GetValue("Morreu");
  159.     }
  160.     Fini_SaveFile();
  161.     Fini_CloseFile();
  162.     return true;
  163. }
  164.  
  165. SetarPlayer(playerid)
  166. {
  167.     new sStr[50], Nome[MAX_PLAYER_NAME];
  168.     GetPlayerName(playerid, Nome, sizeof(Nome));
  169.     format(sStr, sizeof(sStr), "Players/%s.ini", Nome);
  170.     if(!fexist(sStr))
  171.     {
  172.         Fini_Create(sStr);
  173.     }
  174.     Fini_OpenFile(sStr);
  175.     GivePlayerMoney(playerid, Fini_GetValue("Dinheiro"));
  176.     Matou[playerid] = Fini_GetValue("Matou");
  177.     Morreu[playerid] = Fini_GetValue("Morreu");
  178.     Fini_SaveFile();
  179.     Fini_CloseFile();
  180.     return true;
  181. }
Advertisement
Add Comment
Please, Sign In to add comment