03.09.2018, 18:32
BOOMBOX SYSTEM by David Sfeir
Version 1.1
Version 1.1
Hey pals,
Today i\'m gonna release my Boombox system, hope you like it.
Introduction
It\'s a boombox system that players are able to play music even inside an interior or exterior.
Boombox had a specific music distance/range. You can stop/play the music at any time you wish.
Commands
- /boombox - to place/pickup the boombox (One boombox can be placed).
- /stopmusic - to stop the current music
- /playmusic - to play the current music
Download
Code:
/* BBBBBBB OOOOOOOO OOOOOOOO MM MM BBBBBBB OOOOOOOO X X B B O O O O M M M M B B O O X X B B O O O O M M M M B B O O X X BBBBBB O O O O M M M BBBBBB O O XX B B O O O O M M B B O O XX B B O O O O M M B B O O X X BBBBBBB OOOOOOOO OOOOOOOO M M BBBBBBB OOOOOOOO X X BOOMBOX SYSTEM BY DAVID SFEIR BOOMBOX V1.1 */ #include <a_samp> #include <zcmd> #include <YSI\y_timers> #include <sscanf2> #include <streamer> #include <foreach> #include <audio> #include <a_zones> #include <zones> #define FILTERSCRIPT #define COLOR_PURPLE 0xC2A2DAAA new BBPlaced[MAX_PLAYERS]; new ABBPlaced[MAX_PLAYERS]; new MusicsOn[MAX_PLAYERS]; new Musics[MAX_PLAYERS]; new test[MAX_PLAYERS]; new Float:Pos[4]; enum pInfo { pMusic, pRadioID, pRadioURL, }; new PlayerInfo[MAX_PLAYERS+1][pInfo]; public OnFilterScriptInit() { print(" --------------------------------------"); print(" Boombox Filterscript by David Sfeir V1.1"); print("-------------------------------------- "); return 1; } public OnFilterScriptExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); return 1; } public OnPlayerConnect(playerid) { return 1; } public OnPlayerDisconnect(playerid, reason) { return 1; } public OnPlayerSpawn(playerid) { return 1; } public OnPlayerDeath(playerid, killerid, reason) { return 1; } public OnVehicleSpawn(vehicleid) { return 1; } public OnVehicleDeath(vehicleid, killerid) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/mycommand", cmdtext, true, 10) == 0) { // Do something here return 1; } return 0; } stock RadioMusicID(playerid) { if(PlayerInfo[playerid][pRadioID] == 1) { PlayAudioStreamForPlayer(playerid, "http://listen.livestreamingservice.com/181-power_128k.mp3",Pos[0], Pos[1], Pos[2], PlayerInfo[playerid][pMusic], 1); } if(PlayerInfo[playerid][pRadioID] == 2) { PlayAudioStreamForPlayer(playerid, "http://listen.livestreamingservice.com/181-uktop40_128k.mp3",Pos[0], Pos[1], Pos[2], PlayerInfo[playerid][pMusic], 1); } if(PlayerInfo[playerid][pRadioID] == 3) { PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1563092",Pos[0], Pos[1], Pos[2], PlayerInfo[playerid][pMusic], 1); } if(PlayerInfo[playerid][pRadioID] == 4) { PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=630803",Pos[0], Pos[1], Pos[2], PlayerInfo[playerid][pMusic], 1); } if(PlayerInfo[playerid][pRadioID] == 5) { PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=99217527",Pos[0], Pos[1], Pos[2], PlayerInfo[playerid][pMusic], 1); } if(PlayerInfo[playerid][pRadioID] == 6) { PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1349680",Pos[0], Pos[1], Pos[2], PlayerInfo[playerid][pMusic], 1); } if(PlayerInfo[playerid][pRadioID] == 7) { PlayAudioStreamForPlayer(playerid, "URL",Pos[0], Pos[1], Pos[2], PlayerInfo[playerid][pMusic], 1); } if(PlayerInfo[playerid][pRadioID] == 8) { PlayAudioStreamForPlayer(playerid, "URL",Pos[0], Pos[1], Pos[2], PlayerInfo[playerid][pMusic], 1); } } stock StopAudioEx(playerid) { StopAudioStreamForPlayer(playerid); } CMD:stopmusic(playerid) { if(Musics[playerid] == 0) { SendClientMessage(playerid, -1, "Your music is already off!"); return 1; } StopAudioEx(playerid); Musics[playerid] = 0; return 1; } CMD:playmusic(playerid) { if(BBPlaced[playerid] == 1) { if(Musics[playerid] == 1) { SendClientMessage(playerid, -1, "Your music is already on!"); return 1; } if(IsPlayerInRangeOfPoint(playerid, PlayerInfo[playerid][pMusic], Pos[0], Pos[1], Pos[2])) { StopAudioStreamForPlayer(playerid); RadioMusicID(playerid); Musics[playerid] = 1; } else { SendClientMessage(playerid, -1,"You\'re not near the boombox!"); } } else { SendClientMessage(playerid, -1,"No Boombox placed here!"); } return 1; } CMD:boombox(playerid, params[]) { new Distances = strval(params); new RadioID[100]; if(sscanf(params, "dd", Distances, RadioID)) { SendClientMessage(playerid, -1, "USAGE: /boombox [distance] [RadioID] (Type it again to remove music)"); SendClientMessage(playerid, -1, "{FFFFFF}[1] FM Power 181 (Top 40) {0000FF} - {FFFFAA} [2] U.K (Top 40) {0000FF} - {FFFFFF} [3] Power Hitz {0000FF} - {FFFFAA} [4] 100 Top Hits"); SendClientMessage(playerid, -1, "{FFFFAA}[5] 113-FM Power {0000FF} - {FFFFFF} [6] Nashville FM (Country) {0000FF} - {FFFFAA} [7] Name {0000FF} - {FFFFFF} [8] Name"); return 1; } if(Distances < 5 || Distances > 200) { SendClientMessage(playerid, -1,"Can\'t go below 5 and above 200!"); return 1; } for(new i = 0; i < MAX_PLAYERS; i++) { if(MusicsOn[i] == 0) { new string[256]; new zone[MAX_ZONE_NAME]; GetPlayer3DZone(playerid, zone, sizeof(zone)); format(string, sizeof(string), "ANNOUNCEMENT: Party has just started at %s!",zone); SendClientMessage(i,-1,string); } if(IsPlayerConnected(i)) { if(ABBPlaced[i] == 1) { ABBPlaced[i] = 0; DestroyDynamicObject(test[i]); DestroyDynamic3DTextLabel(Text3D:GetPVarInt(i, "pDynamicBBLabel")); DeletePVar(i, "pDynamicBBLabel"); DeletePVar(i, "pDynamicBB"); DestroyDynamicObject(GetPVarInt(i, "pDynamicBB")); DeletePVar(playerid, "pDynamicBBArea"); MusicsOn[i] = 1; Musics[i] = 0; BBPlaced[i] = 0; StopAudioEx(i); Streamer_Update(i); } else { GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]); if(IsPlayerInRangeOfPoint(playerid, strval(params), Pos[0], Pos[1], Pos[2])) { switch(RadioID[0]) { case 1: { PlayerInfo[i][pRadioID] = 1; } case 2: { PlayerInfo[i][pRadioID] = 2; } case 3: { PlayerInfo[i][pRadioID] = 3; } case 4: { PlayerInfo[i][pRadioID] = 4; } case 5: { PlayerInfo[i][pRadioID] = 5; } case 6: { PlayerInfo[i][pRadioID] = 6; } case 7: { PlayerInfo[i][pRadioID] = 7; } case 8: { PlayerInfo[i][pRadioID] = 8; } default: return SendClientMessage(playerid, -1, "Invalid station specified."); } MusicsOn[i] = 0; Musics[i] = 1; BBPlaced[i] = 1; ABBPlaced[i] = 1; PlayerInfo[i][pMusic] = strval(params); StopAudioStreamForPlayer(i); ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In", 4.0, 0, 0, 0, 0, 0, 1); Pos[0] += (2 * floatsin(-Pos[3], degrees)); Pos[1] += (2 * floatcos(-Pos[3], degrees)); Pos[2] -= 1.0; SetTimerEx("Music", 2000, 1, "i", i); DestroyDynamicObject(GetPVarInt(i, "pDynamicBB")); DeletePVar(i, "pDynamicBB"); SetPVarInt(playerid, "pDynamicBB", 1); Streamer_Update(i); test[i] = CreateDynamicObject(2226, Pos[0], Pos[1], Pos[2], 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)); } } } } return 1; } forward Music(playerid); public Music(playerid) { new string[256]; for(new i = 0; i < MAX_PLAYERS; i++) { if(MusicsOn[i] == 0 && IsPlayerInRangeOfPoint(i, PlayerInfo[playerid][pMusic], Pos[0], Pos[1], Pos[2])) { MusicsOn[i] = 1; StopAudioStreamForPlayer(i); RadioMusicID(i); if(PlayerInfo[playerid][pRadioID] == 1) { format(string, sizeof(string), "{00FF00}Music:{FFFFFF} FM Power 181 (Top 40) {FF0000}/stopmusic {FFFFFF},{FF0000} /playmusic{FFFFFF}"); SetPVarInt(i, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, -1, Pos[0], Pos[1], Pos[2], 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid))); } if(PlayerInfo[playerid][pRadioID] == 2) { format(string, sizeof(string), "{00FF00}Music:{FFFFFF} U.K (Top 40) {FF0000}/stopmusic {FFFFFF},{FF0000} /playmusic{FFFFFF}"); SetPVarInt(i, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, -1, Pos[0], Pos[1], Pos[2], 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid))); } if(PlayerInfo[playerid][pRadioID] == 3) { format(string, sizeof(string), "{00FF00}Music:{FFFFFF} Power Hitz {FF0000}/stopmusic {FFFFFF},{FF0000} /playmusic{FFFFFF}"); SetPVarInt(i, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, -1, Pos[0], Pos[1], Pos[2], 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid))); } if(PlayerInfo[playerid][pRadioID] == 4) { format(string, sizeof(string), "{00FF00}Music:{FFFFFF} 100 Top Hits {FF0000}/stopmusic {FFFFFF},{FF0000} /playmusic{FFFFFF}"); SetPVarInt(i, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, -1, Pos[0], Pos[1], Pos[2], 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid))); } if(PlayerInfo[playerid][pRadioID] == 5) { format(string, sizeof(string), "{00FF00}Music:{FFFFFF} 113-FM Power {FF0000}/stopmusic {FFFFFF},{FF0000} /playmusic{FFFFFF}"); SetPVarInt(i, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, -1, Pos[0], Pos[1], Pos[2], 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid))); } if(PlayerInfo[playerid][pRadioID] == 6) { format(string, sizeof(string), "{00FF00}Music:{FFFFFF} Nashville FM (Country) {FF0000}/stopmusic {FFFFFF},{FF0000} /playmusic{FFFFFF}"); SetPVarInt(i, "pDynamicBBLabel", _:CreateDynamic3DTextLabel(string, -1, Pos[0], Pos[1], Pos[2], 5.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid))); } if(PlayerInfo[playerid][pRadioID] == 7) { //PUT URS } if(PlayerInfo[playerid][pRadioID] == 8) { //PUT URS } } } return 1; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { return 1; } public OnPlayerEnterCheckpoint(playerid) { return 1; } public OnPlayerLeaveCheckpoint(playerid) { return 1; } public OnPlayerEnterRaceCheckpoint(playerid) { return 1; } public OnPlayerLeaveRaceCheckpoint(playerid) { return 1; } public OnRconCommand(cmd[]) { return 1; } public OnPlayerRequestSpawn(playerid) { return 1; } public OnObjectMoved(objectid) { return 1; } public OnPlayerObjectMoved(playerid, objectid) { return 1; } public OnPlayerPickUpPickup(playerid, pickupid) { return 1; } public OnVehicleMod(playerid, vehicleid, componentid) { return 1; } public OnVehiclePaintjob(playerid, vehicleid, paintjobid) { return 1; } public OnVehicleRespray(playerid, vehicleid, color1, color2) { return 1; } public OnPlayerSelectedMenuRow(playerid, row) { return 1; } public OnPlayerExitedMenu(playerid) { return 1; } public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) { return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { return 1; } public OnRconLoginAttempt(ip[], password[], success) { return 1; } public OnPlayerUpdate(playerid) { return 1; } public OnPlayerStreamIn(playerid, forplayerid) { return 1; } public OnPlayerStreamOut(playerid, forplayerid) { return 1; } public OnVehicleStreamIn(vehicleid, forplayerid) { return 1; } public OnVehicleStreamOut(vehicleid, forplayerid) { return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { return 1; } public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; }