Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Drop FilterScript for SA-MP
- * Creator: 002
- * Date:20.08.2019
- *
- *
- */
- #include <a_samp>
- #include <sscanf2>
- #include <YSI\y_ini>
- #include <zcmd>
- //--//
- //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- #define DIALOG_MUSICCREATE 169
- #define DIALOG_SINGERNAME DIALOG_MUSICCREATE+1
- #define DIALOG_DURATION DIALOG_SINGERNAME+1
- #define DIALOG_URL DIALOG_DURATION+1
- #define MAX_MUSIC 500
- #define MUSIC_F "music.ini"
- enum musicData {
- Song[30],
- Singer[25],
- Duration[10],
- URL[200]
- }
- new Music[ MAX_MUSIC ][ musicData ];
- //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- forward split(const strsrc[], strdest[][], delimiter);
- //-->>
- public split(const strsrc[], strdest[][], delimiter)
- {
- new i, li;
- new aNum;
- new len;
- while(i <= strlen(strsrc)){
- if(strsrc[ i ]==delimiter || i==strlen(strsrc)){
- len = strmid(strdest[aNum], strsrc, li, i, 128);
- strdest[aNum][len] = 0;
- li = i+1;
- aNum++;
- }
- i++;
- }
- return 1;
- }
- //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- 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;
- }
- //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- //-- >> Save and Load
- forward SaveMusic( );
- public SaveMusic( ) {
- if( fexist( MUSIC_F ) ) {
- fremove( MUSIC_F );
- }
- new File:music_file = fopen( MUSIC_F, io_append ),
- str[100];
- for( new i = 0; i < MAX_MUSIC; i++) {
- format(str, sizeof(str), "%s,%s,%d,%s\n",Music[i][Singer],Music[i][Song],Music[i][Duration],Music[i][URL]);
- fwrite(music_file, str);
- }
- fclose(music_file);
- return (true);
- }
- forward LoadMusic( );
- public LoadMusic( ) {
- if( fexist( MUSIC_F ) ) {
- new File:music_file = fopen( MUSIC_F, io_read ),
- str[100],
- i = 0;
- new MusicLoad[ 5 ][ 64 ];
- while( fread( music_file, str ) )
- {
- split( str, MusicLoad, ',' );
- strmid( Music[ i ][ Song ], MusicLoad[ 0 ], 0, strlen( MusicLoad[ 0 ] ), 255);
- strmid( Music[ i ][ Singer ], MusicLoad[ 1 ], 0, strlen( MusicLoad[ 1 ] ), 255);
- Music[ i ][ Duration ] = strval( MusicLoad[ 2 ] );
- strmid( Music[ i ][ URL ], MusicLoad[ 3 ], 0, strlen( MusicLoad[ 3 ] ), 255);
- i++;
- }
- fclose(music_file);
- }
- return (true);
- }
- //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- public OnGameModeInit()
- {
- LoadMusic();
- #if defined music_OnGameModeInit
- return music_OnGameModeInit();
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit music_OnGameModeInit
- #if defined music_OnGameModeInit
- forward music_OnGameModeInit();
- #endif
- public OnGameModeExit()
- {
- SaveMusic();
- #if defined music_OnGameModeExit
- return music_OnGameModeExit();
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnGameModeExit
- #undef OnGameModeExit
- #else
- #define _ALS_OnGameModeExit
- #endif
- #define OnGameModeExit music_OnGameModeExit
- #if defined music_OnGameModeExit
- forward music_OnGameModeExit();
- #endif
- //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_MUSICCREATE:
- {
- if( response )
- {
- new id = -1,
- songname[30];
- //>>
- for( new b = 0; b < MAX_MUSIC; b++ ) {
- if( Music[ b ][ Song ] != 1 ) {
- id = b;
- break;
- }
- else continue;
- }
- if( id == -1 ) return SendClientMessage(playerid, -1, "{4bc206}Music >>{FFFFFF} Presli ste maksimum pesma, kako bi dodali jos morate obrisati neke!");
- //>>//
- if( sscanf( inputtext, "s[30]", songname ) ) return ShowPlayerDialog(playerid, DIALOG_MUSICCREATE, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite ime pesme.", ">>", "X");
- strmid( Music[ id ][ Song ], songname, 0, strlen( songname ), 30);
- printf("%s",Music[id][Song]);
- ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite ime izvodjaca.", ">>", "X");
- }
- }
- case DIALOG_SINGERNAME:
- {
- if( response )
- {
- new singername[25],
- id = -1;
- for( new b = 0; b < MAX_MUSIC; b++ ) {
- if( Music[ b ][ Song ] != 1 ) {
- id = b;
- break;
- }
- else continue;
- }
- if( id == -1 ) return SendClientMessage(playerid, -1, "{4bc206}Music >>{FFFFFF} Presli ste maksimum pesma, kako bi dodali jos morate obrisati neke!");
- if( sscanf( inputtext,"s[25]",singername)) return ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Greska pokusajte ponovo\nUnesite ime izvodjaca.", ">>", "X");
- if(strlen(singername) < 3 || strlen(singername) > 24) return ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Ime izvodjaca ne sme da sadrzi vise od 25 karaktera\nUnesite ime izvodjaca.", ">>", "X");
- strmid(Music[ id ][ Singer ], singername, 0, strlen( singername ), 25);
- printf("%s",Music[id][Singer]);
- ShowPlayerDialog(playerid, DIALOG_DURATION, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite duzinu pesme.(U minutama)", ">>", "X");
- }
- }
- case DIALOG_DURATION:
- {
- if( response )
- {
- new duration[10],
- id = -1;
- if( !IsNumeric( inputtext ) ) {
- ShowPlayerDialog(playerid, DIALOG_DURATION, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Morate koristiti samo brojeve!\nUnesite duzinu pesme.(U minutama).", ">>", "X");
- return (true);
- }
- if( sscanf( inputtext,"s[25]",duration)) return ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "", ">>", "X");
- if( strlen(duration) < 1 || strlen(duration) > 9 ) return ShowPlayerDialog(playerid, DIALOG_DURATION, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Trajanje pesme ne sme da zadrzi manje od 1 ili vise od 9 karaktera!\nUnesite duzinu pesme.(U minutama).", ">>", "X");
- Music[ id ][ Duration ] = duration;
- ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite URL pesme(Sa Direct Download linkom, najbolje kiwi ili slicno).", ">>", "X");
- }
- }
- case DIALOG_URL:
- {
- if( response )
- {
- new url[200],
- id = -1;
- if( sscanf( inputtext,"s[25]",url)) return ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Greska pokusajte ponovo\nUnesite URL pesme(Sa Direct Download linkom, najbolje kiwi ili slicno).", ">>", "X");
- if(strlen(url) < 5 || strlen(url) > 200) return ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "URL ne sme da sadrzi manje od 5 ili vise od 200 karaktera\nUnesite ime izvodjaca.", ">>", "X");
- strmid(Music[ id ][ URL ], url, 0, strlen( url ), 200);
- SaveMusic( );
- }
- }
- }
- return (true);
- }
- CMD:muzika(playerid)
- {
- ShowPlayerDialog(playerid, DIALOG_MUSICCREATE, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite ime pesme.", ">>", "X");
- return(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement