Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <YSI_Coding\y_hooks>
- static stock const urls[][] = {
- "",
- "https://s2.radio.co/s2b2b68744/listen",
- "https://streams.ilovemusic.de/iloveradio1.mp3",
- "https://streams.ilovemusic.de/iloveradio2.mp3",
- "https://streams.ilovemusic.de/iloveradio21.mp3",
- "http://streams.ilovemusic.de/iloveradio5.mp3",
- "http://blackbeats.fm/listen.m3u",
- "http://server1.chilltrax.com:9000/listen.pls",
- "http://stream.radioparadise.com/mp3-320",
- "http://listener3.mp3.tb-group.fm/ht.mp3",
- "http://listener1.mp3.tb-group.fm/hb.mp3",
- "http://listener2.mp3.tb-group.fm/trb.mp3",
- "http://listener2.mp3.tb-group.fm/ct.mp3",
- "http://listener3.mp3.tb-group.fm/clt.mp3",
- "http://listener1.mp3.tb-group.fm/tb.mp3",
- "http://listener3.mp3.tb-group.fm/tt.mp3",
- "https://www.surfmusik.de/m3u/1-fm-reggae-trade,16149.m3u",
- "http://cdn.nrjaudio.fm/adwz1/de/33041/mp3_128.mp3",
- "https://f5-pa6.nrjaudio.fm/de/56252/mp3_128.mp3?cdn_path=adswizz_lbs12&adws_out_b2&access_token=1893924e77484d839ad401fb79d794a9"
- },
- names[][] = {
- "Custom URL",
- "Badradio.nz",
- "iLoveRadio",
- "iLoveDance",
- "iLoveHardstyle",
- "iLoveMashup",
- "BlackBeats.FM",
- "Chilltrax",
- "Radio Paradise",
- "HouseTime.FM",
- "HardBase.FM",
- "TranceBase.FM",
- "CoreTime.FM",
- "ClubTime.FM",
- "TechnoBase.FM",
- "TeaTime",
- "Reggae",
- "Energy RAP US"
- };
- CMD:boombox(playerid, params[])
- {
- if(!pInfo[playerid][pVip]) return NO_VIP;
- if(GetPlayerVirtualWorld(playerid) >= 50) return NO_ARENA;
- if(pInfo[playerid][pJail]) return SendClientMessage(playerid,rot,!"* You can not use this command, because you are in jail!");
- if(GetPlayerVirtualWorld(playerid) != 0) return SendClientMessage(playerid,rot,!"* You can only use this command outside!");
- if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid,rot,!"* You must be on foot to do this.");
- if(GetPVarType(playerid, "pBoomBox")) return SendClientMessage(playerid,rot,!"* You already have a boombox out, use /destroyboombox.");
- foreach(new i : Player)
- {
- if(GetPVarType(i, "pBoomBox"))
- {
- if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "pBoomBoxX"), GetPVarFloat(i, "pBoomBoxY"), GetPVarFloat(i, "pBoomBoxZ")))
- {
- SendClientMessage(playerid,rot,!"* You are in range of another boombox, you can't place one here!");
- return 1;
- }
- }
- }
- new Float:x, Float:y, Float:z, Float:a;
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, a);
- ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1);
- x += (2 * floatsin(-a, degrees));
- y += (2 * floatcos(-a, degrees));
- z -= 1.0;
- DestroyBoombox(playerid);
- SetPVarInt(playerid, "pBoomBox", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, a, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
- SetPVarFloat(playerid, "pBoomBoxX", x); SetPVarFloat(playerid, "pBoomBoxY", y); SetPVarFloat(playerid, "pBoomBoxZ", z);
- new string[255];
- format(string, sizeof(string), "%s's boombox\n/setboombox or\n/destroyboombox", GetPlayerNameEx(playerid));
- SetPVarInt(playerid, "pBoomBoxLabel", _:CreateDynamic3DTextLabel(string, yellow, x, y, z+0.6, 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
- SetPVarInt(playerid, "pBoomBoxArea", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
- SetPVarInt(playerid, "pBoomBoxInt", GetPlayerInterior(playerid));
- SetPVarInt(playerid, "pBoomBoxVW", GetPlayerVirtualWorld(playerid));
- Streamer_SetIntData(STREAMER_TYPE_AREA , GetPVarInt(playerid, "pBoomBoxArea"), E_STREAMER_EXTRA_ID, playerid);
- SendClientMessage(playerid, grey, "* You have placed an boombox!");
- ShowBoomboxMenu(playerid);
- return 1;
- }
- CMD:destroyboombox(playerid, params[])
- {
- if(!GetPVarType(playerid, "pBoomBox")) return SendClientMessage(playerid,rot,!"* You dont have a boombox out, to place one use /boombox.");
- if(!IsPlayerInDynamicArea(playerid, GetPVarInt(playerid, "pBoomBoxArea"), 1)) return SendClientMessage(playerid,rot,!"* You must be near your boombox.");
- DestroyBoombox(playerid);
- return 1;
- }
- CMD:setboombox(playerid, params[])
- {
- if(!pInfo[playerid][pVip]) return NO_VIP;
- if(!GetPVarType(playerid, "pBoomBox")) return SendClientMessage(playerid,rot,!"* You dont have a boombox out, to place one use /boombox.");
- if(!IsPlayerInDynamicArea(playerid, GetPVarInt(playerid, "pBoomBoxArea"), 1)) return SendClientMessage(playerid,rot,!"* You must be near your boombox.");
- ShowBoomboxMenu(playerid);
- return 1;
- }
- DestroyBoombox(playerid)
- {
- if(GetPVarType(playerid, "pBoomBox"))
- {
- foreach(new i : Player)
- {
- if(IsPlayerInRangeOfPoint(i, 30.0, GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ")) && GetPVarInt(i, "pBoomBoxListeningTo") == playerid)
- {
- StopAudioStreamForPlayer(i);
- DeletePVar(i, "pBoomBoxListeningTo");
- }
- }
- if(IsValidDynamicObject(GetPVarInt(playerid, "pBoomBox"))) DestroyDynamicObject(GetPVarInt(playerid, "pBoomBox")), DeletePVar(playerid, "pBoomBox");
- if(IsValidDynamic3DTextLabel(Text3D:GetPVarInt(playerid, "pBoomBoxLabel"))) DestroyDynamic3DTextLabel(Text3D:GetPVarInt(playerid, "pBoomBoxLabel")), DeletePVar(playerid, "pBoomBoxLabel");
- if(IsValidDynamicArea(GetPVarInt(playerid, "pBoomBoxArea"))) DestroyDynamicArea(GetPVarInt(playerid, "pBoomBoxArea")), DeletePVar(playerid, "pBoomBoxArea");
- DeletePVar(playerid, "pBoomBoxX");
- DeletePVar(playerid, "pBoomBoxY");
- DeletePVar(playerid, "pBoomBoxZ");
- DeletePVar(playerid, "pBoomBoxInt");
- DeletePVar(playerid, "pBoomBoxVW");
- DeletePVar(playerid, "pBoomBoxStation");
- DeletePVar(playerid, "pBoomBoxDestructionTimer");
- }
- return 1;
- }
- hook OnPlayerEnterDynArea(playerid, areaid)
- {
- if(IsPlayerNPC(playerid)) return 1;
- new boomboxOwner = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
- if(boomboxOwner == playerid && GetPVarInt(playerid, "pBoomBoxDestructionTimer"))
- {
- KillTimer(GetPVarInt(playerid, "pBoomBoxDestructionTimer"));
- DeletePVar(playerid, "pBoomBoxDestructionTimer");
- }
- if(IsPlayerConnected(boomboxOwner) && GetPVarType(boomboxOwner, "pBoomBox") && !GetPVarType(playerid, "radio"))
- {
- new url[300];
- GetPVarString(boomboxOwner, "pBoomBoxStation", url, sizeof url);
- PlayAudioStreamForPlayer(playerid, url, GetPVarFloat(boomboxOwner, "pBoomBoxX"), GetPVarFloat(boomboxOwner, "pBoomBoxY"), GetPVarFloat(boomboxOwner, "pBoomBoxZ"), 30.0, 1);
- SetPVarInt(playerid, "pBoomBoxListeningTo", boomboxOwner);
- }
- return 1;
- }
- hook OnPlayerLeaveDynArea(playerid, areaid)
- {
- if(IsPlayerNPC(playerid)) return 1;
- new boomboxOwner = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
- if(IsPlayerConnected(boomboxOwner) && GetPVarType(boomboxOwner, "pBoomBox") && GetPVarInt(playerid, "pBoomBoxListeningTo") == boomboxOwner)
- {
- StopAudioStreamForPlayer(playerid);
- DeletePVar(playerid, "pBoomBoxListeningTo");
- if(boomboxOwner == playerid)
- {
- new timerid = SetTimerEx(DestroyBoombox, 10000, false, playerid);
- SetPVarInt(playerid, "pBoomBoxDestructionTimer", timerid);
- SendClientMessage(playerid, grey, "* You are far from your boombox, in 10 seconds it disappears if you don't come back close!");
- }
- return 1;
- }
- hook OnPlayerDisconnect(playerid, reason)
- {
- if(IsPlayerNPC(playerid)) return 1;
- DestroyBoombox(playerid);
- return 1;
- }
- stock ShowBoomboxMenu(playerid)
- {
- inline BoomboxMenu(pid, did, response, listitem, string:inputtext[])
- {
- #pragma unused pid, did, listitem, inputtext
- if(response)
- {
- if(listitem == 0) return ShowBoomboxCustomUrlMenu(playerid);
- foreach(new i : Player)
- {
- if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")) && !GetPVarType(i, "radio"))
- {
- SetPVarInt(i, "pBoomBoxListeningTo", playerid);
- PlayAudioStreamForPlayer(i, urls[listitem], GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
- }
- }
- SetPVarString(playerid, "pBoomBoxStation", urls[listitem]);
- }
- }
- new string[sizeof(names)*12 + 24];
- for(new i; i<sizeof(names); i++) format(string,sizeof(string),"%s%s\n",string,names[i]);
- Dialog_ShowCallback(playerid, using inline BoomboxMenu, DIALOG_STYLE_LIST, DC"Boombox | Play Music", string, "Select", "Cancel");
- return 1;
- }
- stock ShowBoomboxCustomUrlMenu(playerid)
- {
- inline CustomBoomboxUrlMenu(pid, did, response, listitem, string:inputtext[])
- {
- if(response)
- {
- #pragma unused pid, did, listitem, inputtext
- foreach(new i : Player)
- {
- if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "pBoomBoxArea")))
- {
- SetPVarInt(i, "pBoomBoxListeningTo", playerid);
- PlayAudioStreamForPlayer(i, inputtext, GetPVarFloat(playerid, "pBoomBoxX"), GetPVarFloat(playerid, "pBoomBoxY"), GetPVarFloat(playerid, "pBoomBoxZ"), 30.0, 1);
- }
- }
- SetPVarString(playerid, "pBoomBoxStation", inputtext);
- }
- }
- Dialog_ShowCallback(playerid, using inline CustomBoomboxUrlMenu, DIALOG_STYLE_INPUT, DC"Boombox | Play From URL", "Please Enter the URL link below.\nIt is recommended the link is live streamed for continuous playback.", "Enter", "Cancel");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment