Jump to content

[Cerere - tutorial] DJ, Stream


Blackyy.

Recommended Posts

Nume: Blackyy.

Nume tutorial: DJ - Stream

Descriere: Pai un admin de level 3+ sa poata folosi comanda /stream [link] si sa poata pune pe server muzica (adica tot server-ul sa auda muzica pusa de admin). Link-ul sa nu fie de pe youtube, ci un link in format .MP3 (de pe fisierulmeu de exemplu..).

Link to comment
Share on other sites

Poate nu e exact ceea ce iti doresti tu...dar seamana :D

/*
 _____________________________________________________________________________
|                                                                             |
|                                                                             |
|                                                                             |
|       $$$$$$       $$$$$$     $$$$$$     $$$$$$                             |
|       $    $       $          $    $     $    $                             |
|       $$$$$$       $   $$     $$$$$$     $$$$$$  					          |
|       $     $      $    $     $     $    $                   			      |
|       $      $     $$$$$$     $      $   $                     			  |
|                                                                             |
|					  New DJ Job, suitable for everyone                       |
|                Scratch made by SandieL, feel free to use it                 |
|              Credits free, don't be afraid to Rep+ ;D Enjoy!                |
|                                                                             |
|_____________________________________________________________________________|
                                                                              */

#include <a_samp>
#include <sscanf2>
#include <ZCMD>

#define FILTERSCRIPT
#define DIALOG_PARTY 1
#define DIALOG_MUSICNAME 2
#define DIALOG_MUSICURL 3
#define P_VEH 459 // Change 459 to whatever vehicle you want as the DJ Van
#define MinimumParticipants 5 // Change 5 to whatever minimum number of people you want
#if defined FILTERSCRIPT

#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_GREY 0xAFAFAFAA

new bool:IsADJ[MAX_PLAYERS] = false; // Is the player a DJ?
new bool:PartyStarted = false; // Is there a party going on already?
new bool:PartyPrepared = false;
new bool:Joined[MAX_PLAYERS] = false;
new Float:PartyX;
new Float:PartyY;
new Float:PartyZ;
new Admin[MAX_PLAYERS]; // This will be the admin variable in the system, you can change it if you want to.
new CurrentParticipants; // Current participants in the party!
new PartyVehicle;
new SongName[128];

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" DJ Job scratch made by SandieL");
	print("--------------------------------------\n");
	CurrentParticipants = 0;
	PartyStarted = false;
	PartyPrepared = false;
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main() {}

#endif

forward DJTimer(playerid);
public DJTimer(playerid)
{
	if(IsADJ[playerid] == true)
	{
	    new string[128];
	    IsADJ[playerid] = false;
	    PartyStarted = false;
	    PartyPrepared = false;
	    CurrentParticipants = 0;
	    format(string, sizeof(string), "** %s has been removed from being a DJ because the time has passed!", N(playerid));
	    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
	}
	return 1;
}

public OnPlayerConnect(playerid)
{
	// 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
	// I don't have a save system in this filterscript, so it doesn't really matter if I do it.
	return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
	Joined[playerid] = false;
	CurrentParticipants--;
	// Don't forget to remove his DJ privliges if he is a DJ! (IsADJ[playerid] = false)
	return 1;
}

CMD:assigndj(playerid, params[])
{
	new ID, time;
	if(!sscanf(params, "ui", ID, time)) // parameters
	{
		if(Admin[playerid] == 3) // Is the player that executed the command an administrator
		{
		    if(ID != INVALID_PLAYER_ID)
		    {
		        if(time < 6 || time > 0)
		        {
				    // Uncomment the line below to not be able to set yourself as DJ (has to be another person)
				    //if(playerid == id) return SendClientMessage(playerid, COLOR_GREY, ".:: You cannot make yourself a DJ! ::.");
				    for(new i = 0; i < MAX_PLAYERS; i++)
				    if(IsADJ[i] == false) // Is there any DJ online at the moment? (also checks if the ID inserted is a DJ aswell)
				    {
				        new string[128];
				        IsADJ[ID] = true;
				        format(string, sizeof(string), "%s has made %s a DeeJay in the server!", N(playerid), N(ID));
				        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
				        SetTimer("DJTimer", 3600000, 0);
				    }
				    else return SendClientMessage(playerid, COLOR_GREY, ".:: There already is a DJ online ::.");
				}
				else return SendClientMessage(playerid, COLOR_GREY, ".:: The DJ hours can't exceed 5 hours ::.");
			}
			else return SendClientMessage(playerid, COLOR_GREY, ".:: The player id you entered does not exist ::.");
		}
		else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
	}
	else return SendClientMessage(playerid, COLOR_GREY, ".:: USAGE: /assigndj [Playerid/PartOfName] [Hours] ::.");
	return 1;
}

CMD:prepareparty(playerid, params[])
{
	if(IsADJ[playerid] == true) // Is he a DJ?
	{
	    if(PartyStarted == false && PartyPrepared == false) // Is there a party going on?
	    {
	        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == P_VEH) // DJ Van
	        {
	            PartyVehicle = GetPlayerVehicleID(playerid);
	            PartyPrepared = true;
				CurrentParticipants = 0;
	            SendClientMessage(playerid, COLOR_LIGHTBLUE, "** The party is prepared, use /startparty to start it once there are 5 people!");
	            GetPlayerPos(playerid, Float:PartyX, Float:PartyY, Float:PartyZ);
	            for(new i = 0; i < MAX_PLAYERS; i++)
				if(playerid != i)
				{
				    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");
				}
	        }
	        else return SendClientMessage(playerid, COLOR_GREY, ".:: You need to be inside the DJ Van to use this feature ::.");
	    }
	    else return SendClientMessage(playerid, COLOR_GREY, ".:: There already is a party underway (Or a party is already prepared, use /startparty) ::.");
	}
	else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
	return 1;
}
CMD:startparty(playerid, params[])
{
	if(IsADJ[playerid] == true) // Is he a DJ?
	{
	    if(PartyStarted == false) // Is there a party going on?
	    {
	        if(PartyPrepared == true) // Is the party prepared?
	        {
				if(CurrentParticipants >= MinimumParticipants-1) // If there are the correct number of people to start this shit
				{
				    PartyStarted = true;
				    PartyPrepared = false;
				    SendClientMessageToAll(COLOR_LIGHTBLUE, "** 5 people have joined the party, and it is underway, get there fast!");
				}
				else return SendClientMessage(playerid, COLOR_GREY, ".:: You must wait for atleast 5 people to join first! ::.");
	        }
	        else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party prepared, use /prepareparty to prepare one!  ::.");
	    }
	    else return SendClientMessage(playerid, COLOR_GREY, ".:: There already is a party underway (Or a party is already prepared, use /startparty) ::.");
	}
	else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
	return 1;
}
CMD:play(playerid, params[])
{
	if(IsADJ[playerid] == true)
	{
	    if(PartyStarted == true)
	    {
			if(IsPlayerInFrontVehicle(playerid,PartyVehicle,3,-4) == 1)
			{
				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");
			}
			else return SendClientMessage(playerid, COLOR_GREY, ".:: You need to be behind the Party Van to use this feature ::.");
	    }
	    else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party being held at the moment ::.");
	}
	else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
	return 1;
}
CMD:endparty(playerid, params[])
{
    if(IsADJ[playerid] == true)
	{
	    if(PartyStarted == true || PartyPrepared == true)
	    {
	        new string[128];
			PartyStarted = false;
			PartyPrepared = false;
			CurrentParticipants = 0;
			format(string, sizeof(string), "** DeeJay %s has ended the party! Untill next time. **", N(playerid));
	    }
	    else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party being held at the moment ::.");
	}
	else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not allowed to use this command ::.");
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_PARTY:
        {
            if(response)
            {
                if(PartyPrepared == true || PartyStarted == true)
                {
                    if(Joined[playerid] == false)
                    {
                        SetPlayerCheckpoint(playerid, Float:PartyX, Float:PartyY, Float:PartyZ, 3);
                        SendClientMessage(playerid, COLOR_GREY, " (( Get to the checkpoint to join the party before it's over!");
                    }
                    else return SendClientMessage(playerid, COLOR_GREY, ".:: You already joined this party! ::.");
                }
                else return SendClientMessage(playerid, COLOR_GREY, ".:: There are no current parties being held at the moment ::.");
            }
        }
        case DIALOG_MUSICNAME:
        {
            if(response)
            {
                if(PartyPrepared == true || PartyStarted == true)
                {
					format(SongName, sizeof(SongName), "%s", inputtext);
                    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");
                }
                else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party being held at the moment ::.");
            }
        }
        case DIALOG_MUSICURL:
        {
            if(response)
            {
                if(PartyPrepared == true || PartyStarted == true)
                {
					new string[128];
					format(string, sizeof(string), "** %s has played the song '%s' **", N(playerid), SongName);
					for(new i = 0; i < MAX_PLAYERS; i++)
					if(Joined[i] == true || IsADJ[i] == true)
					{
					    PlayAudioStreamForPlayer(i, inputtext, 0, 0, 0, 50, 0);
					}
                }
                else return SendClientMessage(playerid, COLOR_GREY, ".:: There is no party being held at the moment ::.");
            }
        }
    }
    return 0;
}

public OnPlayerEnterCheckpoint(playerid)
{
	if(IsADJ[playerid] == false)
 	{
        new string[128];
	    Joined[playerid] = true;
	    CurrentParticipants++;
		for(new i = 0; i < MAX_PLAYERS; i++)
		if(Joined[i] == true)
		{
			format(string, sizeof(string), "** %s has joined the party! there are now %d participants!", N(playerid), CurrentParticipants);
			SendClientMessage(i, COLOR_LIGHTBLUE, string);
		}
	}
	return 1;
}
// ======================================================================================================
// NAME RELATED STOCKS, IGNORE IGNORE IGNORE IGNORE 
stock GetPlayerFirstName(playerid)
{
    new NickName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, NickName, MAX_PLAYER_NAME);
    strdel(NickName, strfind(NickName, "_"), strlen(NickName));
    return NickName;
}
stock GetPlayerLastName(playerid)
{
	new namestring[2][MAX_PLAYER_NAME];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	split(name, namestring, '_');
	return namestring[1];
}
stock N(playerid)
{
	new NA[32];
	format(NA, sizeof(NA), "%s %s", GetPlayerFirstName(playerid), GetPlayerLastName(playerid));
	return NA;
}
stock split(const strsrc[], strdest[][], delimiter)
{
	new i, li;
	new aNum;
	new len;
	while(i <= strlen(strsrc)){
	    if(strsrc[i]==delimiter || i==strlen(strsrc)){
	        len = strmid(strdest[aNum], strsrc, li, i, 128);
	        strdest[aNum][len] = 0;
	        li = i+1;
	        aNum++;
		}
		i++;
	}
	return 1;
}
stock IsPlayerInFrontVehicle(playerid,vehicleid,Float:radius,Float:vehiclelength)
{
  new Float:x,Float:y,Float:z,Float:a;
  GetVehiclePos(vehicleid, x, y, z);
  GetPlayerFacingAngle(vehicleid, a);
  x += (vehiclelength* floatsin(-a, degrees));
  y += (vehiclelength* floatcos(-a, degrees));
  return IsPlayerInRangeOfPoint(playerid,radius,x,y,z);
}

"Maxim respect pentru orice proiect

Nimeni nu poate sa va scape cand va execut direct"

Link to comment
Share on other sites

  • 3 months later...

Poti face ceva in genul

[pawn]

if (strcmp(cmdtext, "/radioall", true) ==0)

{

if (PlayerInfo[playerid][pAdmin] >= 1340)

        {

        PlayAudioStreamForAll(playerid, "Aici pui un radio care il vrei");

        SendClientMessageToAll(playerid, COLOR_RED,"Radio pornit");

        return 1;

}

[/pawn]

Link to comment
Share on other sites

Incearca asta:

[pawn] if(strcmp(cmd, "/musicforall", true) == 0)

{

    //tmp = strtok(cmdtext, idx);

new length = strlen(cmdtext);

while ((idx < length) && (cmdtext[idx] <= ' '))

{

idx++;

}

new offset = idx;

new link[182];

while ((idx < length) && ((idx - offset) < (sizeof(link) - 1)))

{

link[idx - offset] = cmdtext[idx];

idx++;

}

link[idx - offset] = EOS;

if(!strlen(link))

    {

        SendClientMessage(playerid, COLOR_GREY, "Foloseste: /musicforall [link-ul]");

        return 1;

}

if(PlayerData[playerid][pAdmin] >= 1338)

{

    foreach(Player, i)

    {

        PlayAudioStreamForPlayer(i, link);

        Listening = true;

}

}

return 1;

}[/pawn]

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.