Edit to Boombox FS (Easy)
#3

Код:
/*
Boombox filterscript created by Soumi.
Copyright Soumi 2012.
Commands:
- /boombox : It will open a dialog where you can choose a radio station to play. After choosing the radio station,
it will create a boombox object and starts playing the radio station for the players in range of DISTANCE_RADIO.
- /radiostation : To switch to another radio station.
- /turnoff : To turn off the boombox.

P.S : - If a player leaves the boombox range, the audio stream will stop for him.
	  - If a player enters the boombox range, the audio stream will start playing for him.
*/

#define filterscript
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <streamer>

#define DISTANCE_RADIO 999.00

// Colors defines

#define GREY            0xCECECEFF
#define WHITE           0xFFFFFFFF
#define RED             0xAA3333AA
#define GOLD            0xB8860BAA
#define ACTION_COLOR 	0xC2A2DAAA
#define GREEN           0x33AA33AA
#define ORANGE          0xFF9900AA
#define GUARDS_RADIO	0x33CCFFAA
#define DOCTORS_RADIO   0xFFC0CBAA
#define YELLOW          0xFFFF00AA
#define BRONZE          0x800000AA
#define SILVER          0xF5F5F5FF

// Player Stats

enum PlayerInfo
{
	 BoomBoxObject,
	 Float: BoomBoxObjectX,
	 Float: BoomBoxObjectY,
	 Float: BoomBoxObjectZ,
	 BoomBoxStatus,
	 BoomBoxLink[512],
	 ListeningToBoomBox,

}
new PlayerStat[MAX_PLAYERS][PlayerInfo];

forward OneSecondPlayerCheck(playerid);

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Boombox filterscript by Soumi ");
	print("--------------------------------------\n");
	LoadGangs();
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n--------------------------------------");
	print(" Boombox filterscript by Soumi ");
	print("--------------------------------------\n");
}

#endif

public OnPlayerConnect(playerid)
{
    PlayerStat[playerid][BoomBoxStatus] = -1;
    PlayerStat[playerid][ListeningToBoomBox] = -1;
    SetTimerEx("OneSecondPlayerCheck", 1000, true, "d", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(PlayerStat[playerid][BoomBoxStatus] == playerid)
	{
        DestroyDynamicObject(PlayerStat[playerid][BoomBoxObject]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
	        if(IsPlayerInRangeOfPoint(i, DISTANCE_RADIO, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
            {
                StopAudioStreamForPlayer(i);
                PlayerStat[i][ListeningToBoomBox] = 0;
            }
         }
    }
    return 1;
}

public OneSecondPlayerCheck(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
		if(PlayerStat[i][BoomBoxStatus] == i && PlayerStat[playerid][ListeningToBoomBox] == -1)
		{
	        if(IsPlayerInRangeOfPoint(i, DISTANCE_RADIO, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
	        {
                PlayAudioStreamForPlayer(playerid, PlayerStat[i][BoomBoxLink], PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ], 10.0, 1);
                PlayerStat[playerid][ListeningToBoomBox] = i;
            }
        }
        if(PlayerStat[i][BoomBoxStatus] == i && PlayerStat[playerid][ListeningToBoomBox] == i)
		{
	        if(!IsPlayerInRangeOfPoint(i, DISTANCE_RADIO, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
	        {
                StopAudioStreamForPlayer(playerid);
                PlayerStat[playerid][ListeningToBoomBox] = -1;
            }
        }
    }
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 8888)
    {
        if(!response) return 1;
        else if(response)
        {
            switch(listitem)
        	{
				case 0:
				{
					if(PlayerStat[playerid][BoomBoxStatus] != playerid)
					{
					    GetPlayerPos(playerid, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]);
	                    PlayerStat[playerid][BoomBoxObject] = CreateDynamicObject(2103 ,PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ] -1,0.0000000,0.00000000,0.00000000);
	                    PlayerStat[playerid][BoomBoxStatus] = playerid;
                        format(PlayerStat[playerid][BoomBoxLink], 512, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=313797");
                        SendClientMessage(playerid, GREEN, "Boombox turned [ON].");
                        SendClientMessage(playerid, WHITE, "Use /radiostation to switch to another radio station!");
                    }
                    else if(PlayerStat[playerid][BoomBoxStatus] == playerid)
					{
                        format(PlayerStat[playerid][BoomBoxLink], 512, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=313797");
                        SendClientMessage(playerid, GREEN, "Radio station changed.");
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if(IsPlayerInRangeOfPoint(i, DISTANCE_RADIO, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
	                        {
                                PlayAudioStreamForPlayer(i, PlayerStat[i][BoomBoxLink], PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ], 10.0, 1);
                            }
                        }
                    }
				}
				case 1:
				{
					if(PlayerStat[playerid][BoomBoxStatus] != playerid)
					{
					    GetPlayerPos(playerid, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]);
	                    PlayerStat[playerid][BoomBoxObject] = CreateDynamicObject(2103 ,PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ] -1,0.0000000,0.00000000,0.00000000);
	                    PlayerStat[playerid][BoomBoxStatus] = playerid;
                        format(PlayerStat[playerid][BoomBoxLink], 512, "http://www.sky.fm/mp3/tophits.pls");
                        SendClientMessage(playerid, GREEN, "Boombox turned [ON].");
                        SendClientMessage(playerid, WHITE, "Use /radiostation to switch to another radio station!");
                    }
                    else if(PlayerStat[playerid][BoomBoxStatus] == playerid)
					{
                        format(PlayerStat[playerid][BoomBoxLink], 512, "http://www.sky.fm/mp3/tophits.pls");
                        SendClientMessage(playerid, GREEN, "Radio station changed.");
                        for(new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if(IsPlayerInRangeOfPoint(i, DISTANCE_RADIO, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
	                        {
                                PlayAudioStreamForPlayer(i, PlayerStat[i][BoomBoxLink], PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ], 10.0, 1);
                            }
                        }
                    }
				}
			}
        }
    }
    return 1;
}


//-----------------------------------------------------------------------[Commands]------------------------------------------------------------------------------
COMMAND:boombox(playerid, params[])
{
	if(PlayerStat[playerid][BoomBoxStatus] == playerid) return SendClientMessage(playerid, GREY, "You can't use this command now.");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, GREY, "You can't use this command now.");
	ShowPlayerDialog(playerid, 8888, DIALOG_STYLE_LIST, "Radio Stations:","SomaFM\nSkyFM","Play","Quit");
    return 1;
}

COMMAND:radiostation(playerid, params[])
{
	if(PlayerStat[playerid][BoomBoxStatus] == -1) return SendClientMessage(playerid, GREY, "You can't use this command now.");
	ShowPlayerDialog(playerid, 8888, DIALOG_STYLE_LIST, "Radio Stations:","SomaFM\nWWOZ","Play","Quit");
    return 1;
}

COMMAND:turnoff(playerid, params[])
{
	if(PlayerStat[playerid][BoomBoxStatus] == -1) return SendClientMessage(playerid, GREY, "You can't use this command now.");
	SendClientMessage(playerid, RED, "Boombox turned [OFF].");
	DestroyDynamicObject(PlayerStat[playerid][BoomBoxObject]);
    StopAudioStreamForPlayer(playerid);
    PlayerStat[playerid][BoomBoxStatus] = -1;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
	    if(IsPlayerInRangeOfPoint(i, DISTANCE_RADIO, PlayerStat[playerid][BoomBoxObjectX], PlayerStat[playerid][BoomBoxObjectY], PlayerStat[playerid][BoomBoxObjectZ]))
	    {
            StopAudioStreamForPlayer(i);
            PlayerStat[i][ListeningToBoomBox] = -1;
        }
    }
    return 1;
}
Here modified the script for you, edit DISTANCE_RADIO on the top of your script to set the radios area people can hear it. Default was "20.0."
Reply


Messages In This Thread
Edit to Boombox FS (Easy) - by jakejohnsonusa - 10.11.2012, 01:27
Re: Edit to Boombox FS (Easy) - by jakejohnsonusa - 10.11.2012, 12:55
Re: Edit to Boombox FS (Easy) - by Guest3598475934857938411 - 10.11.2012, 13:19
Re: Edit to Boombox FS (Easy) - by jakejohnsonusa - 10.11.2012, 13:31

Forum Jump:


Users browsing this thread: 2 Guest(s)