03.06.2013, 19:44
Making a basic audio system!
Hi my name is xXitsgodzillaXx and I am going to show you how to make a basic audio system where you can find individual songs and get different radios.
Okay so we need to make sure with all of our includes and such so first we want to get zcmd so our commands will execute each function faster. Link for Zcmd: https://sampforum.blast.hk/showthread.php?tid=91354 And then you will need "a_http" which comes default when you download the server package if you still dont have it just redownload the package here: http://files.sa-mp.com/samp03x_svr_R1-2_win32.zip
Okay so lets start we must make sure that the include are being used in the script so we are going to put "#include <zcmd>" and "#include <a_http>"
So our script should look like this at the top so far.
Okay so once that is done we need to define the dialogs so let's do that. We will put "#define Music_dialog (insert any number in between 1 and 32767)
Okay so lets make our first command lets call it uhh... "/music"? yes?
So lets do this any where on the script. but make sure it's not under ANY callbacks or you will get errors.
Okay so lets type our command which will be this "CMD:music(playerid, params[]);" This here will execute all the functions when we type "/music" in game. Now lets add some functions like "ShowPlayerDialog". Now the command should look like this.
now hit "CTRL + F" and type "OnDialogResponse" and click "find next". should find it if not just type anywhere on the script
So lets start using the PlayAudioStreamForPlayer function. Looks like this
Now lets pick a song doesnt matter which one. Now in order to get a song we need to go to this website: www.dilandau.eu Type in a song in the search bar then listen to it just to make sure that its the right one that you want.
When you have found your song just right click the download button and click "copy link location" So im just going to pick any song.. lets go with "Higher" by creed. Now that we have our song lets paste the link in the "URL" params" Now the dialog Should look somthing like this.
"StopAudioStreamForPlayer" Is pretty self explanatory. and for the returns ALWAYS REMEMBER TO DO
"
return 1;
}
return 0;
}"
at the bottom of OnDialogResponse.
So now our filterscript Should look like this once you remove all of the other callbacks and stuff we dont need.
This is my first Tutorial so any feed back is appreciated. Please tell me how I did!
Hi my name is xXitsgodzillaXx and I am going to show you how to make a basic audio system where you can find individual songs and get different radios.
Okay so we need to make sure with all of our includes and such so first we want to get zcmd so our commands will execute each function faster. Link for Zcmd: https://sampforum.blast.hk/showthread.php?tid=91354 And then you will need "a_http" which comes default when you download the server package if you still dont have it just redownload the package here: http://files.sa-mp.com/samp03x_svr_R1-2_win32.zip
Okay so lets start we must make sure that the include are being used in the script so we are going to put "#include <zcmd>" and "#include <a_http>"
So our script should look like this at the top so far.
pawn Code:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#include <a_http>
#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
pawn Code:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#include <a_http>
#if defined FILTERSCRIPT
#define Music_dialog 8487
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
So lets do this any where on the script. but make sure it's not under ANY callbacks or you will get errors.
Okay so lets type our command which will be this "CMD:music(playerid, params[]);" This here will execute all the functions when we type "/music" in game. Now lets add some functions like "ShowPlayerDialog". Now the command should look like this.
pawn Code:
CMD:musiclist(playerid, params[])
{
ShowPlayerDialog(playerid, Music_dialog, DIALOG_STYLE_LIST, "Music", "Creed - Higher\nStopMusic", "Play", "Close");
return 1;
}
pawn Code:
public OnDialogResponse
{
if(dialogid == Music_dialog)
{
if(response)
{
if(listitem == 0)
{
PlayAudioStreamForPlayer(playerid, "");
}
}
pawn Code:
PlayAudioStreamForPlayer(playerid,(URL Goes here));
When you have found your song just right click the download button and click "copy link location" So im just going to pick any song.. lets go with "Higher" by creed. Now that we have our song lets paste the link in the "URL" params" Now the dialog Should look somthing like this.
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == Music_dialog)
{
if(response)
{
if(listitem == 0)
{
PlayAudioStreamForPlayer(playerid, "http://jweb.taconic.net/music/creed-my_own_prison.mp3");
}
if(listitem == 1)
{
StopAudioStreamForPlayer(playerid);
}
}
return 1;
}
return 0;
}
"
return 1;
}
return 0;
}"
at the bottom of OnDialogResponse.
So now our filterscript Should look like this once you remove all of the other callbacks and stuff we dont need.
pawn Code:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#include <a_http>
#if defined FILTERSCRIPT
#define Music_dialog 8487
#else
#endif
CMD:music(playerid, params[])
{
ShowPlayerDialog(playerid, Music_dialog, DIALOG_STYLE_LIST, "Music","Creed - Higher\nStop Music","Play","Close");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == Music_dialog)
{
if(response)
{
if(listitem == 0)
{
PlayAudioStreamForPlayer(playerid, "http://jweb.taconic.net/music/creed-my_own_prison.mp3");
}
if(listitem == 1)
{
StopAudioStreamForPlayer(playerid);
}
}
return 1;
}
return 0;
}