Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Nome: VBMail
- Descrição: Sistema de email
- Autor: ViniBorn
- Contato : vini-elite@hotmail.com
- *** *** *** ***** *** *** *** *** ***** ******** ****** ***
- *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** ***
- *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** ***
- *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** ***
- ****** *** *** ****** *** *** **** ***** *** *** *** ******
- Não retire os créditos.
- Seu nome é valioso, não suje-o.
- Observações :
- - O diretório padrão para salvar os emails é : scriptfiles/emails. Crie a pasta emails.
- - O diretório padrão para contas de usuários é : scriptfiles/users. Modifique a define Players, de acordo com
- o local onde são salvas as contas do seu servidor.
- - A caixa de entrada de cada jogador tem capacidade de 10 emails.
- Atualizações :
- * 20/08/11
- - Novo método para leitura de emails utilizando DIALOG_STYLE_LIST
- - Indicação de e-mails (Lido) ou (Não lido)
- */
- #include <a_samp>
- #include <Dini>
- #define Local "/emails/%s.ini" // Diretório dos emails
- #define Players "/users/%s.ini" // Diretório das contas
- new Destinatario[MAX_PLAYERS][32];
- static const Status[2][14] = {
- {"(Lido) - "},
- {"(Não lido) - "}
- };
- new Emails[][10] = {
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- "10"
- };
- public OnFilterScriptInit()
- {
- print("\n\n--------------------------------------");
- print(" Sistema de e-mail By: ViniBorn");
- print(" - Não retire os créditos -");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n\tSistema de e-mail descarregado.");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/comprarpc", cmdtext, true, 10) == 0)
- {
- if(GetPlayerMoney(playerid) < 2000)
- return SendClientMessage(playerid, 0xAFAFAFAA,"Você não possui esta quantia.");
- new email[32];
- format(email,32,Local,Player(playerid));
- if(dini_Exists(email))
- return SendClientMessage(playerid, 0xAFAFAFAA,"Você já possui um computador.");
- dini_Create(email);
- for(new i=0;i<sizeof(Emails);i++)
- dini_Set(email,Emails[i],"Vazio");
- GameTextForPlayer(playerid, "Custo : R$ 2.000", 5000, 1);
- GivePlayerMoney(playerid, -2000);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- SendClientMessage(playerid, 0xAFAFAFAA, "Agora você pode usar /email.");
- return 1;
- }
- if(strcmp("/email", cmdtext, true, 10) == 0)
- {
- new email[32];
- format(email,32,Local,Player(playerid));
- if(!dini_Exists(email))
- return SendClientMessage(playerid, 0xAFAFAFAA,"Você não possui um computador.");
- new listitems[] = "Caixa de entrada\nEnviar\nApagar";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Meu email : ", listitems,"Selecionar","Sair");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 225)
- {
- if(!response)
- return 0;
- else
- {
- new str[128], email[32], string[1024];
- format(email,32,Local,Player(playerid));
- switch (listitem)
- {
- case 0:
- {
- for(new i=0;i<sizeof(Emails);i++)
- {
- format(str,128,"{C2A2DA}%d - %s\n",strval(Emails[i]),dini_Get(email,Emails[i]));
- strcat(string, str);
- }
- ShowPlayerDialog(playerid, 226, DIALOG_STYLE_LIST, "Caixa de entrada : ", string,"Selecionar","Voltar");
- }
- case 1: ShowPlayerDialog(playerid, 227,DIALOG_STYLE_INPUT,"E-mail","Digite o nome do destinatário:","Enviar","Voltar");
- case 2: ShowPlayerDialog(playerid, 228,DIALOG_STYLE_INPUT,"E-mail","Digite número do e-mail:","Apagar","Voltar");
- }
- }
- }
- else if(dialogid == 226)//Ler
- {
- if(!response)
- {
- new listitems[] = "Caixa de entrada\nEnviar\nApagar";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Meu email : ", listitems,"Selecionar","Sair");
- }
- else
- MeuEmail(playerid,listitem);
- }
- else if(dialogid == 227)//Enviar (destinatário)
- {
- if(!response)
- {
- new listitems[] = "Caixa de entrada\nEnviar\nApagar";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Meu email : ", listitems,"Selecionar","Sair");
- }
- else
- {
- new file[64];
- format(file, sizeof(file), Players,inputtext);
- if(dini_Exists(file))
- {
- new giveid = ReturnUser(inputtext);
- format(file,32,Local,Player(giveid));
- if(!dini_Exists(file))
- return SendClientMessage(playerid, 0xAA3333AA,"[ERRO] O jogador não possui um computador.");
- new str[128];
- format(str,128,"Você está prestes a enviar um e-mail para %s. Digite a mensagem.", inputtext);
- SendClientMessage(playerid, 0xFFD700AA,str);
- format(Destinatario[playerid],32,inputtext);
- return ShowPlayerDialog(playerid,229,DIALOG_STYLE_INPUT,"E-mail","Digite a mensagem:","Enviar","Voltar");
- }
- else
- SendClientMessage(playerid,0xAA3333AA,"[ERRO] A conta não existe.");
- }
- }
- else if(dialogid == 228)//Apagar
- {
- if(!response)
- {
- new listitems[] = "Caixa de entrada\nEnviar\nApagar";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Meu email : ", listitems,"Selecionar","Sair");
- }
- else
- {
- new n;
- n = strval(inputtext);
- new email[32];
- format(email,32,Local,Player(playerid));
- dini_Set(email,Emails[n-1],"Vazio");
- }
- }
- else if(dialogid == 229)//Enviar (mensagem)
- {
- if(response)
- {
- SendClientMessage(playerid,0xFFD700AA,"E-mail enviado com sucesso ");
- EnviarEmail(playerid,inputtext);
- }
- }
- else if(dialogid == 230)//Exibir e-mail
- {
- if(response)
- {
- new listitems[] = "Caixa de entrada\nEnviar\nApagar";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Meu email : ", listitems,"Selecionar","Sair");
- }
- }
- return 1;
- }
- stock MeuEmail(playerid,numero)
- {
- new email[32],email2[128];
- format(email,32,Local,Player(playerid));
- if(strcmp(dini_Get(email,Emails[numero]),"Vazio",true)==0)
- return ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Meu email : ", "Caixa de entrada\nEnviar\nApagar","Selecionar","Sair");
- format(email2,128,"%s",dini_Get(email,Emails[numero]));
- if(email2[1] == 'N')
- {
- strdel(email2,0,14);
- dini_Set(email,Emails[numero],email2);
- format(email2,128,"%s%s",Status[0],dini_Get(email,Emails[numero]));
- dini_Set(email,Emails[numero],email2);
- }
- ShowPlayerDialog(playerid, 230, DIALOG_STYLE_MSGBOX, "VBMail", email2, "Voltar", "Sair");
- return 1;
- }
- stock EnviarEmail(playerid,const string[])
- {
- new email[32],str[128];
- format(email,32,Local,Destinatario[playerid]);
- if(!dini_Exists(email))
- {
- for(new i=0;i<sizeof(Emails);i++)
- dini_Set(email,Emails[i],"Vazio");
- }
- else
- {
- format(str,128,"%s %s - Remetente : %s",Status[1],string,Player(playerid));
- for(new i=0;i<sizeof(Emails);i++)
- if(strcmp(dini_Get(email,Emails[i]),"Vazio",true)==0)
- {
- new giveid = ReturnUser(Destinatario[playerid]);
- if(IsPlayerConnected(giveid))
- GameTextForPlayer(giveid, "Voce recebeu um novo e-mail.", 5000, 5);
- dini_Set(email,Emails[i],str);
- return 1;
- }
- return SendClientMessage(playerid,0xAA3333AA,"[ERRO] A caixa de entrada está lotada.");
- }
- return 1;
- }
- stock Player(playerid)
- {
- new pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
- return pname;
- }
- stock IsNumeric(const string[])
- {
- for (new i = 0, j = strlen(string); i < j; i++)
- if(string[i] > '9' || string[i] < '0') return 0;
- return 1;
- }
- stock ReturnUser(PlayerName[])
- {
- if(IsNumeric(PlayerName))
- return strval(PlayerName);
- else
- {
- new found=0, id;
- for(new i=0; i <= MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- new foundname[MAX_PLAYER_NAME];
- GetPlayerName(i, foundname, MAX_PLAYER_NAME);
- new namelen = strlen(foundname);
- new bool:searched=false;
- for(new pos=0; pos <= namelen; pos++)
- {
- if(searched != true)
- {
- if(strfind(foundname,PlayerName,true) == pos)
- {
- found++;
- id = i;
- }
- }
- }
- }
- }
- if(found == 1)
- return id;
- else
- return INVALID_PLAYER_ID;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement