Advertisement
Guest User

DJ Job script

a guest
Jul 9th, 2013
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.47 KB | None | 0 0
  1. /*
  2. _____________________________________________________________________________
  3. | |
  4. | |
  5. | |
  6. | $$$$$$ $$$$$$ $$$$$$ $$$$$$ |
  7. | $ $ $ $ $ $ $ |
  8. | $$$$$$ $ $$ $$$$$$ $$$$$$ |
  9. | $ $ $ $ $ $ $ |
  10. | $ $ $$$$$$ $ $ $ |
  11. | |
  12. | New DJ Job, suitable for everyone |
  13. | Scratch made by SandieL, feel free to use it |
  14. | Credits free, don't be afraid to Rep+ ;D Enjoy! |
  15. | |
  16. |_____________________________________________________________________________|
  17. */
  18.  
  19. #include <a_samp>
  20. #include <sscanf2>
  21. #include <ZCMD>
  22.  
  23. #define FILTERSCRIPT
  24. #define DIALOG_PARTY 1
  25. #define DIALOG_MUSICNAME 2
  26. #define DIALOG_MUSICURL 3
  27. #define P_VEH 459 // Change 459 to whatever vehicle you want as the DJ Van
  28. #define MinimumParticipants 5 // Change 5 to whatever minimum number of people you want
  29. #if defined FILTERSCRIPT
  30.  
  31. #define COLOR_LIGHTBLUE 0x33CCFFAA
  32. #define COLOR_GREY 0xAFAFAFAA
  33.  
  34. new bool:IsADJ[MAX_PLAYERS] = false; // Is the player a DJ?
  35. new bool:PartyStarted = false; // Is there a party going on already?
  36. new bool:PartyPrepared = false;
  37. new bool:Joined[MAX_PLAYERS] = false;
  38. new Float:PartyX;
  39. new Float:PartyY;
  40. new Float:PartyZ;
  41. new Admin[MAX_PLAYERS]; // This will be the admin variable in the system, you can change it if you want to.
  42. new CurrentParticipants; // Current participants in the party!
  43. new PartyVehicle;
  44. new SongName[128];
  45.  
  46. public OnFilterScriptInit()
  47. {
  48. print("\n--------------------------------------");
  49. print(" DJ Job scratch made by SandieL");
  50. print("--------------------------------------\n");
  51. CurrentParticipants = 0;
  52. PartyStarted = false;
  53. PartyPrepared = false;
  54. return 1;
  55. }
  56.  
  57. public OnFilterScriptExit()
  58. {
  59. return 1;
  60. }
  61.  
  62. #else
  63.  
  64. main() {}
  65.  
  66. #endif
  67.  
  68. forward DJTimer(playerid);
  69. public DJTimer(playerid)
  70. {
  71. if(IsADJ[playerid] == true)
  72. {
  73. new string[128];
  74. IsADJ[playerid] = false;
  75. PartyStarted = false;
  76. PartyPrepared = false;
  77. CurrentParticipants = 0;
  78. format(string, sizeof(string), "** %s has been removed from being a DJ because the time has passed!", N(playerid));
  79. SendClientMessageToAll(COLOR_LIGHTBLUE, string);
  80. }
  81. return 1;
  82. }
  83.  
  84. public OnPlayerConnect(playerid)
  85. {
  86. // MAKE SURE YOU CHECK IF THE PLAYER IS A DJ, IF SO, CHECK IF ANYONE ELSE IS A DJ ONLINE AND REMOVE ONE OF THEM
  87. // I don't have a save system in this filterscript, so it doesn't really matter if I do it.
  88. return 1;
  89. }
  90. public OnPlayerDisconnect(playerid, reason)
  91. {
  92. Joined[playerid] = false;
  93. CurrentParticipants--;
  94. // Don't forget to remove his DJ privliges if he is a DJ! (IsADJ[playerid] = false)
  95. return 1;
  96. }
  97.  
  98. CMD:assigndj(playerid, params[])
  99. {
  100. new ID, time;
  101. if(!sscanf(params, "ui", ID, time)) // parameters
  102. {
  103. if(Admin[playerid] == 1) // Is the player that executed the command an administrator
  104. {
  105. if(ID != INVALID_PLAYER_ID)
  106. {
  107. if(time < 6 || time > 0)
  108. {
  109. // Uncomment the line below to not be able to set yourself as DJ (has to be another person)
  110. //if(playerid == id) return SendClientMessage(playerid, COLOR_GREY, ".:: You cannot make yourself a DJ! ::.");
  111. for(new i = 0; i < MAX_PLAYERS; i++)
  112. if(IsADJ[i] == false) // Is there any DJ online at the moment? (also checks if the ID inserted is a DJ aswell)
  113. {
  114. new string[128];
  115. IsADJ[ID] = true;
  116. format(string, sizeof(string), "%s has made %s a DeeJay in the server!", N(playerid), N(ID));
  117. SendClientMessageToAll(COLOR_LIGHTBLUE, string);
  118. SetTimer("DJTimer", 3600000, 0);
  119. }
  120. else return SendClientMessage(playerid, COLOR_GREY, ".:: There already is a DJ online ::.");
  121. }
  122. else return SendClientMessage(playerid, COLOR_GREY, ".:: The DJ hours can't exceed 5 hours ::.");
  123. }
  124. else return SendClientMessage(playerid, COLOR_GREY, ".:: The player id you entered does not exist ::.");
  125. }
  126. else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
  127. }
  128. else return SendClientMessage(playerid, COLOR_GREY, ".:: USAGE: /assigndj [Playerid/PartOfName] [Hours] ::.");
  129. return 1;
  130. }
  131.  
  132. CMD:prepareparty(playerid, params[])
  133. {
  134. if(IsADJ[playerid] == true) // Is he a DJ?
  135. {
  136. if(PartyStarted == false && PartyPrepared == false) // Is there a party going on?
  137. {
  138. if(GetVehicleModel(GetPlayerVehicleID(playerid)) == P_VEH) // DJ Van
  139. {
  140. PartyVehicle = GetPlayerVehicleID(playerid);
  141. PartyPrepared = true;
  142. CurrentParticipants = 0;
  143. SendClientMessage(playerid, COLOR_LIGHTBLUE, "** The party is prepared, use /startparty to start it once there are 5 people!");
  144. GetPlayerPos(playerid, Float:PartyX, Float:PartyY, Float:PartyZ);
  145. for(new i = 0; i < MAX_PLAYERS; i++)
  146. if(playerid != i)
  147. {
  148. ShowPlayerDialog(playerid, DIALOG_PARTY, DIALOG_STYLE_MSGBOX, "There is a party going on...", "There is a party going on, it just started, do you wish to join?", "Okay", "Cancel");
  149. }
  150. }
  151. else return SendClientMessage(playerid, COLOR_GREY, ".:: You need to be inside the DJ Van to use this feature ::.");
  152. }
  153. else return SendClientMessage(playerid, COLOR_GREY, ".:: There already is a party underway (Or a party is already prepared, use /startparty) ::.");
  154. }
  155. else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
  156. return 1;
  157. }
  158. CMD:startparty(playerid, params[])
  159. {
  160. if(IsADJ[playerid] == true) // Is he a DJ?
  161. {
  162. if(PartyStarted == false) // Is there a party going on?
  163. {
  164. if(PartyPrepared == true) // Is the party prepared?
  165. {
  166. if(CurrentParticipants >= MinimumParticipants-1) // If there are the correct number of people to start this shit
  167. {
  168. PartyStarted = true;
  169. PartyPrepared = false;
  170. SendClientMessageToAll(COLOR_LIGHTBLUE, "** 5 people have joined the party, and it is underway, get there fast!");
  171. }
  172. else return SendClientMessage(playerid, COLOR_GREY, ".:: You must wait for atleast 5 people to join first! ::.");
  173. }
  174. else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party prepared, use /prepareparty to prepare one! ::.");
  175. }
  176. else return SendClientMessage(playerid, COLOR_GREY, ".:: There already is a party underway (Or a party is already prepared, use /startparty) ::.");
  177. }
  178. else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
  179. return 1;
  180. }
  181. CMD:play(playerid, params[])
  182. {
  183. if(IsADJ[playerid] == true)
  184. {
  185. if(PartyStarted == true)
  186. {
  187. if(IsPlayerInFrontVehicle(playerid,PartyVehicle,3,-4) == 1)
  188. {
  189. ShowPlayerDialog(playerid, DIALOG_MUSICNAME, DIALOG_STYLE_INPUT, "What is this songs name?", "What is the name of this song you are going to play?", "Okay", "Cancel");
  190. }
  191. else return SendClientMessage(playerid, COLOR_GREY, ".:: You need to be behind the Party Van to use this feature ::.");
  192. }
  193. else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party being held at the moment ::.");
  194. }
  195. else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
  196. return 1;
  197. }
  198. CMD:endparty(playerid, params[])
  199. {
  200. if(IsADJ[playerid] == true)
  201. {
  202. if(PartyStarted == true || PartyPrepared == true)
  203. {
  204. new string[128];
  205. PartyStarted = false;
  206. PartyPrepared = false;
  207. CurrentParticipants = 0;
  208. format(string, sizeof(string), "** DeeJay %s has ended the party! Untill next time. **", N(playerid));
  209. }
  210. else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party being held at the moment ::.");
  211. }
  212. else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
  213. return 1;
  214. }
  215.  
  216. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  217. {
  218. switch( dialogid )
  219. {
  220. case DIALOG_PARTY:
  221. {
  222. if(response)
  223. {
  224. if(PartyPrepared == true || PartyStarted == true)
  225. {
  226. if(Joined[playerid] == false)
  227. {
  228. SetPlayerCheckpoint(playerid, Float:PartyX, Float:PartyY, Float:PartyZ, 3);
  229. SendClientMessage(playerid, COLOR_GREY, " (( Get to the checkpoint to join the party before it's over!");
  230. }
  231. else return SendClientMessage(playerid, COLOR_GREY, ".:: You already joined this party! ::.");
  232. }
  233. else return SendClientMessage(playerid, COLOR_GREY, ".:: There are no current parties being held at the moment ::.");
  234. }
  235. }
  236. case DIALOG_MUSICNAME:
  237. {
  238. if(response)
  239. {
  240. if(PartyPrepared == true || PartyStarted == true)
  241. {
  242. format(SongName, sizeof(SongName), "%s", inputtext);
  243. ShowPlayerDialog(playerid, DIALOG_MUSICURL, DIALOG_STYLE_INPUT, "What is the URL of this song?", "Insert below the URL of the song you want to play (MUST BE MP3 LINK", "Okay", "Cancel");
  244. }
  245. else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party being held at the moment ::.");
  246. }
  247. }
  248. case DIALOG_MUSICURL:
  249. {
  250. if(response)
  251. {
  252. if(PartyPrepared == true || PartyStarted == true)
  253. {
  254. new string[128];
  255. format(string, sizeof(string), "** %s has played the song '%s' **", N(playerid), SongName);
  256. for(new i = 0; i < MAX_PLAYERS; i++)
  257. if(Joined[i] == true || IsADJ[i] == true)
  258. {
  259. PlayAudioStreamForPlayer(i, inputtext, 0, 0, 0, 50, 0);
  260. }
  261. }
  262. else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party being held at the moment ::.");
  263. }
  264. }
  265. }
  266. return 0;
  267. }
  268.  
  269. public OnPlayerEnterCheckpoint(playerid)
  270. {
  271. if(IsADJ[playerid] == false)
  272. {
  273. new string[128];
  274. Joined[playerid] = true;
  275. CurrentParticipants++;
  276. for(new i = 0; i < MAX_PLAYERS; i++)
  277. if(Joined[i] == true)
  278. {
  279. format(string, sizeof(string), "** %s has joined the party! there are now %d participants!", N(playerid), CurrentParticipants);
  280. SendClientMessage(i, COLOR_LIGHTBLUE, string);
  281. }
  282. }
  283. return 1;
  284. }
  285. // ======================================================================================================
  286. // NAME RELATED STOCKS, IGNORE IGNORE IGNORE IGNORE :D
  287. stock GetPlayerFirstName(playerid)
  288. {
  289. new NickName[MAX_PLAYER_NAME];
  290. GetPlayerName(playerid, NickName, MAX_PLAYER_NAME);
  291. strdel(NickName, strfind(NickName, "_"), strlen(NickName));
  292. return NickName;
  293. }
  294. stock GetPlayerLastName(playerid)
  295. {
  296. new namestring[2][MAX_PLAYER_NAME];
  297. new name[MAX_PLAYER_NAME];
  298. GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  299. split(name, namestring, '_');
  300. return namestring[1];
  301. }
  302. stock N(playerid)
  303. {
  304. new NA[32];
  305. format(NA, sizeof(NA), "%s %s", GetPlayerFirstName(playerid), GetPlayerLastName(playerid));
  306. return NA;
  307. }
  308. stock split(const strsrc[], strdest[][], delimiter)
  309. {
  310. new i, li;
  311. new aNum;
  312. new len;
  313. while(i <= strlen(strsrc)){
  314. if(strsrc[i]==delimiter || i==strlen(strsrc)){
  315. len = strmid(strdest[aNum], strsrc, li, i, 128);
  316. strdest[aNum][len] = 0;
  317. li = i+1;
  318. aNum++;
  319. }
  320. i++;
  321. }
  322. return 1;
  323. }
  324. stock IsPlayerInFrontVehicle(playerid,vehicleid,Float:radius,Float:vehiclelength)
  325. {
  326. new Float:x,Float:y,Float:z,Float:a;
  327. GetVehiclePos(vehicleid, x, y, z);
  328. GetPlayerFacingAngle(vehicleid, a);
  329. x += (vehiclelength* floatsin(-a, degrees));
  330. y += (vehiclelength* floatcos(-a, degrees));
  331. return IsPlayerInRangeOfPoint(playerid,radius,x,y,z);
  332. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement