Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*=====================================================================================================================================
- =================================================================================================================================================
- =============================================================================================================================================================
- =========================================================================================================================================================
- ========================================================== Melodii Dinamice =================================================================================
- ============================================================ by Gireada =================================================================================================
- ====================================================================================================================================================
- ======================================================================================================================================================
- ==============================================================================================================================================
- =======================================================================================================================================================*/
- #include <a_samp>
- #include <zcmd>
- #include <dini>
- #define MAX_MELODII 50 //Numarul de melodii din folderul melodii
- #define Dialog_Melodie 1
- #define Dialog_Melodie2 2
- #define Dialog_Melodie3 3
- new dialogmelodie[MAX_PLAYERS];
- enum MelodieData
- {
- Nume[40],
- URL[500]
- };
- new MelodieInfo[MAX_MELODII][MelodieData];
- forward IncarcaMelodii();
- forward SalveazaMelodii();
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Sistem de Melodii by Gireada");
- print("--------------------------------------\n");
- IncarcaMelodii();
- return 1;
- }
- public OnFilterScriptExit()
- {
- SalveazaMelodii();
- return 1;
- }
- main()
- {
- print("\n----------------------------------");
- print(" Sistem de Melodii by Gireada");
- print("----------------------------------\n");
- }
- CMD:stop(playerid, params[])
- {
- StopAudioStreamForPlayer(playerid);
- return 1;
- }
- CMD:melodii(playerid, params[])
- {
- new string[256],string2[2560];
- for(new i=0;i<=sizeof(MelodieInfo);i++)
- {
- new file[20];
- format(file, sizeof(file),"Melodii/%d.ini", i);
- if(dini_Exists(file))
- {
- if(i==0)
- {
- format(string, sizeof(string), "Melodia: %d | Nume: %s",i,MelodieInfo[i][Nume]);
- }
- else if(i>0)
- {
- format(string, sizeof(string), "\nMelodia: %d | Nume: %s",i,MelodieInfo[i][Nume]);
- }
- strcat(string2, string);
- }
- else if(!dini_Exists(file))
- {
- break;
- }
- ShowPlayerDialog(playerid, Dialog_Melodie3, DIALOG_STYLE_LIST,"Alege Melodie",string2,"Play","Anulez");
- }
- return 1;
- }
- CMD:adauga(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- for(new i=0; i<=sizeof(MelodieInfo);i++)
- {
- new file[20];
- format(file, sizeof(file),"Melodii/%d.ini", i);
- if(!dini_Exists(file))
- {
- dialogmelodie[playerid] = i;break;
- }
- }
- ShowPlayerDialog(playerid, Dialog_Melodie, DIALOG_STYLE_INPUT,"Adauga Melodie","[Pasul 1] Introdu URL-ul melodieii.",">","Anulez");
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new melodie = dialogmelodie[playerid];
- if(response)
- {
- switch(dialogid)
- {
- case Dialog_Melodie:
- {
- strmid(MelodieInfo[melodie][URL], inputtext, 0, strlen(inputtext), 999);
- ShowPlayerDialog(playerid, Dialog_Melodie2, DIALOG_STYLE_INPUT,"Adauga Melodie","[Pasul 2] Introdu numele artistului si numele melodiei \n Ex: Gireada - SAMP.","Gata","Anulez");
- }
- case Dialog_Melodie2:
- {
- if(strlen(inputtext) != 0)
- {
- new file[20];
- format(file, sizeof(file),"Melodii/%d.ini", melodie);
- strmid(MelodieInfo[melodie][Nume], inputtext, 0, strlen(inputtext), 999);
- dini_Create(file);
- dini_Set(file,"URL",MelodieInfo[melodie][URL]);
- dini_Set(file,"Nume",MelodieInfo[melodie][Nume]);
- }
- else
- {
- ShowPlayerDialog(playerid, Dialog_Melodie2, DIALOG_STYLE_INPUT,"Adauga Melodie","[Pasul 2] Introdu numele artistului si numele melodiei \n Ex: Gireada - SAMP.","Gata","Anulez");
- }
- }
- case Dialog_Melodie3:
- {
- new string[256];
- PlayAudioStreamForPlayer(playerid, MelodieInfo[listitem][URL]);
- format(string, sizeof(string), "Asculti %s",MelodieInfo[listitem][Nume]);
- SendClientMessage(playerid, 0xFFFFFFFF, string);
- }
- }
- }
- return 1;
- }
- public SalveazaMelodii()
- {
- for(new i=0;i<=sizeof(MelodieInfo);i++)
- {
- new file[20];
- format(file, sizeof(file),"Melodii/%d.ini", i);
- if(dini_Exists(file))
- {
- dini_Set(file,"URL",MelodieInfo[i][URL]);
- dini_Set(file,"Nume",MelodieInfo[i][Nume]);
- }
- }
- return 1;
- }
- public IncarcaMelodii()
- {
- for(new i=0;i<=sizeof(MelodieInfo);i++)
- {
- new file[20];
- format(file, sizeof(file),"Melodii/%d.ini", i);
- if(dini_Exists(file))
- {
- strmid(MelodieInfo[i][Nume], dini_Get(file,"Nume"), 0, strlen(dini_Get(file,"Nume")), 999);
- strmid(MelodieInfo[i][URL], dini_Get(file,"URL"), 0, strlen(dini_Get(file,"URL")), 999);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement