Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=======================Includes
- #include <a_samp>
- #include <dini>
- #include <dudb>
- #pragma unused ret_memcpy
- #define REGISTER_DIALOG 1200
- #define LOGIN_DIALOG 1300
- #define righe 5035
- #define aggiornamento "12/06/2010"
- #define versione "0.1"
- //=======================Colori
- #define BLU_CHIARO 0x00BFFFAA
- //============================New
- enum pInfo
- {
- pAdmin,
- pSoldi,
- pLivello,
- pKills,
- pDeaths,
- pRegistrato,
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new pFile[64], Ip[16];
- new nome[24];
- new stringa[500];
- new Avvisi[MAX_PLAYERS] = 0;
- new Count[MAX_PLAYERS];
- new Tempo[MAX_PLAYERS];
- //============================Bool
- new bool: Loggato[MAX_PLAYERS];
- main()
- {
- print("\n-------------GameMode Caricata-------------");
- print(" Nome GameMode: FreeMode Server");
- print(" A");
- print(" Versione: 0.1");
- print(" a");
- print(" d");
- print("------------------------------------------\n");
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("FreeMode v0.1");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- //============================Messaggio Iniziale
- new ora, minuti;
- gettime(ora, minuti);
- SetPlayerTime(playerid, ora, minuti);
- SetTimerEx("Telecamera", 100, false, "d", playerid);
- GetPlayerIp(playerid, Ip, 16);
- GetPlayerName(playerid, nome, 24);
- SendClientMessage(playerid, BLU_CHIARO, "{00FF00}__________________________{FFFFFF}__________________________{FF4444}__________________________");
- SendClientMessage(playerid, BLU_CHIARO, "");
- format(stringa, sizeof stringa, "{FFFFFF}Benvenuto {FFFF00}%s{FFFFFF}, {FFFFFF}ti sei connesso alle {FFFF00}%02d{FFFFFF}:{FFFF00}%02d {FFFFFF}con Ip: {FFFF00}%s", nome, ora, minuti, Ip);
- SendClientMessage(playerid, BLU_CHIARO, stringa);
- SendClientMessage(playerid, BLU_CHIARO, "{FFFFFF}Gamemode scriptata interamente da {FFFF00}Anthony Boss{FFFFFF}:");
- format(stringa, sizeof stringa, "{FFFFFF}Numero di righe: {FFFF00}%d{FFFFFF} Aggiornamento: {FFFF00}%s{FFFFFF} Versione: {FFFF00}%s{FFFFFF}", righe, aggiornamento, versione);
- SendClientMessage(playerid, BLU_CHIARO, stringa);
- SendClientMessage(playerid, BLU_CHIARO, "{00FF00}__________________________{FFFFFF}__________________________{FF4444}__________________________");
- PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
- GameTextForPlayer(playerid, "~g~Benvenuto!", 6000, 1);
- //============================File Dini
- format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
- if(!fexist(pFile))
- {
- GetPlayerName(playerid, nome, 24);
- format(stringa, sizeof(stringa), "{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\n{FFFFFF}Non sei registrato.\nPer giocare è necessario registrare il proprio account.\nRegistrandoti, accetti le regole del Server.\n\nInserisci una {FF4444}password{FFFFFF} per registrarti.", nome);
- ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Registrati", "Chiudi");
- }
- else if(fexist(pFile))
- {
- GetPlayerName(playerid, nome, 24);
- format(stringa, sizeof(stringa), "{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\nIl tuo Account risulta registrato.\n\n{FFFFFF}Inserisci la {FF4444}password{FFFFFF} per fare il Login.", nome);
- ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Login", "Chiudi");
- format(stringa, sizeof(stringa), "** {00BFFF}%s{FFFFFF}è entrato sul server.", nome);
- SendClientMessageToAll(BLU_CHIARO, stringa);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new nome[24];
- GetPlayerName(playerid, nome, 24);
- format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
- if(dini_Exists(pFile))
- {
- Tempo[playerid] = Count[playerid] - GetTickCount();
- new str[32];
- if(!dini_Isset(pFile, "Tempo")) format(str, 32, "%02d:%02d:%02d", floatround(Tempo[playerid]/3600000, floatround_floor), floatfract(Tempo[playerid]/3600000)*60, floatfract(Tempo[playerid]/60000)*60), dini_Set(pFile, "Tempo", str);
- else
- {
- new string[32];
- new time[3];
- string = dini_Get(pFile, "Tempo");
- format(str, 32, "%02d, %02d, %02d", floatround(Tempo[playerid]/3600000, floatround_floor) + strval(format(time, 3, "%s%s", string[0], string[1])), (floatfract(Tempo[playerid]/3600000)*60) + strval(format(time, 3, "%s%s", string[3], string[4])) , (floatfract(Tempo[playerid]/60000)*60) + strval(format(time, 3, "%s%s", string[6], string[7])));
- dini_Set(pFile, "Tempo", str);
- }
- }
- SalvaAccount(playerid);
- Avvisi[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- /*=================================Registrazione*/
- if(dialogid == REGISTER_DIALOG)
- {
- if(response)
- {
- GetPlayerName(playerid, nome, 24);
- if(!strlen(inputtext))
- {
- format(stringa, sizeof(stringa), "{FF4444}Errore:{FFFFFF} Inserisci una password.\n\n{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\n{FFFFFF}Non sei registrato.\nPer giocare è necessario registrare il proprio account.\nRegistrandoti, accetti le regole del Server.\n\nInserisci una {FF4444}password{FFFFFF} per registrarti.", nome);
- ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Registrati", "Chiudi");
- return 0;
- }
- if(strfind(inputtext, "=", true) == 0)
- {
- format(stringa, sizeof(stringa), "{FF4444}Errore:{FFFFFF} Non puoi utilizzare {FF4444}={FFFFFF} come password.\n\n{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\n{FFFFFF}Non sei registrato.\nPer giocare è necessario registrare il proprio account.\nRegistrandoti, accetti le regole del Server.\n\nInserisci una {FF4444}password{FFFFFF} per registrarti.", nome);
- ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Registrati", "Chiudi");
- return 0;
- }
- format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
- dini_Create(pFile);
- dini_Set(pFile, "Password", inputtext);
- dini_IntSet(pFile, "Soldi", 0);
- dini_IntSet(pFile, "Kills", 0);
- dini_IntSet(pFile, "Deaths", 0);
- dini_IntSet(pFile, "Admin", 0);
- dini_IntSet(pFile, "Livello", 0);
- dini_IntSet(pFile, "Registrato", 0);
- format(stringa, sizeof(stringa), "{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\nHai registrato con successo un Account.\nOra esegui il Login per inizare a giocare.\n\n{FFFFFF}Inserisci la password del tuo Account.", nome);
- ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Login", "Chiudi");
- SendClientMessage(playerid, BLU_CHIARO, "* {FFFFFF}Hai creato con successo un account. Ora esegui il Login.");
- }
- else if(!response)
- {
- SendClientMessage(playerid, BLU_CHIARO, "{00FF00}[Info:] {FFFFFF}Sei stato kickato. Motivo: {FF66FF}Registrazione obbligatoria{FFFFFF}.");
- GetPlayerName(playerid, nome, 24);
- format(stringa, sizeof(stringa), "{00FF00}[Info:]{FFFFFF}%s{00BFFF} è stato kickato dal Server. Motivo: {FFFFFF}Registrazione obbligatoria{00BFFF}.", nome);
- SendClientMessageToAll(BLU_CHIARO, stringa);
- Kick(playerid);
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- }
- /*===============================Login*/
- if(dialogid == LOGIN_DIALOG)
- {
- if(response)
- {
- GetPlayerName(playerid, nome, 24);
- if(!strlen(inputtext))
- {
- format(stringa, sizeof stringa, "{FF4444}Errore:{FFFFFF} Inserisci una password.\n\n{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\nIl tuo Account risulta registrato.\n\n{FFFFFF}Inserisci la password del tuo Account.", nome);
- ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Login", "Chiudi");
- return 0;
- }
- if(!strcmp(inputtext, dini_Get(pFile, "Password"), false))
- {
- format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
- Loggato[playerid] = true;
- ResetPlayerMoney(playerid);
- Count[playerid] = GetTickCount();
- GivePlayerMoney(playerid, dini_Int(pFile, "Soldi"));
- PlayerInfo[playerid][pKills] = dini_Int(pFile, "Kills");
- PlayerInfo[playerid][pDeaths] = dini_Int(pFile, "Deaths");
- PlayerInfo[playerid][pLivello] = dini_Int(pFile, "Livello");
- PlayerInfo[playerid][pAdmin] = dini_Int(pFile, "Admin");
- PlayerInfo[playerid][pRegistrato] = 1;
- Count[playerid] = GetTickCount();
- format(stringa, sizeof(stringa), "* {FFFFFF}Benvenuto {33AA33}%s{FFFFFF}, i tuoi dati sono stati caricati con successo..", nome);
- SendClientMessage(playerid, BLU_CHIARO, stringa);
- return 1;
- }
- else
- {
- format(stringa, sizeof(stringa), "{FF4444}[Errore:]{FFFFFF} Password errata, al terzo tentativo sbagliato, verrai {FF4444}kickato{FFFFFF}.\n\n{FFFFFF}Benvenuto {FF4444}%s{FFFFFF}!\nIl tuo Account risulta registrato.\n\n{FFFFFF}Inserisci la password del tuo Account.", nome);
- ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "{33AA33}Account:", stringa, "Login", "Chiudi");
- Avvisi[playerid] ++;
- if(Avvisi[playerid] == 3)
- {
- SendClientMessage(playerid, BLU_CHIARO, "{00FF00}[Info:] {FFFFFF}Sei stato kickato. Motivo: {FF66FF}Tentativi Login falliti{FFFFFF}.");
- format(stringa, sizeof(stringa), "{00FF00}[Info:]{FFFFFF}%s{00BFFF} è stato kickato dal Server. Motivo: {FFFFFF}Tentativi Login falliti{00BFFF}.", nome);
- SendClientMessageToAll(BLU_CHIARO, stringa);
- Kick(playerid);
- }
- return 0;
- }
- }
- else if(!response)
- {
- GetPlayerName(playerid, nome, 24);
- SendClientMessage(playerid, BLU_CHIARO, "{00FF00}[Info:] {FFFFFF}Sei stato kickato. Motivo: {FF66FF}Login obbligatorio{FFFFFF}.");
- format(stringa, sizeof(stringa), "{00FF00}[Info:] {FFFFFF}%s{00BFFF} è stato kickato dal Server. Motivo: {FFFFFF}Login obbligatorio{00BFFF}.", nome);
- SendClientMessageToAll(BLU_CHIARO, stringa);
- Kick(playerid);
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //Strtok
- stock strrest(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[128];
- while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- //Salva Account
- SalvaAccount(playerid)
- {
- GetPlayerName(playerid, nome, 24);
- format(pFile, sizeof(pFile), "Utenti/%s.ini", nome);
- dini_IntSet(pFile, "Soldi", GetPlayerMoney(playerid));
- dini_IntSet(pFile, "Kills", PlayerInfo[playerid][pKills]);
- dini_IntSet(pFile, "Deaths", PlayerInfo[playerid][pDeaths]);
- dini_IntSet(pFile, "Admin", PlayerInfo[playerid][pAdmin]);
- dini_IntSet(pFile, "Livello", PlayerInfo[playerid][pLivello]);
- dini_IntSet(pFile, "Registrato", PlayerInfo[playerid][pRegistrato]);
- Loggato[playerid] = false;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement