_Rolux_

ZENELEJÁTSZÓ

Jul 18th, 2016
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <a_mysql>
  3. #include <zcmd>
  4. #include <sscanf2>
  5.  
  6. //»Definiciók
  7. #define MAX_SONGS 100
  8. #define DIALOG_ZENE 100
  9.  
  10. //»Változók
  11. new sql;
  12. new zenek;
  13.  
  14. enum music
  15. {
  16.     m_id,
  17.     m_artist[32],
  18.     m_song[32],
  19.     m_link[96]
  20. }
  21. new mInfo[MAX_SONGS][music];
  22.  
  23. //»Forward(ok)
  24. forward LoadSongs();
  25. forward InsertSong(a[],b[],c[]);
  26.  
  27. public OnFilterScriptInit()
  28. {
  29.     sql = mysql_connect("127.0.0.1", "root", "teszt", "");
  30.     if(mysql_errno() != 0)
  31.     {
  32.         print("[MySQL] » Sikertelen csatlakozás!");
  33.     }
  34.     else
  35.     {
  36.         print("[MySQL] » Sikeres csatlakozás!");
  37.     }
  38.     print("[Zenelejátszó] » Zenék betöltése..");
  39.     mysql_tquery(sql, "SELECT * FROM songs", "LoadSongs");
  40.     return 1;
  41. }
  42.  
  43. CMD:zene(playerid)
  44. {
  45.     return ShowMusic(playerid);
  46. }
  47.  
  48. CMD:ujzene(playerid,params[])
  49. {
  50.     new artist[32],song[32],link[96],string[96];
  51.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xf03c3cAA,"Nem vagy RCON admin!");
  52.     if(sscanf(params, "s[32]s[32]s[96]",artist,song,link)) return SendClientMessage(playerid,0xf03c3cAA,"/újzene [Előadó] [szám Címe] [Link]");
  53.     for(new i = 0; i < zenek; i++)
  54.     {
  55.     if( strcmp(mInfo[i][m_artist],artist) == 0 && strcmp(mInfo[i][m_song],song) == 0 ) return SendClientMessage(playerid,0xf03c3cAA,"Már van ilyen Előadó/Szám kombináció");
  56.     }
  57.     new query[256];
  58.     mysql_format(sql, query, 256, "INSERT INTO songs (Artist,Song,Link) VALUES ('%s','%s','%s')",artist,song,link);
  59.     mysql_tquery(sql, query,"InsertSong","sss",artist,song,link);
  60.     format(string,96,"Sikeresen elmentettél egy új zenét! Előadó: %s , Szám : %s",artist,song);
  61.     SendClientMessage(playerid,0x1cd657AA,string);
  62.     return 1;
  63. }
  64.  
  65.  
  66. CMD:refresh(playerid,params[])
  67. {
  68.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xf03c3cAA,"Nem vagy RCON admin!");
  69.     for(new i = 0; i < zenek; i++)
  70.     {
  71.         mInfo[i][m_id] = 0;
  72.         mInfo[i][m_artist] = EOS;
  73.         mInfo[i][m_song] = EOS;
  74.         mInfo[i][m_link] = EOS;
  75.     }
  76.     zenek = 0;
  77.     mysql_tquery(sql, "SELECT * FROM songs", "LoadSongs");
  78.     SendClientMessage(playerid,0x1cd657AA,"Sikeresen frissítetted a zenéket!");
  79.     return 1;
  80. }
  81.  
  82. stock ShowMusic(playerid)
  83. {
  84.     new str[512] = "Előadó\t-\tSzám\n{f03c3c}Zene megállítása\n",str2[100],count;
  85.     for(new i = 0; i < zenek; i++)
  86.     {
  87.     format(str2,sizeof(str2),"%s\t-\t%s\n",mInfo[i][m_artist],mInfo[i][m_song]);
  88.     strcat(str,str2);
  89.     count = 1;
  90.     }
  91.     if(count != 1) return SendClientMessage(playerid,0xf03c3cAA,"Sajnos még nincsenek zenék a szerveren :/");
  92.     ShowPlayerDialog(playerid,DIALOG_ZENE,DIALOG_STYLE_TABLIST_HEADERS,"Zenelejátszó",str, "Meghallgat", "Kilép");
  93.     return 1;
  94. }
  95.  
  96.  
  97. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  98. {
  99.     if(dialogid == DIALOG_ZENE)
  100.     {
  101.         if(response)
  102.         {
  103.             if(listitem == 0)
  104.             {
  105.                 StopAudioStreamForPlayer(playerid);
  106.                 SendClientMessage(playerid,0xf03c3cAA,"Zene megállítva!");
  107.             }
  108.             else
  109.             {
  110.                 PlayAudioStreamForPlayer(playerid,mInfo[listitem-1][m_link]);
  111.                 new string[100];
  112.                 format(string,100,"Zene elindítva! / Előadó: %s / Szám : %s /",mInfo[listitem-1][m_artist],mInfo[listitem-1][m_song]);
  113.                 SendClientMessage(playerid,0x8a3cf0AA,string);
  114.             }
  115.         }
  116.     }
  117.     return 1;
  118. }
  119.  
  120. public LoadSongs()
  121. {
  122.     for(new i = 0; i < cache_get_row_count(); i++)
  123.     {
  124.         mInfo[i][m_id] = cache_get_row_int(i,0);
  125.         cache_get_row(i, 1,mInfo[i][m_artist],1,32);
  126.         cache_get_row(i, 2,mInfo[i][m_song],1,32);
  127.         cache_get_row(i, 3,mInfo[i][m_link],1,96);
  128.         zenek ++;
  129.     }
  130.     printf("[Zenelejátszó] » %d db zene sikeresen betöltve.",zenek);
  131.     return 1;
  132. }
  133.  
  134.  
  135. public InsertSong(a[],b[],c[])
  136. {
  137.     mInfo[zenek][m_id] = cache_insert_id();
  138.     strins(mInfo[zenek][m_artist],a,0);
  139.     strins(mInfo[zenek][m_song],b,0);
  140.     strins(mInfo[zenek][m_link],c,0);
  141.     zenek++;
  142.     return 1;
  143. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×