Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dudb>
- #include <dini>
- #define FILTERSCRIPT
- #if defined FILTERSCRIPT
- #define Register 1
- #define Login 2
- #define WELCOME3 3
- #define WELCOME2 4
- #define WELCOME1 5
- #define Register1 6
- #define Register2 7
- #define SkinSave 8
- #define AutoLog 9
- #define COLOR_GREEN 0x00FF00FF
- #define COLOR_RED 0xFF0000FF
- #define COLOR_RED2 0xA50047FF
- #define COLOR_GREEN2 0x18FF18FF
- #define COLOR_BLUE 0x0000FFFF
- enum pInfo
- {
- Deaths,
- Kills,
- ServerTime
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new IsLogged[MAX_PLAYERS];
- new TimeTimer;
- new rip[MAX_PLAYERS][16];
- new Avisos[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("------------------RankS-----------------");
- print("--------------------------------------\n");
- return 1;
- }
- #endif
- public OnPlayerConnect(playerid)
- {
- TogglePlayerSpectating(playerid, 1);
- IsLogged[playerid] = 0;
- new file[128], string[128];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(!fexist(file))
- {
- ShowPlayerDialog(playerid, WELCOME1, DIALOG_STYLE_MSGBOX, "Welcome", string, "Login", "Register");
- }
- if(fexist(file))
- {
- format(file,sizeof(file),"/RankS/%s IP.ini",name);
- GetPlayerIp(playerid,rip[playerid],16);
- if(!strcmp(rip[playerid], dini_Get(file,"IP")))
- {
- SpawnPlayer(playerid);
- IsLogged[playerid] = 1;
- TogglePlayerSpectating(playerid, 0);
- }else{
- format(string, sizeof string, "Your IP doesn match with Username: %s", name);
- ShowPlayerDialog(playerid, 14, DIALOG_STYLE_MSGBOX, "Login Failed", string, "OK", "Cancel");
- }
- if(!dini_Exists(file))
- {
- ShowPlayerDialog(playerid, WELCOME2, DIALOG_STYLE_MSGBOX, "Welcome", string, "Register", "Login");
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerSpawn(playerid)
- {
- new file[128], string[128];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s SKINS.ini",name);
- if(dini_Exists(file))
- {
- SetPlayerSkin(playerid, dini_Int(file,"Skins"));
- }
- format(file,sizeof(file),"/RankS/%s IP.ini",name);
- if(!strcmp(rip[playerid], dini_Get(file,"IP")))
- {
- SendClientMessage(playerid, COLOR_GREEN, "You have been automatically logged in");
- }else{
- IsLogged[playerid] = 0;
- TogglePlayerSpectating(playerid, 1);
- format(string, sizeof string, "Your IP doesn match with Username:%s", name);
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Login Failed", string, "OK", "Cancel");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new file[128];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(!dini_Exists(file))
- {
- dini_Create(file);
- dini_IntSet(file,"Score", GetPlayerScore(playerid));
- dini_IntSet(file,"Money", GetPlayerMoney(playerid));
- dini_IntSet(file,"Deaths", PlayerInfo[playerid][Deaths]);
- dini_IntSet(file,"Kills", PlayerInfo[playerid][Kills]);
- dini_IntSet(file,"ServerTime", PlayerInfo[playerid][ServerTime]);
- dini_IntSet(file, "WantedLevel", GetPlayerWantedLevel(playerid));
- dini_FloatSet(file, "FightStyle", GetPlayerFightingStyle(playerid));
- }
- IsLogged[playerid] = 0;
- KillTimer(TimeTimer);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid)
- {
- PlayerInfo[playerid][Deaths] ++;
- PlayerInfo[killerid][Kills] ++;
- return 1;
- }
- forward TimeOnServer(playerid);
- public TimeOnServer(playerid)
- {
- PlayerInfo[playerid][ServerTime] ++;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/changepass", true))
- {
- new string[128], name[MAX_PLAYER_NAME] ,PlayerName[24];
- {
- format(string, sizeof string, "Your About to change your password \n\nA password authorization will be needed to continue!!!", name);
- ShowPlayerDialog(playerid, Register1, DIALOG_STYLE_MSGBOX, "change password ", string, "OK", "Cancel");
- }
- if(IsLogged[playerid] == 0)
- {
- format(string, sizeof string, "You Need To login First", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "WARRNING", string, "login", "Cancel");
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/logout", true))
- {
- new string[128], name[MAX_PLAYER_NAME] ,PlayerName[24];
- if(IsLogged[playerid] == 0)
- {
- format(string, sizeof string, "You are already logged out", PlayerName);
- ShowPlayerDialog(playerid, 12, DIALOG_STYLE_MSGBOX, "ERROR", string, "OK", "Cancel");
- }
- IsLogged[playerid] = 0;
- TogglePlayerSpectating(playerid, 7);
- printf("%s has Logged Out", name);
- format(string, sizeof string, "Enter a password to log back in", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- return 1;
- }
- if(!strcmp(cmdtext, "/register", true))
- {
- new file[128], string[128] ,PlayerName[24] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(IsLogged[playerid] == 0)
- {
- if(fexist(file))
- GetPlayerName(playerid, PlayerName, sizeof PlayerName);
- format(string, sizeof string, "You need to login first", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- }
- if(!fexist(file))
- {
- GetPlayerName(playerid, PlayerName, sizeof PlayerName);
- format(string, sizeof string, "Enter Your Password for your account", PlayerName);
- ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Account", string, "Register", "Cancel");
- }
- if(IsLogged[playerid] == 1)
- {
- format(string, sizeof string, "You are already Registered", PlayerName);
- ShowPlayerDialog(playerid, 11, DIALOG_STYLE_MSGBOX, "ERROR", string, "OK", "Cancel");
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/login", true))
- {
- new file[128], string[128] ,PlayerName[24] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(IsLogged[playerid] == 0)
- {
- if(fexist(file))
- GetPlayerName(playerid, PlayerName, sizeof PlayerName);
- format(string, sizeof string, "Enter a password to log back in", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- }
- if(!fexist(file))
- {
- GetPlayerName(playerid, PlayerName, sizeof PlayerName);
- format(string, sizeof string, "You need to Register First", PlayerName);
- ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Account", string, "Register", "Cancel");
- }
- if(IsLogged[playerid] == 1)
- {
- format(string, sizeof string, "You are already logged in", PlayerName);
- ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "ERROR", string, "OK", "Cancel");
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/AutoLog", true))
- {
- new string[128] ,PlayerName[24];
- ShowPlayerDialog(playerid, AutoLog, DIALOG_STYLE_LIST, "Auto Login", "On \nOff", "Select", "Cancel");
- if(IsLogged[playerid] == 0)
- {
- format(string, sizeof string, "You Need To login First", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "login", "Cancel");
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/Saveskin", true))
- {
- new string[128] ,PlayerName[24];
- ShowPlayerDialog(playerid, SkinSave, DIALOG_STYLE_LIST, "Skin Saving", "On \nOff", "Select", "Cancel");
- if(IsLogged[playerid] == 0)
- {
- format(string, sizeof string, "You Need To login First", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "login", "Cancel");
- }
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == AutoLog && response)
- {
- switch(listitem)
- {
- case 0:
- {
- new file[128] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s IP.ini",name);
- {
- dini_Create(file);
- GetPlayerIp(playerid,rip[playerid],16);
- dini_Set(file,"IP",rip[playerid]);
- SendClientMessage(playerid, COLOR_GREEN, "Auto Login Enabled");
- }
- return 1;
- }
- case 1:
- {
- new file[128] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s IP.ini",name);
- {
- dini_Remove(file);
- GetPlayerIp(playerid,rip[playerid],16);
- dini_Set(file,"IP",rip[playerid]);
- SendClientMessage(playerid, COLOR_RED, "Auto Login Disable");
- }
- return 1;
- }
- }
- }
- if(dialogid == SkinSave && response)
- {
- switch(listitem)
- {
- case 0:
- {
- new file[128] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s SKINS.ini",name);
- {
- dini_Create(file);
- dini_IntSet(file,"Skins",GetPlayerSkin(playerid));
- SendClientMessage(playerid, COLOR_GREEN, "Skin Saved");
- }
- return 1;
- }
- case 1:
- {
- new file[128] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s SKINS.ini",name);
- {
- dini_Remove(file);
- dini_IntSet(file,"Skins",GetPlayerSkin(playerid));
- SendClientMessage(playerid, COLOR_RED, "Skin UnSaved");
- }
- return 1;
- }
- }
- }
- if(dialogid == WELCOME2)
- {
- if(response)
- {
- ShowPlayerDialog(playerid,WELCOME2,DIALOG_STYLE_MSGBOX,"ERROR","You are already Registered \n \n If you dont know your password use another USERNAME","Cancel","Login");
- }
- else
- {
- TogglePlayerSpectating(playerid, 1);
- IsLogged[playerid] = 0;
- new file[128], string[128] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(fexist(file))
- {
- format(string, sizeof string, "Welcome %s! \nYour account is Registered \n\nPlease Login to your account!", name);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- }
- }
- }
- if(dialogid == WELCOME1)
- {
- if(response)
- {
- ShowPlayerDialog(playerid,WELCOME1,DIALOG_STYLE_MSGBOX,"ERROR","Your account is not Registered","Cancel","Register");
- }
- else
- {
- TogglePlayerSpectating(playerid, 1);
- IsLogged[playerid] = 0;
- new file[128], string[128] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(!fexist(file))
- {
- format(string, sizeof string, "Welcome %s! \nPlease Register you account!", name);
- ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Account", string, "Register", "Cancel");
- }
- }
- }
- if(dialogid == Register1)
- {
- if(response)
- {
- new file[128] ,string[128] ,PlayerName[24];
- if(strlen(inputtext) == 0)
- {
- GetPlayerName(playerid, PlayerName, sizeof PlayerName);
- format(string, sizeof string, "Enter your old password to proceed", PlayerName);
- ShowPlayerDialog(playerid, Register1, DIALOG_STYLE_INPUT, "Account", string, "Confirm", "Cancel");
- return 0;
- }
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(fexist(file))
- {
- new password = dini_Int(file, "Password");
- if(udb_hash(inputtext) != password)
- {
- SendClientMessage(playerid, COLOR_RED, "Error ~ Incorrect password");
- }
- else
- {
- format(string, sizeof string, "Password confirmed", name);
- ShowPlayerDialog(playerid, Register2, DIALOG_STYLE_MSGBOX, "change password", string, "NEXT", "Cancel");
- }
- }
- }
- }
- if(dialogid == Register2)
- {
- if(response)
- {
- new file[128] ,string[128] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(strlen(inputtext) == 0)
- {
- format(string, sizeof string, "Please enter a new password!", name);
- ShowPlayerDialog(playerid, Register2, DIALOG_STYLE_INPUT, "Account", string, "Change", "Cancel");
- return 1;
- }
- format(file,sizeof(file),"/RankS/%s.ini",name);
- {
- dini_Create(file);
- dini_IntSet(file,"Password", udb_hash(inputtext));
- TogglePlayerSpectating(playerid, 0);
- SendClientMessage(playerid, COLOR_BLUE, "You have successfully changed your password");
- }
- }
- }
- if(dialogid == Register)
- {
- if(response)
- {
- new file[128] ,string[128] ,name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(string,128,"%s.ini",inputtext);
- if(dini_Exists(string))
- {
- ShowPlayerDialog(playerid,WELCOME1 ,DIALOG_STYLE_MSGBOX,"Register [ERROR]","THIS USERNAME IS IN USE!\n\nPlease enter another username:","Cancel","Go back");
- }
- if(strlen(inputtext) == 0)
- {
- format(string, sizeof string, "Please enter a password \n\nWelcome %s! \nYour account is NOT Registered \n\nPlease Register you account!", name);
- ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Account", string, "Register", "Cancel");
- return 0;
- }
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(!fexist(file))
- {
- dini_Create(file);
- dini_IntSet(file,"Password", udb_hash(inputtext));
- dini_IntSet(file,"Score", GetPlayerScore(playerid));
- dini_IntSet(file,"Money", GetPlayerMoney(playerid));
- dini_IntSet(file,"Deaths", PlayerInfo[playerid][Deaths]);
- dini_IntSet(file,"Kills", PlayerInfo[playerid][Kills]);
- dini_IntSet(file,"ServerTime", PlayerInfo[playerid][ServerTime]);
- dini_FloatSet(file, "FightStyle", GetPlayerFightingStyle(playerid));
- format(string, sizeof string, "Account Registered \n\nWelcome %s! \nWe have detected that your account is Registered \n\nPlease Login to your account!", name);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
- GetPlayerName(playerid, name, sizeof(name));
- printf("%s has Registered a account", name);
- }
- }
- }
- if(dialogid == Login)
- {
- if(response)
- {
- new file[128] ,string[128] ,PlayerName[24];
- if(strlen(inputtext) == 0)
- {
- GetPlayerName(playerid, PlayerName, sizeof PlayerName);
- format(string, sizeof string, "Please enter a password \n\nWelcome %s! \nYour account is Registered \n\nPlease Login to your account!", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- return 0;
- }
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/RankS/%s.ini",name);
- if(fexist(file))
- {
- new password = dini_Int(file, "Password");
- new player[25];
- if(udb_hash(inputtext) != password)
- {
- if(Avisos[playerid]==2)
- {
- new str[128];
- Avisos[playerid]=0;
- format(str, sizeof (str), "%s kicked || Reason: incorrect password [3/3 Tries]",player);
- format(string, sizeof string, "incorrect password \n\n[3/3 Tries]", PlayerName);
- ShowPlayerDialog(playerid, -1, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- Kick(playerid);
- }
- if(Avisos[playerid]==1)
- {
- new str[128];
- Avisos[playerid]++;
- format(str, sizeof (str), "%s kicked || Reason: incorrect password [2/3 Tries]",player);
- format(string, sizeof string, "incorrect password \n\n[2/3 Tries]", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- }
- if(Avisos[playerid]==0)
- {
- new str[128];
- Avisos[playerid]++;
- format(str, sizeof (str), "%s kicked || Reason: incorrect password [1/3 Tries]",player);
- format(string, sizeof string, "incorrect password \n\n[1/3 Tries]", PlayerName);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Account", string, "Login", "Cancel");
- }
- }
- else
- {
- IsLogged[playerid] = 1;
- ResetPlayerMoney(playerid);
- SetPlayerScore(playerid, dini_Int(file,"Score"));
- GivePlayerMoney(playerid, dini_Int(file,"Money"));
- PlayerInfo[playerid][Deaths] = dini_Int(file,"Deaths");
- PlayerInfo[playerid][Kills] = dini_Int(file,"Kills");
- PlayerInfo[playerid][ServerTime] = dini_Int(file,"ServerTime");
- TimeTimer = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
- SendClientMessage(playerid, COLOR_GREEN, "Success ~ You have successfully logged into your account");
- TogglePlayerSpectating(playerid, 0);
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "[SERVER] %s has successfully loged In", name );
- SendClientMessageToAll(COLOR_GREEN2, string);
- printf("%s has logged into his account", name);
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement