Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////
- // /* Register And Login System by $teVe. */
- // /* Please do not change anything in here. */
- // /* Leave my Credits Too Please. */
- ////////////////////////////////////////////////
- #include <a_samp>
- #include <dini>
- ////////////////
- // /* Defines */
- ////////////////
- // Colors (For the Colors wich the player's recieve).
- #define red 0xAA3333AA
- #define RED 0xAA3333AA
- #define COLOUR_RED 0xAA3333AA
- #define COLOR_VIOLETRED 0xDB7093FF
- #define COLOR_LIGHTGREEN 0x00FF00FF
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GRELLOW 0xFFFF00AA
- #define COLOR_WHITE 0x0000BBAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_LIME 0x10F441AA
- #define COLOR_MAGENTA 0xFF00FFFF
- #define COLOR_NAVY 0x000080AA
- #define COLOR_AQUA 0xF0F8FFAA
- #define COLOR_CRIMSON 0xDC143CAA
- #define COLOR_FLBLUE 0x6495EDAA
- #define COLOR_BISQUE 0xFFE4C4AA
- #define COLOR_BLACK 0x000000AA
- #define COLOR_CHARTREUSE 0x7FFF00AA
- #define COLOR_BROWN 0xA52A2AAA
- #define COLOR_CORAL 0xFF7F50AA
- #define COLOR_GOLD 0xB8860BAA
- #define COLOR_GREENYELLOW 0xADFF2FAA
- #define COLOR_INDIGO 0x4B00B0AA
- #define COLOR_IVORY 0xFFFF82AA
- #define COLOR_LAWNGREEN 0x7CFC00AA
- #define COLOR_SEAGREEN 0x20B2AAAA
- #define COLOR_LIMEGREEN 0x32CD32AA
- #define COLOR_MIDNIGHTBLUE 0x191970AA
- #define COLOR_MAROON 0x800000AA
- #define COLOR_OLIVE 0x808000AA
- #define COLOR_ORANGERED 0xFF4500AA
- #define COLOR_PINK 0xFFC0CBAA
- #define COLOR_SPRINGGREEN 0x00FF7FAA
- #define COLOR_TOMATO 0xFF6347AA
- #define COLOR_YELLOWGREEN 0x9ACD32AA
- #define COLOR_MEDIUMAQUA 0x83BFBFAA
- #define COLOR_MEDIUMMAGENTA 0x8B008BAA
- #define COLOR_MAROON 0x800000AA
- #define COLOR_OLIVE 0x808000AA
- #define COLOR_ORANGERED 0xFF4500AA
- #define COLOR_PINK 0xFFC0CBAA
- #define COLOR_SPRINGGREEN 0x00FF7FAA
- #define COLOR_TOMATO 0xFF6347AA
- #define COLOR_YELLOWGREEN 0x9ACD32AA
- #define COLOR_MEDIUMAQUA 0x83BFBFAA
- #define ADMIN_RED 0xFB0000FF
- #define ADMINRED 0xFB0000FF
- #define YELLOW 0xFFFF00FF
- #define COLOUR_YELLOW 0xFFFF00FF
- #define ORANGE 0xF97804FF
- #define LIGHTRED 0xFF8080FF
- #define LIGHTBLUE 0x00C2ECFF
- #define LIGHTBLUE2 0x00C2ECFF
- #define PURPLE 0xB360FDFF
- #define PLAYER_COLOR 0xFFFFFFFF
- #define BLUE 0x1229FAFF
- #define blue 0x1229FAFF
- #define BLAU 0x1229FAFF
- #define LIGHTGREEN 0x38FF06FF
- #define DARKPINK 0xE100E1FF
- #define DARKGREEN 0x008040FF
- #define ANNOUNCEMENT 0x6AF7E1FF
- #define COLOR_SYSTEM 0xEFEFF7AA
- #define GREY 0x99FFFFAA
- #define PINK 0xD52DFFFF
- #define DARKGREY 0x626262FF
- #define AQUAGREEN 0x03D687FF
- #define NICESKY 0x99FFFFAA
- #define WHITE 0xFFFFFFFF
- #define l_red 0xFF0000AA
- #define l_green 0x33FF33AA
- #define ADMINRED 0xFB0000FF
- #define AQUA 0xF0F8FFAA
- #define COLOR_GREEN 0x33AA33AA
- #define GREEN 0x33AA33AA
- #define grey 0xC0C0C0AA
- #define orange 0xFF9900AA
- #define AFK 0x6AF7E1FF
- #define DEDMColor 0xFE9100FF
- #define lightred 0xFB0000AA
- // Hex Colors (For all Colors on the Messages or Dialogs).
- #define HEX_ORANGE "{FF9900}"
- #define HEX_ADMINRED "{FB0000}"
- #define HEX_WHITE "{FFFFFF}"
- #define HEX_PURPLE "{FF00FF}"
- #define HEX_GREY "{C0C0C0}"
- #define HEX_AQUA "{F0F8FF}"
- #define HEX_BLUE "{1229FA}"
- #define HEX_LIGHTGREEN "{38FF06}"
- #define HEX_LIGHTBLUE "{00C2EC}"
- #define HEX_YELLOW "{FFFF00}"
- #define HEX_PINK "{FFC0CB}"
- #define HEX_GREEN "{33AA33}"
- #define HEX_LIGHTRED "{FB0000}"
- #define HEX_GREY "{C0C0C0}"
- #define HEX_BLACK "{000000}"
- // DCMD Define (For all Commands).
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- // Dialog Define (The define for the Dialog IDS).
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- // Filterscript Define (REMOVE IT IF YOU ADD THIS TO YOUR GAMEMODE)!!!!!
- #define FILTERSCRIPT
- // Sets (Comment this lines if you want to Disable the fallowing Functions).
- #define SAVEPLAYERSCORE
- #define SAVEPLAYERMONEY
- #define SAVEPLAYERDEATHS
- #define SHOWINFORMATIONS
- // SendClientMessagef Define (By RyDeR´).
- #if !defined SendClientMessagef || !defined SendClientMessageToAllf || !defined MSGf || !defined MSGToAllf
- new __string[256];
- #define SendClientMessagef(%0,%1,%2) \
- format(__string, sizeof(__string), %2); \
- SendClientMessage((%0), (%1), __string)
- #define SendClientMessageToAllf(%0,%1) \
- format(__string, sizeof(__string), %1); \
- SendClientMessageToAll((%0), __string)
- #define MSGf(%0,%1,%2) \
- format(__string, sizeof(__string), %2); \
- SendClientMessage((%0), (%1), __string)
- #define MSGToAllf(%0,%1) \
- format(__string, sizeof(__string), %1); \
- SendClientMessageToAll((%0), __string)
- #endif
- // Dialog Defines (For the Dialog to show).
- #if !defined ShowRegisterDialog || !defined ShowLoginDialog
- new dString[150];
- #define ShowRegisterDialog(%0) \
- format(dString, sizeof(dString), "Welcome "HEX_LIGHTGREEN"%s"HEX_WHITE", Your account was not found. Type the password you want to register.", PlayerName(%0)); \
- ShowPlayerDialog(%0, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", dString, "Register", "Cancel")
- #define ShowLoginDialog(%0) \
- format(dString, sizeof(dString), "Welcome "HEX_LIGHTGREEN"%s"HEX_WHITE", Your account was found. Type the password you've registered.", PlayerName(%0)); \
- ShowPlayerDialog(%0, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", dString, "Login", "Cancel")
- #endif
- // Max Login Attempts (Use 0 or 1 to kick him if he failed 1x).
- #define MAX_LOGIN_ATTEMPTS 3
- //////////////////
- // /* Veriables */
- //////////////////
- new FirstTimeSpawned[MAX_PLAYERS];
- new AccountFile[100];
- new LoginAttempts[MAX_PLAYERS];
- new Deaths[MAX_PLAYERS];
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" S_RegLogin (Register and login system) by Steve successfully loaded! ");
- print(" Successfully Loaded!");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- public OnGameModeInit()
- {
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- stock PlayerName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- 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)
- {
- #if defined SAVEPLAYERDEATHS
- format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
- if(dini_Exists(AccountFile))
- {
- if(!dini_Isset(AccountFile, "Deaths")) dini_IntSet(AccountFile, "Deaths", 0);
- Deaths[playerid] = dini_Int(AccountFile, "Deaths");
- }
- else if(!dini_Exists(AccountFile))
- {
- Deaths[playerid] = 0;
- }
- #endif
- LoginAttempts[playerid] = 0;
- FirstTimeSpawned[playerid] = 0;
- return 1;
- }
- stock SavePlayer(playerid)
- {
- format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
- #if defined SAVEPLAYERMONEY
- if(!dini_Isset(AccountFile, "Money")) dini_IntSet(AccountFile, "Money", 0);
- dini_IntSet(AccountFile, "Money", GetPlayerMoney(playerid));
- #endif
- #if defined SAVEPLAYERSCORE
- if(!dini_Isset(AccountFile, "Score")) dini_IntSet(AccountFile, "Score", 0);
- dini_IntSet(AccountFile, "Score", GetPlayerScore(playerid));
- #endif
- #if defined SAVEPLAYERDEATHS
- if(!dini_Isset(AccountFile, "Deaths")) dini_IntSet(AccountFile, "Deaths", 0);
- dini_IntSet(AccountFile, "Deaths", Deaths[playerid]);
- #endif
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- LoginAttempts[playerid] = 0;
- FirstTimeSpawned[playerid] = 0;
- SavePlayer(playerid);
- return 1;
- }
- stock CheckRegLogin(playerid)
- {
- if(FirstTimeSpawned[playerid] == 0)
- {
- format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
- if(dini_Exists(AccountFile)) { ShowLoginDialog(playerid); }
- else if(!dini_Exists(AccountFile)) { ShowRegisterDialog(playerid); }
- FirstTimeSpawned[playerid] = 1;
- }
- else if(FirstTimeSpawned[playerid] != 0) { }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- CheckRegLogin(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- Deaths[playerid]++;
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- return 1;
- }
- return 0;
- }
- 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;
- }
- stock KickX(playerid, reason[])
- {
- new string[200]; format(string, sizeof(string), ""HEX_ADMINRED"%s"HEX_WHITE" has been kicked by the system (reason: %s)", PlayerName(playerid), reason);
- SendClientMessage(playerid, WHITE, string);
- Kick(playerid);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_REGISTER)
- {
- if(!strlen(inputtext)) { SendClientMessage(playerid, WHITE, ""HEX_ADMINRED"ERROR:"HEX_WHITE" You must type a password!"); ShowRegisterDialog(playerid); return 1; }
- if(response)
- {
- format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
- dini_Create(AccountFile);
- #if defined SAVEPLAYERSCORE
- dini_IntSet(AccountFile, "Score", 0);
- #endif
- #if defined SAVEPLAYERDEATHS
- dini_IntSet(AccountFile, "Deaths", 0);
- #endif
- #if defined SAVEPLAYERMONEY
- dini_IntSet(AccountFile, "Money", 0);
- #endif
- dini_Set(AccountFile, "Password", inputtext);
- SendClientMessage(playerid, WHITE, "You have "HEX_LIGHTGREEN"successfully"HEX_WHITE" Registered and Logged in!");
- #if defined SHOWINFORMATIONS
- SendClientMessage (playerid, ORANGE, " Information:");
- #if defined SAVEPLAYERSCORE
- SendClientMessagef(playerid, WHITE, "- Score: "HEX_LIGHTBLUE"%d"HEX_WHITE".", GetPlayerScore(playerid));
- #endif
- #if defined SAVEPLAYERMONEY
- SendClientMessagef(playerid, WHITE, "- Money: "HEX_LIGHTBLUE"%d"HEX_WHITE".", GetPlayerMoney(playerid));
- #endif
- #if defined SAVEPLAYERDEATHS
- SendClientMessagef(playerid, WHITE, "- Deaths: "HEX_LIGHTBLUE"%d"HEX_WHITE".", Deaths[playerid]);
- #endif
- #endif
- }
- else if(!response)
- {
- KickX(playerid, "You Must Register!");
- }
- }
- if(dialogid == DIALOG_LOGIN)
- {
- if(!strlen(inputtext)) { SendClientMessage(playerid, WHITE, ""HEX_ADMINRED"ERROR:"HEX_WHITE" You must type a password!"); ShowLoginDialog(playerid); return 1; }
- if(response)
- {
- format(AccountFile, sizeof(AccountFile), "/Accounts/%s.acc", PlayerName(playerid));
- if(strcmp(inputtext, dini_Get(AccountFile, "Password"), true) == 0)
- {
- #if defined SAVEPLAYERMONEY
- if(!dini_Isset(AccountFile, "Money")) dini_IntSet(AccountFile, "Money", 0);
- GivePlayerMoney(playerid, dini_Int(AccountFile, "Money"));
- #endif
- #if defined SAVEPLAYERSCORE
- if(!dini_Isset(AccountFile, "Score")) dini_IntSet(AccountFile, "Score", 0);
- SetPlayerScore(playerid, dini_Int(AccountFile, "Score"));
- #endif
- SendClientMessage(playerid, WHITE, "You have "HEX_LIGHTGREEN"successfully"HEX_WHITE" Logged in!");
- #if defined SHOWINFORMATIONS
- SendClientMessage (playerid, ORANGE, " Information:");
- #if defined SAVEPLAYERSCORE
- SendClientMessagef(playerid, WHITE, "- Score: "HEX_LIGHTBLUE"%d"HEX_WHITE".", GetPlayerScore(playerid));
- #endif
- #if defined SAVEPLAYERMONEY
- SendClientMessagef(playerid, WHITE, "- Money: "HEX_LIGHTBLUE"%d"HEX_WHITE".", GetPlayerMoney(playerid));
- #endif
- #if defined SAVEPLAYERDEATHS
- SendClientMessagef(playerid, WHITE, "- Deaths: "HEX_LIGHTBLUE"%d"HEX_WHITE".", Deaths[playerid]);
- #endif
- #endif
- LoginAttempts[playerid] = 0;
- }
- else
- {
- LoginAttempts[playerid]++;
- if(LoginAttempts[playerid] == MAX_LOGIN_ATTEMPTS)
- {
- KickX(playerid, "Failed Login");
- return 1;
- }
- SendClientMessagef(playerid, WHITE, ""HEX_ADMINRED"ERROR:"HEX_WHITE" Invalid password [Failed Logins: %d/Max Allowed: %d]!", LoginAttempts[playerid], MAX_LOGIN_ATTEMPTS);
- ShowLoginDialog(playerid);
- }
- }
- else if(!response)
- {
- KickX(playerid, "You Must Login!");
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement