Advertisement
Guest User

DJ System V2

a guest
Apr 25th, 2016
1,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. //CREDITS:
  2. Jubaer Editing the script and add some more updates
  3. dh240473 for the Real Script
  4. DracoBlue for Dini
  5. Zeex for ZCMD
  6. Y_Less for sscanf2
  7. Kar for Foreach
  8. //
  9.  
  10. #include <a_samp>
  11. #include <dini>
  12. #include <zcmd>
  13. #include <sscanf2>
  14. #include <foreach>
  15. #define FILE1 "DJ/%s.ini"
  16. #define COLOR_YELLOW 0xFFFF00FF
  17. #define COLOR_WHITE 0xFFFFFFFF
  18. #define COLOR_ORANGE 0xFF9900FF
  19. #define COLOR_RED 0xFF0000FF
  20.  
  21.  
  22. new DJ[MAX_PLAYERS];
  23.  
  24. public OnFilterScriptInit()
  25. {
  26. print("\n==========================");
  27. print(" DJ SYSTEM BY JUBAER");
  28. print("============================/n");
  29. return 1;
  30. }
  31.  
  32. public OnFilterScriptExit()
  33. {
  34. return 1;
  35. }
  36. main()
  37. {
  38. }
  39. public OnPlayerConnect(playerid)
  40. {
  41. new file[MAX_PLAYERS];
  42. format(file, sizeof(file), FILE1, IsPlayerName(playerid));
  43. if(!fexist(file))
  44. {
  45. dini_Create(file);
  46. dini_IntSet(file, "DJ", 0);
  47. DJ[playerid] = dini_Int(file, "DJ");
  48. } else {
  49. DJ[playerid] = dini_Int(file, "DJ");
  50. }
  51. return 1;
  52. }
  53. public OnPlayerDisconnect(playerid, reason)
  54. {
  55. new file[MAX_PLAYERS];
  56. format(file, sizeof(file), FILE1, IsPlayerName(playerid));
  57. dini_IntSet(file, "DJ", DJ[playerid]);
  58. DJ[playerid] = 0;
  59. return 1;
  60. }
  61. stock IsPlayerName(playerid)
  62. {
  63. new name[MAX_PLAYER_NAME];
  64. GetPlayerName(playerid, name, sizeof(name));
  65. return name;
  66. }
  67. CMD:dcmds(playerid, params[])
  68. {
  69. new playername[25];
  70. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  71. if(DJ[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Error: You aren't DJ.");
  72. SendClientMessage(playerid, COLOR_YELLOW, "DJ Commands");
  73. SendClientMessage(playerid, COLOR_WHITE, "/playsong, /stopsong, /dc, /addsong, /delsong");
  74. return 1;
  75. }
  76.  
  77. CMD:stopsong(playerid, params[])
  78. {
  79. new playername[25];
  80. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  81. if(DJ[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Error: You aren't DJ.");
  82. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  83. for(new i = 0; i < MAX_PLAYERS; i++)
  84. StopAudioStreamForPlayer(i);
  85. SendClientMessageToAll(playerid, "{FFFF00}[DJ]: A DJ has stoped an song.");
  86. return 1;
  87. }
  88.  
  89. CMD:stopmusic(playerid, params[])
  90. {
  91. SendClientMessage(playerid, COLOR_WHITE, "Music stopped.");
  92. StopAudioStreamForPlayer(playerid);
  93. return 1;
  94. }
  95.  
  96. CMD:dc(playerid, params[])
  97. {
  98. new Nam[MAX_PLAYERS], message[128], str[256], playername[25];
  99. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  100. if(DJ[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Error: You aren't DJ.");
  101. if(sscanf(params,"s",message)) return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /dc [Text]");
  102. GetPlayerName(playerid,Nam,sizeof(Nam));
  103. format(str,sizeof(str),"DJ Chat [%s] %s",Nam,message);
  104. for (new a=0;a<MAX_PLAYERS;a++)
  105. {
  106. if (IsPlayerConnected(a))
  107. {
  108. if(DJ[playerid] == 1)
  109. {
  110. SendClientMessage(a, COLOR_ORANGE, str);
  111. }
  112. }
  113. }
  114. return 1;
  115. }
  116.  
  117. CMD:playsong(playerid, params[])
  118. {
  119. new playername[25];
  120. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  121. if(DJ[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Error: You aren't DJ.");
  122. if(sscanf(params, "s[200]", params)) return SendClientMessage(playerid, -1, "Usage: /playsong [link]");
  123. SendClientMessageToAll(playerid, "{FFFF00}[DJ]: A DJ has played an song. /stopmusic to stop it");
  124. foreach(Player, i)
  125. {
  126. PlayAudioStreamForPlayer(i, params);
  127. }
  128. return 1;
  129. }
  130. CMD:dj(playerid, params[])
  131. {
  132. if(IsPlayerAdmin(playerid))
  133. {
  134. new string[MAX_PLAYERS], targetid, license;
  135. if(sscanf(params, "ud", targetid, license)) return SendClientMessage(playerid, -1, "{FF9900}Usage: /dj [playerid] [1 - enable 0 - disable]");
  136. if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "{FF9900}Error: That player is not connected!");
  137. if(license == 1)
  138. {
  139. DJ[targetid] = 1;
  140. format(string, sizeof(string), "{FFFF00}You have set %s as DJ.", IsPlayerName(targetid));
  141. SendClientMessage(playerid, -1, string);
  142. format(string, sizeof(string), "{FFFF00}An Admin has set you DJ.");
  143. SendClientMessage(targetid, -1, string);
  144. } else {
  145. DJ[targetid] = 0;
  146. format(string, sizeof(string), "{FFFF00}You have remove %s from DJ.", IsPlayerName(targetid));
  147. SendClientMessage(playerid, -1, string);
  148. format(string, sizeof(string), "{FFFF00}An Admin has remove you from DJ.");
  149. SendClientMessage(targetid, -1, string);
  150. }
  151.  
  152. }
  153. return 1;
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement