Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // [FS] torran's Registration System v2
- // Made by Joe Torran C
- // DO NOT REMOVE THESE CREDITS
- #include <a_samp>
- #include <dini>
- #include <dudb>
- #include <zcmd>
- #define SCRIPT_VERSION "v2"
- #define colorRed 0xFF0000FF
- #define colorGreen 0x008000FF
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- #define DIALOG_ACCOUNT 3
- #define DIALOG_CHANGEPASS 4
- #pragma unused ret_memcpy
- forward UpdateTime(playerid);
- new str[128];
- new file[128];
- new Update;
- public OnPlayerConnect(playerid)
- {
- format(file, 128, "/tReg/%s.ini", GetName(playerid));
- if(!dini_Exists(file))
- {
- format(str, 128, "Welcome %s \n\nPlease register your account", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account Management", str, "Register", "Quit");
- }
- if(dini_Exists(file))
- {
- format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- format(file, 128, "/tReg/%s.ini", GetName(playerid));
- if(GetPVarInt(playerid, "Logged") == 1)
- {
- dini_IntSet(file, "Money", GetPlayerMoney(playerid));
- dini_IntSet(file, "Score", GetPlayerScore(playerid));
- dini_IntSet(file, "Kills", GetPVarInt(playerid, "Kills"));
- dini_IntSet(file, "Deaths", GetPVarInt(playerid, "Deaths"));
- dini_IntSet(file, "Minutes Ingame", GetPVarInt(playerid, "Time"));
- KillTimer(Update);
- }
- return 1;
- }
- public OnFilterScriptInit()
- {
- printf("\n [FS] torran's Registration System %s \n", SCRIPT_VERSION);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- format(file, 128, "/tReg/%s.ini", GetName(playerid));
- if(dialogid == DIALOG_REGISTER)
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- if(strlen(inputtext) == 0)
- {
- format(str, 128, "Welcome %s \n\nPlease register your account", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account Management", str, "Register", "Quit");
- return 0;
- }
- if(!dini_Exists(file))
- {
- dini_Create(file);
- dini_IntSet(file, "Password", udb_hash(inputtext));
- dini_IntSet(file, "Money", GetPlayerMoney(playerid));
- dini_IntSet(file, "Score", GetPlayerScore(playerid));
- dini_IntSet(file, "Kills", GetPVarInt(playerid, "Kills"));
- dini_IntSet(file, "Deaths", GetPVarInt(playerid, "Deaths"));
- dini_IntSet(file, "Minutes Ingame", GetPVarInt(playerid, "Time"));
- format(str, 128, "Account successfully Registered \n\n\nWelcome %s \n\nPlease login to your account", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
- }
- }
- }
- if(dialogid == DIALOG_LOGIN)
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- if(strlen(inputtext) == 0)
- {
- format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
- return 0;
- }
- if(fexist(file))
- {
- new password = dini_Int(file, "Password");
- if(udb_hash(inputtext) != password)
- {
- if(GetPVarInt(playerid, "Attempts") == 0)
- {
- SetPVarInt(playerid, "Attempts", 1);
- SendClientMessage(playerid, colorRed, "Incorrect password, You have 1 more attempt");
- format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
- }
- else if(GetPVarInt(playerid, "Attempts") == 1)
- {
- SendClientMessage(playerid, colorRed, "Incorrect password, You do not have any attempts left");
- Kick(playerid);
- }
- }
- else
- {
- SetPVarInt(playerid, "Logged", 1);
- SetPlayerMoney(playerid, dini_Int(file, "Money"));
- SetPlayerScore(playerid, dini_Int(file, "Score"));
- SetPVarInt(playerid, "Kills", dini_Int(file, "Kills"));
- SetPVarInt(playerid, "Deaths", dini_Int(file, "Deaths"));
- SetPVarInt(playerid, "Time", dini_Int(file, "Minutes Ingame"));
- Update = SetTimerEx("UpdateTime", 60*1000, 1, "i", playerid);
- SendClientMessage(playerid, colorGreen, "You have successfully logged in.");
- }
- }
- }
- }
- if(dialogid == DIALOG_CHANGEPASS)
- {
- if(response)
- {
- if(GetPVarInt(playerid, "PassStage") == 1)
- {
- new password = dini_Int(file, "Password");
- if(udb_hash(inputtext) == password)
- {
- SetPVarInt(playerid, "PassStage", 2);
- ShowPlayerDialog(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, "Account Management", "Please input your new password", "Change Pass", "Cancel");
- }
- else
- {
- SendClientMessage(playerid, colorRed, "Incorrect password.");
- }
- }
- if(GetPVarInt(playerid, "PassStage") == 2)
- {
- if(GetPVarInt(playerid, "Logged") == 1)
- {
- dini_IntSet(file, "Password", udb_hash(inputtext));
- SendClientMessage(playerid, colorGreen, "Password successfully changed.");
- }
- }
- }
- }
- return 0;
- }
- public UpdateTime(playerid)
- {
- format(file, 128, "/tReg/%s.ini", GetName(playerid));
- SetPVarInt(playerid, "Time", GetPVarInt(playerid, "Time")+1);
- return 1;
- }
- CMD:changepass(playerid, params[])
- {
- if(GetPVarInt(playerid, "Logged") == 1)
- {
- SetPVarInt(playerid, "PassStage", 1);
- ShowPlayerDialog(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, "Account Management", "Please input your current password for verification", "Continue", "Cancel");
- }
- return 1;
- }
- stock GetName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof name);
- return name;
- }
- stock SetPlayerMoney(playerid, amount)
- {
- ResetPlayerMoney(playerid);
- return GivePlayerMoney(playerid, amount);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement