Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- I would appreciate it if you add my name in the credits if you use this FS in your server
- ______ ____ ______ ____ ___
- | | | /\ | | | | |__|
- | | XCZ<XCX<C|---- /--\ | |---| |---- | \
- _|____| |____/ \ | | | |____ | \
- DARE TO DIE
- Notes:
- 1. You need 'dRegis' folder in the scriptfiles folder.
- 2. Donot Remove these credits.
- 3. You can edit it for your own purpose but you are not allowed to realease this without my permission.
- */
- //********************************INCLUDES************************************//
- //============================================================================//
- #include <a_samp>
- #include <dini>
- #include <dutils>
- //**********************************COLORS************************************//
- //============================================================================//
- #define COLOR_MESSAGE 0x00C7FFAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_BLUE 0x0000BBAA
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xFF0000FF
- #define COLOR_YELLOW 0xFFFF0088
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_LIGHTRED 0xFF6347AA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOUR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_LIGHTGREEN 0x9ACD32AA
- #define COLOR_GREEN2 0x33FF33AA
- #define COLOR_ERROR 0xFF0000AA
- #define COLOR_MSG 0x00FFFFFF
- #define COLOR_PINK 0xFF66FFAA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_GREEN1 0x33AA33AA
- #define COLOR_BROWN 0xA52A2AAA
- #define COLOR_PURPLE 0x800080AA
- #define COLOR_BLACK 0x000000AA
- #define COLOR_GREEN1 0x33AA33AA
- //**********************************DIALOGS***********************************//
- //============================================================================//
- #define REGISTERDIALOG 500
- #define LOGINDIALOG 501
- #define STATS 502DFASD
- #define AUTOLOGIN 503
- //*******************************DEFINE DCMD**********************************//
- //============================================================================//
- #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
- //**********************************ENUM*************************************//
- //============================================================================//
- enum PlayerData
- {
- Name[MAX_PLAYER_NAME],
- IP[16],
- Registered,
- Password,
- LoggedIn,
- Autologin,
- Kills,
- Deaths
- };
- //***********************************NEW**************************************//
- //============================================================================//
- new PlayerInfo[MAX_PLAYERS][PlayerData];
- //*******************************CALLBACKS************************************//
- //============================================================================//
- public OnFilterScriptInit()
- {
- printf("******************************************************************");
- printf("---deather's Dialog Registration System by 'Deather' has been loaded---");
- printf("******************************************************************");
- return 1;
- }
- //============================================================================//
- public OnPlayerConnect(playerid)
- {
- new playername[MAX_PLAYER_NAME];
- new string1[64];
- GetPlayerName(playerid, playername, sizeof(playername));
- format(string1, sizeof(string1), "--%s (ID: %d) has joined the server--", playername, playerid);
- SendClientMessageToAll(COLOR_LIGHTBLUE, string1);
- new file[128];
- format(file, sizeof(file), "dRegis/%s.ini", pName(playerid));
- PlayerInfo[playerid][Name] = playername;
- PlayerInfo[playerid][IP] = 0;
- PlayerInfo[playerid][Registered] = 0;
- PlayerInfo[playerid][LoggedIn] = 0;
- PlayerInfo[playerid][Autologin] = 0;
- PlayerInfo[playerid][Password] = 0;
- PlayerInfo[playerid][Password] = dini_Int(file,"Password");
- PlayerInfo[playerid][Kills] = dini_Int(file,"Kills");
- PlayerInfo[playerid][Deaths] = dini_Int(file,"Deaths");
- if(userfile(playerid))
- {
- new RegIP_hash;
- RegIP_hash = num_hash(dini_Get(file,"Ip"));
- new playerIp[16];
- GetPlayerIp(playerid,playerIp,sizeof(playerIp));
- new playerIP_hash;
- playerIP_hash = num_hash(playerIp);
- if(PlayerInfo[playerid][Autologin] == 1)
- {
- if(playerIP_hash == RegIP_hash)
- {
- Autolog(playerid);
- new autolog[128];
- ShowPlayerDialog(playerid, AUTOLOGIN, DIALOG_STYLE_MSGBOX,"Deather's AutoLogin",autolog,"Ok","Cancel");
- format(autolog, sizeof(autolog), "Welcome back %s. You have been automatically logged in.", pName(playerid));
- }
- }
- else
- {
- ShowPlayerDialog(playerid, LOGINDIALOG, DIALOG_STYLE_INPUT, "Deather's Login", "Enter your Password to login to your account", "Login", "Cancel");
- new msg2[128];
- format(msg2, sizeof(msg2), "Welcome back. Your account is registered. Please Login.");
- SendClientMessage(playerid, COLOR_LIGHTGREEN, msg2);
- }
- }
- else
- {
- ShowPlayerDialog(playerid, REGISTERDIALOG ,DIALOG_STYLE_INPUT, "Deather's Registration", "Please enter a New Password and Register with our server.\n And do remember this password for your future Logins","Register","Cancel");
- new msg3[128];
- format(msg3, sizeof(msg3), "Welcome to our server %s. You are not registered yet. Please reigster before you continue.", pName(playerid));
- SendClientMessage(playerid, COLOR_LIGHTGREEN, msg3);
- }
- return 1;
- }
- //============================================================================//
- public OnPlayerDisconnect(playerid, reason)
- {
- new playerName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, playerName, sizeof(playerName));
- switch(reason)
- {
- case 0: format(string, sizeof(string), "%s has left the server. (Ping Timeout)", playerName);
- case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", playerName);
- case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", playerName);
- }
- SendClientMessageToAll(COLOR_GREY, string);
- new pfile[256];
- format(pfile,sizeof(pfile),"dRegis/%s.ini", pName(playerid));
- dini_IntSet(pfile,"Kills",PlayerInfo[playerid][Kills]);
- dini_IntSet(pfile,"Deaths",PlayerInfo[playerid][Deaths]);
- return 1;
- }
- //============================================================================//
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new playername[MAX_PLAYERS];
- GetPlayerName(playerid, playername, sizeof(playername));
- if(dialogid == REGISTERDIALOG)
- {
- if(response == 1)
- {
- if(!inputtext[0])
- {
- ShowPlayerDialog(playerid, REGISTERDIALOG ,DIALOG_STYLE_INPUT, "Deather's Registration", "Enter the password for your account.","Register","Cancel");
- return 1;
- }
- new pfile[128];
- format(pfile, sizeof(pfile), "dRegis/%s.ini", pName(playerid));
- new Ip[16];
- GetPlayerIp(playerid,Ip,sizeof(Ip));
- new password = num_hash(inputtext);
- PlayerInfo[playerid][Password] = password;
- PlayerInfo[playerid][Registered] = 1;
- PlayerInfo[playerid][LoggedIn] = 1;
- dini_Create(pfile);
- dini_IntSet(pfile,"Password",PlayerInfo[playerid][Password]);
- dini_Set(pfile,"Ip",Ip);
- PlayerInfo[playerid][Kills] = 0;
- PlayerInfo[playerid][Deaths] = 0;
- dini_IntSet(pfile,"Kills",0);
- dini_IntSet(pfile,"Deaths",0);
- SendClientMessage(playerid, COLOR_GREY, "Registration Done");
- SendClientMessage(playerid, COLOR_GREY, "Welcome to the server.");
- new string[256];
- format(string, sizeof(string), "Your New Password is: \'%s\'.", inputtext);
- SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
- }
- if(response == 0)
- {
- Kick(playerid);
- new string[256];
- format(string, sizeof(string),"%s hasn't registered and so have been kicked from the server",playername);
- SendClientMessageToAll(COLOR_RED, string);
- }
- }
- if(dialogid == LOGINDIALOG)
- {
- if(response == 1)
- {
- new password = num_hash(inputtext);
- if(PlayerInfo[playerid][Password] == password)
- Autolog(playerid);
- SendClientMessage(playerid, COLOR_LIGHTGREEN, "Welcome back to the server. You have successfully been logged in.");
- }
- else
- {
- Kick(playerid);
- new string1[256];
- format(string1, sizeof(string1),"%s hasn't logged in and so have been kicked from the server",playername);
- SendClientMessageToAll(COLOR_RED, string1);
- }
- }
- if(response == 0)
- {
- Kick(playerid);
- new string1[256];
- format(string1, sizeof(string1),"%s hasn't logged in and so have been kicked from the server",playername);
- SendClientMessageToAll(COLOR_RED, string1);
- }
- return 1;
- }
- //============================================================================//
- public OnPlayerDeath(playerid, killerid, reason)
- {
- new pname[24], kfile[50], pfile[50], kname[24];
- GetPlayerName(playerid, pname, sizeof(pname));
- GetPlayerName(killerid, kname, sizeof(kname));
- format(kfile, sizeof(kfile), "dRegis/%s.ini", kname);
- format(pfile, sizeof(pfile), "dRegis/%s.ini", pname);
- if(killerid == INVALID_PLAYER_ID)
- {
- SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
- PlayerInfo[playerid][Deaths]++;
- dini_IntSet(pfile, "Deaths", PlayerInfo[playerid][Deaths]);
- }
- else
- {
- SendDeathMessage(killerid, playerid, reason);
- PlayerInfo[killerid][Kills]++;
- PlayerInfo[playerid][Deaths]++;
- dini_IntSet(pfile, "Deaths", PlayerInfo[playerid][Deaths]);
- dini_IntSet(pfile, "Kills", PlayerInfo[killerid][Kills]);
- }
- return 1;
- }
- //============================================================================//
- public OnPlayerClickPlayer(playerid,clickedplayerid,source)
- {
- if(clickedplayerid == playerid)
- {
- new statstr[500];
- format(statstr, sizeof(statstr), "Name: %s\nIP: %d\nKills: %d\nDeaths: %d",PlayerInfo[playerid][Name],PlayerInfo[playerid][IP],PlayerInfo[playerid][Kills],PlayerInfo[playerid][Deaths]);
- ShowPlayerDialog(playerid, STATS, DIALOG_STYLE_MSGBOX,"Player Stats", statstr, "Ok", "Cancel");
- }
- return 1;
- }
- //**********************************STOCKS************************************//
- //============================================================================//
- stock pName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- //============================================================================//
- stock userfile(playerid)
- {
- new FilePath[128];
- format(FilePath, sizeof(FilePath), "dRegis/%s.ini", pName(playerid));
- if(dini_Exists(FilePath)) return 1;
- return 0;
- }
- //============================================================================//
- stock Autolog(playerid)
- {
- new file[128];
- format(file, sizeof(file), "dRegis/%s.ini", pName(playerid));
- PlayerInfo[playerid][LoggedIn] = 1;
- PlayerInfo[playerid][Registered] = 1;
- PlayerInfo[playerid][Kills] = dini_Int(file,"Kills");
- PlayerInfo[playerid][Deaths] = dini_Int(file,"Deaths");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement