Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #include <YSI\y_ini>
- #if defined FILTERSCRIPT
- #endif
- #define DIALOG_REG 1
- #define DIALOG_LOGIN 2
- #define SYSTEM_RED 0xE7321BFF //Colore rosso per messaggi di errore
- #define MAX_FAILED_LOGIN 3 //Massimo numero di login falliti
- enum stat_info {admin_level, score, money, failed_login, bool: logged}; //Statistiche players
- new player_stat[MAX_PLAYERS][stat_info];
- new pstring[500], p_password[20], bool: banned; //Array & check bannato al login
- new INI: opened_file; //var che identifica il file aperto
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new name[24];
- GetPlayerName(playerid, name, 24);
- format(pstring,sizeof(pstring), "/Utenti/%s.ini", name);
- if(!fexist(pstring))
- {
- 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);
- ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registrazione...", pstring, "Registrati", "");
- return 1;
- }
- else
- {
- 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);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login!", "");
- return 1;
- }
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new name[24];
- GetPlayerName(playerid, name, 24);
- switch(dialogid)
- {
- case DIALOG_REG:
- {
- if(!response)
- {
- PlayerPlaySound(playerid, 1055, 0, 0 ,0); //Suoni per errori
- SendClientMessage(playerid, SYSTEM_RED, "[SERVER:] {C1C1C1}Ci dispiace la registrazione è obbligatoria. Sei stato kickato.");
- Kick(playerid);
- return 1;
- }
- if(!strlen(inputtext))
- {
- PlayerPlaySound(playerid, 1055, 0, 0 ,0);
- 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);
- ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registrazione...", pstring, "Registrati", "");
- return 1;
- }
- if(strlen(inputtext) > 20)
- {
- PlayerPlaySound(playerid, 1055, 0, 0 ,0);
- 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);
- ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_INPUT, "Registrazione...", pstring, "Registrati", "");
- return 1;
- }
- PlayerPlaySound(playerid, 1055, 0, 0 ,0);
- GetPlayerName(playerid, name, 24);
- format(pstring,sizeof(pstring),"/Utenti/%s.ini",name);
- opened_file = INI_Open(pstring);
- new pyear, pmonth, pday, phour, pminute, psecond;
- getdate(pyear,pmonth,pday),gettime(phour,pminute,psecond);
- format(pstring, 500, "%d/%d/%04d - %02d:%02d:%02d", pday, pmonth, pyear, phour, pminute, psecond);
- new ip[20];
- GetPlayerIp(playerid, ip, 20);
- INI_WriteString(opened_file, "Password", inputtext);
- INI_WriteString(opened_file, "Data_Registrazione", pstring);
- INI_WriteString(opened_file, "Ultimo_Login", pstring);
- INI_WriteString(opened_file, "IP_Registrazione", ip);
- INI_WriteString(opened_file, "Ultimo_IP", ip);
- INI_WriteInt(opened_file, "Livello_Admin", 0);
- INI_WriteInt(opened_file, "Punti", 0);
- INI_WriteInt(opened_file, "Soldi", 0);
- INI_WriteBool(opened_file, "Bannato", false);
- INI_Close(opened_file);
- 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);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login!", "");
- return 1;
- }
- case DIALOG_LOGIN:
- {
- if(!response)
- {
- PlayerPlaySound(playerid, 1055, 0, 0 ,0);
- SendClientMessage(playerid, SYSTEM_RED, "[SERVER:] {C1C1C1}Ci dispiace il login è obbligatorio. Sei stato kickato.");
- Kick(playerid);
- return 1;
- }
- if(!strlen(inputtext))
- {
- PlayerPlaySound(playerid, 1055, 0, 0 ,0);
- 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);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
- return 1;
- }
- if(strlen(inputtext) > 20)
- {
- PlayerPlaySound(playerid, 1055, 0, 0 ,0);
- 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);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
- return 1;
- }
- format(pstring,sizeof(pstring),"/Utenti/%s.ini",name);
- INI_ParseFile(pstring, "Parse_Player_Pass", .bExtra = true, .extra = playerid);
- if(strcmp(inputtext, p_password, true))
- {
- player_stat[playerid][failed_login]++;
- PlayerPlaySound(playerid, 1055, 0, 0 ,0);
- if(player_stat[playerid][failed_login] == MAX_FAILED_LOGIN)
- {
- SendClientMessage(playerid, SYSTEM_RED, "[SERVER:] {C1C1C1}Hai superato il limite massimo di tentativi per il login. Sei stato kickato.");
- Kick(playerid);
- return 1;
- }
- 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);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login...", pstring, "Login", "");
- return 1;
- }
- else
- {
- format(pstring,sizeof(pstring),"/Utenti/%s.ini",name);
- INI_ParseFile(pstring,"Load_Player_Data", .bExtra = true, .extra = playerid);
- if(banned)
- {
- banned = false;
- SendClientMessage(playerid, SYSTEM_RED, "Questo account risulta bannato dal server.");
- Kick(playerid);
- return 2;
- }
- player_stat[playerid][logged] = true;
- return 1;
- }
- }
- }
- return 1;
- }
- forward Parse_Player_Pass(playerid, name[], value[]);
- public Parse_Player_Pass(playerid, name[], value[])
- {
- INI_String("Password", p_password, 20);
- return 1;
- }
- forward Load_Player_Data(playerid, name[], value[]);
- public Load_Player_Data(playerid, name[], value[])
- {
- INI_Int("Livello_Admin", player_stat[playerid][admin_level]);
- INI_Int("Soldi", player_stat[playerid][money]);
- INI_Int("Punti", player_stat[playerid][score]);
- INI_Bool("Bannato", banned);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new name[24];
- GetPlayerName(playerid, name, sizeof(name));
- switch(reason)
- {
- case 0: format(pstring, 500, "{B0EC1B}%s {C1C1C1}si è disconnesso dal server {A1A1A1}[crash].", name);
- case 1: format(pstring, 500, "{B0EC1B}%s {C1C1C1}si è disconnesso dal server.", name);
- case 2: format(pstring, 500, "{B0EC1B}%s {C1C1C1}si è disconnesso dal server {A1A1A1}[kick/ban].", name);
- }
- SendClientMessageToAll(-1, pstring);
- if(player_stat[playerid][logged])
- {
- format(pstring, sizeof(pstring), "Utenti/%s.ini", name);
- opened_file = INI_Open(pstring);
- new pyear, pmonth, pday, phour, pminute, psecond;
- getdate(pyear,pmonth,pday),gettime(phour,pminute,psecond);
- format(pstring, 500, "%d/%d/%04d - %02d:%02d:%02d", pday, pmonth, pyear, phour, pminute, psecond);
- new ip[20];
- GetPlayerIp(playerid, ip, 20);
- INI_WriteString(opened_file, "Ultimo_Login", pstring);
- INI_WriteString(opened_file, "Ultimo_IP", ip);
- INI_WriteInt(opened_file, "Livello_Admin", player_stat[playerid][admin_level]);
- INI_WriteInt(opened_file, "Punti", player_stat[playerid][score]);
- INI_WriteInt(opened_file, "Soldi", player_stat[playerid][money]);
- INI_Close(opened_file);
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment