Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <DOF2>
- #define DIALOG_LOGIN 0
- #define DIALOG_REGISTRO 1
- #define DINHEIRO_INICIAL 5000
- #define SCORE_INICIAL 1
- new errouSenha[MAX_PLAYERS],
- Dinheiro[MAX_PLAYERS],
- Score[MAX_PLAYERS],
- bool:Logado[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- if(IsPlayerNPC(playerid)) return true;
- if(Logado[playerid] == false)
- {
- SendClientMessage(playerid, -1, "Logue-se!.");
- return false;
- }
- 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)
- {
- Conectado(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- DOF2_SetInt(Conta(playerid),"Dinheiro",Dinheiro[playerid]);
- DOF2_SetInt(Conta(playerid),"Score",Score[playerid]);
- DOF2_SaveFile();
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_LOGIN)
- {
- if(response)
- {
- if(!strval(inputtext)) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Caracteres inválidos","Digite apenas números e letras!","Logar","");
- else if(!strcmp(inputtext,DOF2_GetString(Conta(playerid),"Senha"),false))
- {
- SendClientMessage(playerid,-1,"Logado com sucesso!");
- CarregarPlayer(playerid);
- }
- else
- {
- if(errouSenha[playerid] == 3) return SendClientMessage(playerid,-1,"Você errou a senha três vezes e foi kickado."),Kick(playerid);
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Senha Incorreta!","Senha Incorreta.\nErrando-a três vezes você será kickado automaticamente.","Logar","Sair");
- errouSenha[playerid] ++;
- }
- }
- else SendClientMessage(playerid,-1,"Você usou a opção 'Sair' e foi kickado do servidor!"),Kick(playerid);
- }
- else if(dialogid == DIALOG_REGISTRO)
- {
- if(response)
- {
- if(strlen(inputtext) < 3 || strlen(inputtext) > 24) return ShowPlayerDialog(playerid,DIALOG_REGISTRO,DIALOG_STYLE_PASSWORD,"Erro","Digite uma senha de 3 à 24 caracteres!","Registrar","Sair");
- DOF2_CreateFile(Conta(playerid));
- DOF2_SetString(Conta(playerid),"Senha",inputtext);
- Dinheiro[playerid] = DINHEIRO_INICIAL,Score[playerid] = SCORE_INICIAL;
- DOF2_SetInt(Conta(playerid),"Dinheiro",Dinheiro[playerid]);
- DOF2_SetInt(Conta(playerid),"Score",Score[playerid]);
- DOF2_SaveFile();
- Logado[playerid] = true;
- GivePlayerMoney(playerid,Dinheiro[playerid]);
- SetPlayerScore(playerid,Score[playerid]);
- SendClientMessage(playerid,-1,"Registrado e Logado com sucesso!");
- }
- else SendClientMessage(playerid,-1,"Você usou a opção 'Sair' e foi kickado do servidor!"),Kick(playerid);
- }
- return 1;
- }
- stock Nick(playerid)
- {
- new nome[24];
- GetPlayerName(playerid,nome,sizeof(nome));
- return nome;
- }
- stock Conta(playerid)
- {
- new arq[64];
- format(arq,sizeof(arq),"%s.ini",Nick(playerid));
- return arq;
- }
- stock Conectado(playerid)
- {
- if(DOF2_FileExists(Conta(playerid)))
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Logue-se","Bem vindo novamente ao servidor.\nPara logar-se digite sua senha no diálogo abaixo:","Logar","Sair");
- else
- ShowPlayerDialog(playerid,DIALOG_REGISTRO,DIALOG_STYLE_PASSWORD,"Registre-se","Bem vindo à sua primeira vez no servidor.\nPara Registrar-se digite sua senha no diálogo abaixo:","Registrar","Sair");
- }
- stock CarregarPlayer(playerid)
- {
- Logado[playerid] = true;
- errouSenha[playerid] = 0;
- Dinheiro[playerid] = DOF2_GetInt(Conta(playerid),"Dinheiro");
- Score[playerid] = DOF2_GetInt(Conta(playerid),"Score");
- GivePlayerMoney(playerid,Dinheiro[playerid]);
- SetPlayerScore(playerid,Score[playerid]);
- }
Advertisement
Add Comment
Please, Sign In to add comment