SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  *
  3.  *      Drop FilterScript for SA-MP
  4.  *          Creator: 002
  5.  *              Date:20.08.2019
  6.  *
  7.  *
  8. */
  9. #include <a_samp>
  10. #include <sscanf2>
  11. #include <YSI\y_ini>
  12. #include <zcmd>
  13. //--//
  14.  
  15. //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  16. #define DIALOG_MUSICCREATE 169
  17. #define DIALOG_SINGERNAME DIALOG_MUSICCREATE+1
  18. #define DIALOG_DURATION DIALOG_SINGERNAME+1
  19. #define DIALOG_URL DIALOG_DURATION+1
  20. #define MAX_MUSIC 500
  21. #define MUSIC_F "music.ini"
  22.  
  23. enum musicData {
  24.     Song[30],
  25.     Singer[25],
  26.     Duration[10],
  27.     URL[200]
  28. }
  29.  
  30. new Music[ MAX_MUSIC ][ musicData ];
  31. //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  32. forward split(const strsrc[], strdest[][], delimiter);
  33. //-->>
  34. public split(const strsrc[], strdest[][], delimiter)
  35. {
  36.     new i, li;
  37.     new aNum;
  38.     new len;
  39.     while(i <= strlen(strsrc)){
  40.         if(strsrc[ i ]==delimiter || i==strlen(strsrc)){
  41.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  42.             strdest[aNum][len] = 0;
  43.             li = i+1;
  44.             aNum++;
  45.         }
  46.         i++;
  47.     }
  48.     return 1;
  49. }
  50. //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  51. stock IsNumeric(const string[])
  52. {
  53.     for (new i = 0, j = strlen(string); i < j; i++)
  54.     {
  55.         if (string[i] > '9' || string[i] < '0') return 0;
  56.     }
  57.     return 1;
  58. }
  59. //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  60. //-- >> Save and Load
  61. forward SaveMusic( );
  62. public SaveMusic( ) {
  63.  
  64.     if( fexist( MUSIC_F ) ) {
  65.         fremove( MUSIC_F );
  66.     }
  67.  
  68.     new File:music_file = fopen( MUSIC_F, io_append ),
  69.         str[100];
  70.  
  71.     for( new i = 0; i < MAX_MUSIC; i++) {
  72.         format(str, sizeof(str), "%s,%s,%d,%s\n",Music[i][Singer],Music[i][Song],Music[i][Duration],Music[i][URL]);
  73.         fwrite(music_file, str);
  74.     }
  75.  
  76.     fclose(music_file);
  77.  
  78.     return (true);
  79. }
  80. forward LoadMusic( );
  81. public LoadMusic( ) {
  82.  
  83.     if( fexist( MUSIC_F ) ) {
  84.         new File:music_file = fopen( MUSIC_F, io_read ),
  85.             str[100],
  86.             i = 0;
  87.         new MusicLoad[ 5 ][ 64 ];
  88.         while( fread( music_file, str ) )
  89.         {
  90.             split( str, MusicLoad, ',' );
  91.             strmid( Music[ i ][ Song ], MusicLoad[ 0 ], 0, strlen( MusicLoad[ 0 ] ), 255);
  92.             strmid( Music[ i ][ Singer ], MusicLoad[ 1 ], 0, strlen( MusicLoad[ 1 ] ), 255);
  93.             Music[ i ][ Duration ] = strval( MusicLoad[ 2 ] );
  94.             strmid( Music[ i ][ URL ], MusicLoad[ 3 ], 0, strlen( MusicLoad[ 3 ] ), 255);
  95.             i++;
  96.         }
  97.  
  98.         fclose(music_file);
  99.     }
  100.  
  101.     return (true);
  102. }
  103. //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  104. public OnGameModeInit()
  105. {
  106.     LoadMusic();
  107.     #if defined music_OnGameModeInit
  108.         return music_OnGameModeInit();
  109.     #else
  110.         return 1;
  111.     #endif
  112. }
  113. #if defined _ALS_OnGameModeInit
  114.     #undef OnGameModeInit
  115. #else
  116.     #define _ALS_OnGameModeInit
  117. #endif
  118.  
  119. #define OnGameModeInit music_OnGameModeInit
  120. #if defined music_OnGameModeInit
  121.     forward music_OnGameModeInit();
  122. #endif
  123.  
  124.    
  125. public OnGameModeExit()
  126. {
  127.     SaveMusic();
  128.     #if defined music_OnGameModeExit
  129.         return music_OnGameModeExit();
  130.     #else
  131.         return 1;
  132.     #endif
  133. }
  134. #if defined _ALS_OnGameModeExit
  135.     #undef OnGameModeExit
  136. #else
  137.     #define _ALS_OnGameModeExit
  138. #endif
  139.  
  140. #define OnGameModeExit music_OnGameModeExit
  141. #if defined music_OnGameModeExit
  142.     forward music_OnGameModeExit();
  143. #endif
  144. //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  145. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  146. {
  147.     switch(dialogid)
  148.     {
  149.  
  150.         case DIALOG_MUSICCREATE:
  151.         {
  152.  
  153.             if( response )
  154.             {
  155.                 new id = -1,
  156.                     songname[30];
  157.                     //>>
  158.                 for( new b = 0; b < MAX_MUSIC; b++ ) {
  159.                     if( Music[ b ][ Song ] != 1 ) {
  160.                         id = b;
  161.                         break;
  162.                     }
  163.                     else continue;
  164.                 }
  165.  
  166.                 if( id == -1 ) return SendClientMessage(playerid, -1, "{4bc206}Music >>{FFFFFF} Presli ste maksimum pesma, kako bi dodali jos morate obrisati neke!");
  167.                 //>>//
  168.                 if( sscanf( inputtext, "s[30]", songname ) ) return ShowPlayerDialog(playerid, DIALOG_MUSICCREATE, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite ime pesme.", ">>", "X");
  169.                 strmid( Music[ id ][ Song ], songname, 0, strlen( songname ), 30);
  170.                 printf("%s",Music[id][Song]);
  171.                 ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite ime izvodjaca.", ">>", "X");
  172.             }
  173.         }
  174.         case DIALOG_SINGERNAME:
  175.         {
  176.  
  177.             if( response )
  178.             {
  179.                 new singername[25],
  180.                     id = -1;
  181.                 for( new b = 0; b < MAX_MUSIC; b++ ) {
  182.                     if( Music[ b ][ Song ] != 1 ) {
  183.                         id = b;
  184.                         break;
  185.                     }
  186.                     else continue;
  187.                 }
  188.  
  189.                 if( id == -1 ) return SendClientMessage(playerid, -1, "{4bc206}Music >>{FFFFFF} Presli ste maksimum pesma, kako bi dodali jos morate obrisati neke!");
  190.                 if( sscanf( inputtext,"s[25]",singername)) return ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Greska pokusajte ponovo\nUnesite ime izvodjaca.", ">>", "X");
  191.                 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");
  192.                
  193.                 strmid(Music[ id ][ Singer ], singername, 0, strlen( singername ), 25);
  194.                 printf("%s",Music[id][Singer]);
  195.                 ShowPlayerDialog(playerid, DIALOG_DURATION, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite duzinu pesme.(U minutama)", ">>", "X");
  196.             }
  197.         }
  198.         case DIALOG_DURATION:
  199.         {
  200.  
  201.             if( response )
  202.             {
  203.                 new duration[10],
  204.                     id = -1;
  205.  
  206.                 if( !IsNumeric( inputtext ) ) {
  207.                     ShowPlayerDialog(playerid, DIALOG_DURATION, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Morate koristiti samo brojeve!\nUnesite duzinu pesme.(U minutama).", ">>", "X");
  208.                     return (true);
  209.                 }
  210.                
  211.  
  212.                 if( sscanf( inputtext,"s[25]",duration)) return ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "", ">>", "X");
  213.                 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");       
  214.                
  215.  
  216.                 Music[ id ][ Duration ] = duration;
  217.                 ShowPlayerDialog(playerid, DIALOG_SINGERNAME, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite URL pesme(Sa Direct Download linkom, najbolje kiwi ili slicno).", ">>", "X");
  218.             }
  219.         }
  220.         case DIALOG_URL:
  221.         {
  222.  
  223.             if( response )
  224.             {
  225.                 new url[200],
  226.                     id = -1;
  227.  
  228.                 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");
  229.                 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");
  230.                
  231.                 strmid(Music[ id ][ URL ], url, 0, strlen( url ), 200);
  232.                 SaveMusic( );
  233.             }
  234.         }
  235.     }
  236.     return (true);
  237. }
  238. CMD:muzika(playerid)
  239. {
  240.     ShowPlayerDialog(playerid, DIALOG_MUSICCREATE, DIALOG_STYLE_INPUT, "- Dodavanje Muzike", "Unesite ime pesme.", ">>", "X");
  241.     return(true);
  242. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top