Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp> //Thanks to SA-MP Team
- #include <bud> //Thanks to Slice for his awesome Blazing User Database System.
- enum dData
- {
- Score,
- Money
- }
- #define DATABASE_NAME "Register.db" //the name of the database , can be edit. [WARNING]Syntax .db must be there!!!! ex: Mytabe.db, SS.db
- //if youd isable these 2 : you'll get an warning but don't worry cause is just an warning ;)
- #define SAVE_SCORE true //if save_score is true , score column will be created in the database also, will be save and loat from the database , else the oposite will happen
- #define SAVE_MONEY true //if save_money is true , money column will be created in the database also, will be save and loat from the database , else the oposite will happen
- #define REGISTER_DIALOG 15 // ID OF THE REGISTER DIALOG
- #define LOGIN_DIALOG 18 // ID OF THE LOGIN DIALOG
- #define MAX_CHARACTERS 10 //max of characters for the password
- #define MIN_CHARACTERS 5 //min of characters for the password
- #define SERVER_NAME "[Name of the server]" //the name of the server wich will appear in your dialog
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Register system by XStormiest. loaded!");
- print("--------------------------------------\n");
- //Save in to the Database
- BUD::Setting( opt.Database, DATABASE_NAME);
- BUD::Setting( opt.Asynchronous, true );
- BUD::Setting( opt.KeepAliveTime, 3000);
- BUD::Setting( opt.CheckForUpdates, true);
- BUD::Initialize();
- #if SAVE_SCORE == true
- BUD::VerifyColumn("Score",BUD::TYPE_NUMBER);
- #endif
- #if SAVE_MONEY == true
- BUD::VerifyColumn("Money",BUD::TYPE_NUMBER);
- #endif
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by XStormiest. unloaded!");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- if(BUD::IsNameRegistered(name) == false)
- {
- new register[256];
- format(register,sizeof(register), "Welcome to %s,%s\nPlease enjoy the server by making your account.\nYou'll have benefits like saving your stats.\nWrite under your desired password",SERVER_NAME,name);
- ShowPlayerDialog(playerid,REGISTER_DIALOG,DIALOG_STYLE_PASSWORD,"Register...",register,"Register","Leave");
- }
- else
- {
- new login[256];
- format(login,sizeof(login),"Hey again %s, and welcome again to the %s\nIt look like you already register in our database\nSo please log in by using your password",name,SERVER_NAME);
- ShowPlayerDialog(playerid,LOGIN_DIALOG,DIALOG_STYLE_PASSWORD,"Login...",login,"Login","Leave");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid,reason)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- new userid = BUD::GetNameUID(name);
- if(BUD::IsNameRegistered(name) == true)
- {
- #if SAVE_SCORE == true
- BUD::MultiSet(userid,"i","Score",GetPlayerScore(playerid) );
- #endif
- #if SAVE_MONEY == true
- BUD::MultiSet(userid,"i","Money",GetPlayerMoney(playerid) );
- #endif
- }
- return 1;
- }
- public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- new userid = BUD::GetNameUID(name);
- if(dialogid == REGISTER_DIALOG)
- {
- if(!response) Kick(playerid);
- if(response)
- {
- if(strlen(inputtext) < MIN_CHARACTERS || strlen(inputtext) > MAX_CHARACTERS)
- {
- new register[256];
- format(register,sizeof(register), "Welcome to %s,%s\nPlease enjoy the server by making your account.\nYou'll have benefits like saving your stats.\nWrite under your desired password\nPassword must be min %d characters, and max %d characters",SERVER_NAME,name,MIN_CHARACTERS,MAX_CHARACTERS);
- ShowPlayerDialog(playerid,REGISTER_DIALOG,DIALOG_STYLE_PASSWORD,"Register...",register,"Register","Leave");
- }
- else
- {
- BUD::RegisterName(name,inputtext);
- #if SAVE_SCORE == true
- BUD::MultiSet(userid,"i","Score",0);
- #endif
- #if SAVE_MONEY == true
- BUD::MultiSet(userid,"i","Money",0);
- #endif
- SendClientMessage(playerid,-1,"[ACCOUNT]Your account was created and saved to the database.");
- }
- }
- }
- if(dialogid == LOGIN_DIALOG)
- {
- if(!response) Kick(playerid);
- if(response)
- {
- if(BUD::CheckAuth(name,inputtext) == false)
- {
- new login[256];
- format(login,sizeof(login),"Hey again %s, and welcome again to the %s\nIt look like you already register in our database\nSo please log in by using your password\nERROR: incorrect password",name,SERVER_NAME);
- ShowPlayerDialog(playerid,LOGIN_DIALOG,DIALOG_STYLE_PASSWORD,"Login...",login,"Login","Leave");
- }
- else
- {
- #if SAVE_SCORE == true
- SetPlayerScore(playerid,BUD::GetIntEntry(userid,"Score") );
- #endif
- #if SAVE_MONEY == true
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid,BUD::GetIntEntry(userid,"Money"));
- #endif
- SendClientMessage(playerid,-1,"[ACCOUNT]Your account was loaded from the database.");
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement