Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Name: VBMail
- Description: Email system
- Author: ViniBorn
- Contact : [email protected]
- Country : Brazil
- Fordította: Suzuki
- *** *** *** ***** *** *** *** *** ***** ******** ****** ***
- *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** ***
- *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** ***
- *** *** *** *** *** *** *** *** ** *** *** *** *** *** *** ***
- ****** *** *** ****** *** *** **** ***** *** *** *** ******
- Do not remove the credits.
- Your name is valuable, do not mess it.
- Comments:
- - The default directory for saving e-mail is: scriptfiles / emails. Create e-mail folder.
- - The default directory for user accounts is: scriptfiles / users. Modify the Players defines, according to
- where the accounts are saved on your server.
- - The inbox each player has a capacity of 10 emails.
- Updates :
- * 20/08/11
- - New method for reading email using DIALOG_STYLE_LIST
- - Indication of e-mails (Read) or (not read)
- */
- #include <a_samp>
- #include <Dini>
- #define Local "/emails/%s.ini" // Directory of emails
- #define Players "/users/%s.ini" // Directory of accounts
- new Receiver[MAX_PLAYERS][32];
- static const Status[2][14] = {
- {"(Read) - "},
- {"(Not read) - "}
- };
- new Emails[][10] = {
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- "10"
- };
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" E-mail system By: ViniBorn");
- print(" - Do not remove the credits - ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n\tE-mail system finished.");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/pcvasarlas", cmdtext, true, 10) == 0)
- {
- if(GetPlayerMoney(playerid) < 2000)
- return SendClientMessage(playerid, 0xAFAFAFAA,"Nincsen elég pénzed..");
- new email[32];
- format(email,32,Local,Player(playerid));
- if(dini_Exists(email))
- return SendClientMessage(playerid, 0xAFAFAFAA,"Már van egy számítógéped.");
- dini_Create(email);
- for(new i=0;i<sizeof(Emails);i++)
- dini_Set(email,Emails[i],"Üres");
- GameTextForPlayer(playerid, "költség. : $ 2.000", 5000, 1);
- GivePlayerMoney(playerid, -2000);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- SendClientMessage(playerid, 0xAFAFAFAA, "Most már használhatja az e-mailját /email parancsal.");
- 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,"Önnek nincsen számítógépe.");
- new listitems[] = "Olvasás\nKüld\nTörlés";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Én email-óm : ", listitems,"Választ","Kilépés");
- 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, "postafiók : ", string,"Választ","Vissza");
- }
- case 1: ShowPlayerDialog(playerid, 227,DIALOG_STYLE_INPUT,"E-mail","Adja meg a címzett nevét:","Küld","Vissza");
- case 2: ShowPlayerDialog(playerid, 228,DIALOG_STYLE_INPUT,"E-mail","Adja meg a telefonszámát a küldéshez.","Törlés","Vissza");
- }
- }
- }
- else if(dialogid == 226)//Olvasás
- {
- if(!response)
- {
- new listitems[] = "Olvasás\nKüldés\nTörlés";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Én email-óm : ", listitems,"Választ","Kilépés");
- }
- else
- MyEmail(playerid,listitem);
- }
- else if(dialogid == 227)//Küldés (receiver)
- {
- if(!response)
- {
- new listitems[] = "Olvasás\nKüldés\nTörlés";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Én email-óm : ", listitems,"Választ","Kilépés");
- }
- 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,"[Hiba] A Játékos nem rendelkezik számítógéppel.");
- new str[128];
- format(str,128,"Arra készüszl, hogy küldj egy e-mailt %s. Írja be az üzenetet..", inputtext);
- SendClientMessage(playerid, 0xFFD700AA,str);
- format(Receiver[playerid],32,inputtext);
- return ShowPlayerDialog(playerid,229,DIALOG_STYLE_INPUT,"E-mail","Írja be az üzenetet:","Küldés","Vissza");
- }
- else
- SendClientMessage(playerid,0xAA3333AA,"[Hiba] A Fiók nem létezik.");
- }
- }
- else if(dialogid == 228)//Törlés
- {
- if(!response)
- {
- new listitems[] = "Olvasás\nKüldés\nTörlés";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Én email-óm : ", listitems,"Választ","Kilépés");
- }
- else
- {
- new n;
- n = strval(inputtext);
- new email[32];
- format(email,32,Local,Player(playerid));
- dini_Set(email,Emails[n-1],"Üres");
- }
- }
- else if(dialogid == 229)//Olvasás (üzenet.)
- {
- if(response)
- {
- SendClientMessage(playerid,0xFFD700AA,"E-mail sikeresen elküldted.");
- SendEmail(playerid,inputtext);
- }
- }
- else if(dialogid == 230)//Email megjelenítése.
- {
- if(response)
- {
- new listitems[] = "Olvasás\nKüldés\nTörlés";
- ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Én email-óm : ", listitems,"Választ","Kilépés");
- }
- }
- return 1;
- }
- stock MyEmail(playerid,number)
- {
- new email[32],email2[128];
- format(email,32,Local,Player(playerid));
- if(strcmp(dini_Get(email,Emails[number]),"Üres",true)==0)
- return ShowPlayerDialog(playerid, 225, DIALOG_STYLE_LIST, "Én email-óm : ", listitems,"Választ","Kilépés");
- format(email2,128,"%s",dini_Get(email,Emails[number]));
- if(email2[1] == 'N')
- {
- strdel(email2,0,14);
- dini_Set(email,Emails[number],email2);
- format(email2,128,"%s%s",Status[0],dini_Get(email,Emails[number]));
- dini_Set(email,Emails[number],email2);
- }
- ShowPlayerDialog(playerid, 230, DIALOG_STYLE_MSGBOX, "Postafiók", email2, "Vissza", "Kilépés");
- return 1;
- }
- stock SendEmail(playerid,const string[])
- {
- new email[32],str[128];
- format(email,32,Local,Receiver[playerid]);
- if(!dini_Exists(email))
- {
- for(new i=0;i<sizeof(Emails);i++)
- dini_Set(email,Emails[i],"Üres");
- }
- else
- {
- format(str,128,"%s %s -Feladó : %s",Status[1],string,Player(playerid));
- for(new i=0;i<sizeof(Emails);i++)
- if(strcmp(dini_Get(email,Emails[i]),"Üres",true)==0)
- {
- new giveid = ReturnUser(Receiver[playerid]);
- if(IsPlayerConnected(giveid))
- GameTextForPlayer(giveid, "Ön kapott egy új e-mailt.", 5000, 5);
- dini_Set(email,Emails[i],str);
- return 1;
- }
- return SendClientMessage(playerid,0xAA3333AA,"[Hiba] A postafiók megtelt.");
- }
- 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