Guest User

Untitled

a guest
Jan 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.71 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <YSI\y_ini>
  7. #if defined FILTERSCRIPT
  8. #endif
  9. #define DIALOG_REG 1
  10. #define DIALOG_LOGIN 2
  11. #define SYSTEM_RED 0xE7321BFF //Colore rosso per messaggi di errore
  12. #define MAX_FAILED_LOGIN 3 //Massimo numero di login falliti
  13. enum stat_info {admin_level, score, money, failed_login, bool: logged}; //Statistiche players
  14. new player_stat[MAX_PLAYERS][stat_info];
  15. new pstring[500], p_password[20], bool: banned; //Array & check bannato al login
  16. new INI: opened_file; //var che identifica il file aperto
  17.  
  18.  
  19. public OnFilterScriptInit()
  20. {
  21.     print("\n--------------------------------------");
  22.     print(" Blank Filterscript by your name here");
  23.     print("--------------------------------------\n");
  24.     return 1;
  25. }
  26.  
  27. public OnFilterScriptExit()
  28. {
  29.     return 1;
  30. }
  31.     public OnPlayerConnect(playerid)
  32.     {
  33.     new name[24];
  34.     GetPlayerName(playerid, name, 24);
  35.     format(pstring,sizeof(pstring), "/Utenti/%s.ini", name);
  36.     if(!fexist(pstring))
  37.     {
  38.     format(pstring, 500, "{C1C1C1}Benvenuto {B0EC1B}%s{C1C1C1} nel server NOMESERVER!\n\n Il tuo account non risulta registrato.\nRegistra un account inserendo la password qui sotto:", name);
  39.     ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registrazione...", pstring, "Registrati", "");
  40.     return 1;
  41.     }
  42.     else
  43.     {
  44.     format(pstring, 500, "{C1C1C1}Benvenuto {B0EC1B}%s{C1C1C1} nel server NOMESERVER!\n\n Il tuo account risulta registrato.\nInserisci la password per effetuare il login:", name);
  45.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login!", "");
  46.     return 1;
  47.     }
  48.     }
  49.  
  50.     public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  51.     {
  52.     new name[24];
  53.     GetPlayerName(playerid, name, 24);
  54.     switch(dialogid)
  55.     {
  56.     case DIALOG_REG:
  57.     {
  58.     if(!response)
  59.     {
  60.     PlayerPlaySound(playerid, 1055, 0, 0 ,0); //Suoni per errori
  61.     SendClientMessage(playerid, SYSTEM_RED, "[SERVER:] {C1C1C1}Ci dispiace la registrazione è obbligatoria. Sei stato kickato.");
  62.     Kick(playerid);
  63.     return 1;
  64.     }
  65.     if(!strlen(inputtext))
  66.     {
  67.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  68.     format(pstring, 500, "{F1781B}-Immetti una password valida-\n{C1C1C1}Benvenuto {B0EC1B}%s{C1C1C1} nel server NOMESERVER!\n\n Il tuo account non risulta registrato.\nRegistra un account inserendo la password qui sotto:", name);
  69.     ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registrazione...", pstring, "Registrati", "");
  70.     return 1;
  71.     }
  72.     if(strlen(inputtext) > 20)
  73.     {
  74.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  75.     format(pstring, 500, "{F1781B}-Massimo 20 caratteri per la password-\n{C1C1C1}Benvenuto {B0EC1B}%s{C1C1C1} nel server NOMESERVER!\n\n Il tuo account non risulta registrato.\nRegistra un account inserendo la password qui sotto:", name);
  76.     ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registrazione...", pstring, "Registrati", "");
  77.     return 1;
  78.     }
  79.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  80.     GetPlayerName(playerid, name, 24);
  81.     format(pstring,sizeof(pstring),"/Utenti/%s.ini",name);
  82.     opened_file = INI_Open(pstring);
  83.     new pyear, pmonth, pday, phour, pminute, psecond;
  84.     getdate(pyear,pmonth,pday),gettime(phour,pminute,psecond);
  85.     format(pstring, 500, "%d/%d/%04d - %02d:%02d:%02d", pday, pmonth, pyear, phour, pminute, psecond);
  86.     new ip[20];
  87.     GetPlayerIp(playerid, ip, 20);
  88.     INI_WriteString(opened_file, "Password", inputtext);
  89.     INI_WriteString(opened_file, "Data_Registrazione", pstring);
  90.     INI_WriteString(opened_file, "Ultimo_Login", pstring);
  91.     INI_WriteString(opened_file, "IP_Registrazione", ip);
  92.     INI_WriteString(opened_file, "Ultimo_IP", ip);
  93.     INI_WriteInt(opened_file, "Livello_Admin", 0);
  94.     INI_WriteInt(opened_file, "Punti", 0);
  95.     INI_WriteInt(opened_file, "Soldi", 0);
  96.     INI_WriteBool(opened_file, "Bannato", false);
  97.     INI_Close(opened_file);
  98.     format(pstring, 500, "{C1C1C1}Benvenuto {B0EC1B}%s{C1C1C1} nel server NOMESERVER!\n\n Congratulazioni, registrazione effettuata con successo.\nInserisci la password per effetuare il login:", name);
  99.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login!", "");
  100.     return 1;
  101.     }
  102.     case DIALOG_LOGIN:
  103.     {
  104.     if(!response)
  105.     {
  106.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  107.     SendClientMessage(playerid, SYSTEM_RED, "[SERVER:] {C1C1C1}Ci dispiace il login è obbligatorio. Sei stato kickato.");
  108.     Kick(playerid);
  109.     return 1;
  110.     }
  111.     if(!strlen(inputtext))
  112.     {
  113.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  114.     format(pstring, 500, "{F1781B}-Inserire una password per effetuare il login-\n{C1C1C1}Benvenuto {B0EC1B}%s{C1C1C1} nel server NOMESERVER!\n\n Il tuo account risulta registrato.\nInserisci la password per effetuare il login:", name);
  115.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
  116.     return 1;
  117.     }
  118.     if(strlen(inputtext) > 20)
  119.     {
  120.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  121.     format(pstring, 500, "{F1781B}-Massimo 20 caratteri per la password-\n{C1C1C1}Benvenuto {B0EC1B}%s{C1C1C1} nel server NOMESERVER!\n\n Il tuo account risulta registrato.\nInserisci la password per effetuare il login:", name);
  122.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
  123.     return 1;
  124.     }
  125.     format(pstring,sizeof(pstring),"/Utenti/%s.ini",name);
  126.     INI_ParseFile(pstring, "Parse_Player_Pass", .bExtra = true, .extra = playerid);
  127.     if(strcmp(inputtext, p_password, true))
  128.     {
  129.     player_stat[playerid][failed_login]++;
  130.     PlayerPlaySound(playerid, 1055, 0, 0 ,0);
  131.     if(player_stat[playerid][failed_login] == MAX_FAILED_LOGIN)
  132.     {
  133.     SendClientMessage(playerid, SYSTEM_RED, "[SERVER:] {C1C1C1}Hai superato il limite massimo di tentativi per il login. Sei stato kickato.");
  134.     Kick(playerid);
  135.     return 1;
  136.     }
  137.     format(pstring, 500, "{F1781B}-Tentativo login %d/%d. A %d tentativi verrai kickato-\n{C1C1C1}Benvenuto {B0EC1B}%s{C1C1C1} nel server NOMESERVER!\n\n Il tuo account risulta registrato.\nInserisci la password per effetuare il login:", player_stat[playerid][failed_login], MAX_FAILED_LOGIN, MAX_FAILED_LOGIN, name);
  138.     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
  139.     return 1;
  140.     }
  141.     else
  142.     {
  143.     format(pstring,sizeof(pstring),"/Utenti/%s.ini",name);
  144.     INI_ParseFile(pstring,"Load_Player_Data", .bExtra = true, .extra = playerid);
  145.     if(banned)
  146.     {
  147.     banned = false;
  148.     SendClientMessage(playerid, SYSTEM_RED, "Questo account risulta bannato dal server.");
  149.     Kick(playerid);
  150.     return 2;
  151.     }
  152.     player_stat[playerid][logged] = true;
  153.     return 1;
  154.     }
  155.     }
  156.     }
  157.     return 1;
  158.     }
  159.    
  160.  
  161.     forward Parse_Player_Pass(playerid, name[], value[]);
  162.     public Parse_Player_Pass(playerid, name[], value[])
  163.     {
  164.     INI_String("Password", p_password, 20);
  165.     return 1;
  166.     }
  167.  
  168.     forward Load_Player_Data(playerid, name[], value[]);
  169.     public Load_Player_Data(playerid, name[], value[])
  170.     {
  171.     INI_Int("Livello_Admin", player_stat[playerid][admin_level]);
  172.     INI_Int("Soldi", player_stat[playerid][money]);
  173.     INI_Int("Punti", player_stat[playerid][score]);
  174.     INI_Bool("Bannato", banned);
  175.     return 1;
  176.     }
  177.  
  178.     public OnPlayerDisconnect(playerid, reason)
  179.     {
  180.     new name[24];
  181.     GetPlayerName(playerid, name, sizeof(name));
  182.     switch(reason)
  183.     {
  184.     case 0: format(pstring, 500, "{B0EC1B}%s {C1C1C1}si è disconnesso dal server {A1A1A1}[crash].", name);
  185.     case 1: format(pstring, 500, "{B0EC1B}%s {C1C1C1}si è disconnesso dal server.", name);
  186.     case 2: format(pstring, 500, "{B0EC1B}%s {C1C1C1}si è disconnesso dal server {A1A1A1}[kick/ban].", name);
  187.     }
  188.     SendClientMessageToAll(-1, pstring);
  189.     if(player_stat[playerid][logged])
  190.     {
  191.     format(pstring, sizeof(pstring), "Utenti/%s.ini", name);
  192.     opened_file = INI_Open(pstring);
  193.     new pyear, pmonth, pday, phour, pminute, psecond;
  194.     getdate(pyear,pmonth,pday),gettime(phour,pminute,psecond);
  195.     format(pstring, 500, "%d/%d/%04d - %02d:%02d:%02d", pday, pmonth, pyear, phour, pminute, psecond);
  196.     new ip[20];
  197.     GetPlayerIp(playerid, ip, 20);
  198.     INI_WriteString(opened_file, "Ultimo_Login", pstring);
  199.     INI_WriteString(opened_file, "Ultimo_IP", ip);
  200.     INI_WriteInt(opened_file, "Livello_Admin", player_stat[playerid][admin_level]);
  201.     INI_WriteInt(opened_file, "Punti", player_stat[playerid][score]);
  202.     INI_WriteInt(opened_file, "Soldi", player_stat[playerid][money]);
  203.     INI_Close(opened_file);
  204.     }
  205.     return 1;
  206.     }
Add Comment
Please, Sign In to add comment