Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Sanady Registration System 1.0(2012)(c)
- //
- #include <a_samp>
- #include <dini>
- #include <dudb>
- #pragma unused ret_memcpy
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define ERROR 0xFF0000AA
- #define SYSTEM 0x375FFFFF
- #define blue 0x375FFFFF
- #define red 0xFF0000FF
- #define white 0xFFFFFFFF
- #define green 0x33FF33FF
- #define yellow 0xFFFF00FF
- #define grey 0xC0C0C0FF
- #define orange 0xFF9900FF
- #define pink 0xFF66FFFF
- #define embed_blue "{00C0FF}"
- #define embed_red "{FF0000}"
- #define embed_white "{FFFFFF}"
- #define embed_green "{33FF33}"
- #define embed_yellow "{E8D04C}"
- #define embed_grey "{C0C0C0}"
- #define embed_orange "{FF9900}"
- #define embed_pink "{FF66FF}"
- #define embed_lblue "{00AFFF}"
- #define embed_sw "{ED136A}"
- #define color_ok 0xFFFF00FF
- #define color_wa 0xFF9900AA
- #define COL_GREEN "{6EF83C}" // GREEN color in HEX ( USED )
- #define COL_RED "{F81414}" // RED color in HEX ( USED )
- #define COL_BLUE "{00C0FF}" // BLUE color in HEX ( USED )
- #define MAX_FAIL_LOGINS 3
- enum PlayerInfo
- {
- pLevel,
- pMoney,
- pScore,
- pKills,
- pFailLogins,
- pDeaths,
- }
- new pInfo[MAX_PLAYERS][PlayerInfo];
- new gPlayerLogged[MAX_PLAYERS];
- #define SERVER_USER_FILE "SanadyReg/Accounts/%s.ini"
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Sanady Registration System 1.0");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- main()
- {
- print("\n----------------------------------");
- print(" Sanady Registration System 1.0");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- gPlayerLogged[playerid] = 0;
- new file[256],string[226],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if (!dini_Exists(file))
- {
- format(string, sizeof(string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}.{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}, you're "COL_RED"not{FFFFFF} registered\n\nPlease log in by inputting your password.", name, playerid);
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{FFFFFF}Registration", string, "Register", "Leave");
- }
- if(fexist(file))
- {
- format(string, sizeof(string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}.You're registered\n\nPlease log in by inputting your password.",name, playerid);
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login", string, "Login", "Leave");
- }
- TogglePlayerSpectating(playerid,0);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new file[256],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(gPlayerLogged[playerid] == 1)
- {
- dini_IntSet(file, "Score", pInfo[playerid][pScore]);
- dini_IntSet(file, "Money", pInfo[playerid][pMoney]);
- dini_IntSet(file, "AdminLevel",pInfo[playerid][pLevel]);
- dini_IntSet(file, "Kills",pInfo[playerid][pKills]);
- dini_IntSet(file, "Deaths",pInfo[playerid][pDeaths]);
- }
- gPlayerLogged[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- pInfo[killerid][pKills] ++;
- pInfo[playerid][pDeaths] ++;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if (dialogid == 1)
- {
- new file[256],name[MAX_PLAYER_NAME],string[158];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(!response) return Kick(playerid);
- if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "{FFFFFF}Registration", ""COL_RED"[ERROR]{FFFFFF}Please input password!", "Register", "Leave");
- dini_Create(file);
- dini_IntSet(file, "Password", udb_hash(inputtext));
- dini_IntSet(file, "AdminLevel",pInfo[playerid][pLevel] = 0);
- dini_IntSet(file, "Money",pInfo[playerid][pMoney] = 500);
- dini_IntSet(file, "Score",pInfo[playerid][pScore] = 0);
- dini_IntSet(file, "Kills",pInfo[playerid][pKills] = 0);
- dini_IntSet(file, "Deaths",pInfo[playerid][pDeaths] = 0);
- format(string,sizeof(string),"{FFFFFF}You have been {8CF051}succesfully {FFFFFF}registred\n\n\nAlso you need to log in.Press button "COL_BLUE"continue {FFFFFF}to log in!");
- ShowPlayerDialog(playerid, 3,DIALOG_STYLE_MSGBOX,"{FFFFFF}Welcome",string,"Continue","");
- }
- if (dialogid == 2)
- {
- new name[MAX_PLAYER_NAME], file[256],string[227];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(!response) return Kick(playerid);
- if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{FFFFFF}", ""COL_RED"[ERROR]{FFFFFF}Please input right password!", "Login", "Leave");
- new tmp;
- tmp = dini_Int(file, "Password");
- if(udb_hash(inputtext) != tmp)
- {
- format(string, sizeof (string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}.You're registered\n\nPlease log in by inputting your password.\n"embed_red"Wrong password!", name,playerid);
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD,"{FFFFFF}Login", string,"Login","Kick");
- pInfo[playerid][pFailLogins]++;
- if(pInfo[playerid][pFailLogins] >= MAX_FAIL_LOGINS)
- {
- SendClientMessage(playerid, red, "[ERROR]"embed_grey"Failed to login!");
- Kick(playerid);
- return 1;
- }
- }
- else
- {
- gPlayerLogged[playerid] = 1;
- pInfo[playerid][pLevel] = dini_Int(file, "AdminLevel");
- SetPlayerScore(playerid, pInfo[playerid][pScore]);
- GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
- pInfo[playerid][pKills] = dini_Int(file, "Kills");
- pInfo[playerid][pDeaths] = dini_Int(file, "Deaths");
- SendClientMessage(playerid,0xFFFFFFF,""embed_blue"[INFO]{FFFFFF}You have been {8CF051}succesfully {FFFFFF}logged in.");
- }
- }
- if (dialogid == 3)
- {
- new string[134],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- format(string, sizeof(string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF}.You're registered\n\nPlease log in by inputting your password.", name, playerid);
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login", string, "Login", "Leave");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement