[Tutorial] How To Stream Music Of Your Own Choice For Players At Your Server!
#1

Audio Streaming

This Is My First Tutorial!
Everyone may give their Feedback No Matter How Bad it is !

First Of All You Need to put this at the Top Of your FilterScript and/or GameMode Script

pawn Код:
#include <zcmd>
#include <foreach>
You Can get these two Includes From Here:

zcmd - Credits To ZeeX
foreach - Credits To ******

Now,

Coming to part of the command that would be used to play audio for all players,

Its a very Simple Command but useful enough, you may write your own command or you may use the following:

pawn Код:
CMD:playmusic(playerid, params[])
{
    foreach(Player, i)
    {
                if (PlayerInfo[playerid][Level] >= 4)
                {
                    if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /playmusic [Link]");
                    PlayAudioStreamForPlayer(i, params);
        }
        }
    return 1;
}
Note:

You might Have to Change This:

pawn Код:
if (PlayerInfo[playerid][Level] >= 4)
^This Must Be according to your own GM/FS!

Its the very basic Command for Streaming Music.

Now,

Since we Know what command we can use to stream audio for everyone and getting excited we would just grab any link from the internet and use it, but DING!

Here's where the problem might occur,
Not just any link might work with this command plus for music to play you need the direct song link,

So,

To make it work you can get the song link from

Here

You Can Search For any Song of any genre and you would hopefully find it there!
When you search a list of URL's appear there you may copy any one of them and paste it ingame, Voila!


Note: This Tutorial has been made to Help New Scripters Others may also Benefit From it!
I Made This Tutorial because when I was a newbie I couldnt find anything which explained that! Plus, I didnt find any other tutorial similar to this one!

I Hope People Like This!
Reply
#2

....
Reply
#3

This is what I was looking for
Now I could finally move on to create my own custom DJ filterscript.
Reply
#4

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>
#include <foreach>

#define COLOR_WHITE 0xFFFFFFAA

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    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;
}

CMD:playmusic(playerid, params[])
{
    foreach(Player, i)
    {
                if (PlayerInfo[playerid][Level] >= 1)
                {
                    if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /playmusic [Link]");
                    PlayAudioStreamForPlayer(i, params);
        }
       
        }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

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;
}
Getting these errors

Код:
error 017: undefined symbol "PlayerInfo"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Reply
#5

You should move everything that doesn't have to be looped out of the loop. In this case, the only thing that needs to be looped is PlayAudioStream. The rest of it can easily appear beforehand.

PS: Don't type random words with a capital letter. It's terribly annoying to read.
Reply
#6

Quote:
Originally Posted by Ryan_Bowe
Посмотреть сообщение
There are already so many of these tutorials out there, but either way Rep +.
Thanks! But didnt find any when i was searching for it a long time ago....plus before making this tutorial i double checked to find if anybody has made some tut like this...but didnt find one.

Quote:
Originally Posted by Inspiron
Посмотреть сообщение
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>
#include <foreach>

#define COLOR_WHITE 0xFFFFFFAA

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    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;
}

CMD:playmusic(playerid, params[])
{
    foreach(Player, i)
    {
                if (PlayerInfo[playerid][Level] >= 1)
                {
                    if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /playmusic [Link]");
                    PlayAudioStreamForPlayer(i, params);
        }
       
        }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

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;
}
Getting these errors

Код:
error 017: undefined symbol "PlayerInfo"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Quote:
Originally Posted by Vege
Посмотреть сообщение
Note:

You might Have to Change This:

pawn Код:
if (PlayerInfo[playerid][Level] >= 4)
^This Must Be according to your own GM/FS!

Inspiron did you even read this part?
I made this command to be only controlled by admins that is actually the admin level i chose for my admins to stream music which is Level 4.
You would have to change the above mentioned part according to your own admin system. For Example there is ladmin and LuxAdmin etc. etc. otherwise anybody can use that command. the part above mentioned must be changed according to your own admin system or according to any Admin FS you're using, for me i have made my own admin system which i'll be releasing soon So that is why those errors are occuring...you need an Admin system.
If you're using an admin FS you may want to edit it and put this command in it.

Quote:
Originally Posted by Vince
Посмотреть сообщение
You should move everything that doesn't have to be looped out of the loop. In this case, the only thing that needs to be looped is PlayAudioStream. The rest of it can easily appear beforehand.

PS: Don't type random words with a capital letter. It's terribly annoying to read.
Sorry :P A bad habit many people pointed this out before...tryin' to improve myself
Reply
#7

ok work thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)