Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define WEBSITE_URL "127.0.0.1"
- #define DIALOG_MUSICPLAYER (2205)
- #include <a_samp>
- #include <a_http>
- #include <sscanf2>
- forward MusicResponse(index, response_code, data[]);
- public OnFilterScriptInit()
- {
- print("Music player loaded");
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/musicplayer", true))
- {
- ShowPlayerDialog(playerid, DIALOG_MUSICPLAYER, DIALOG_STYLE_INPUT, "Music Player", "Please enter url\nCurrent support : soundclound ( only single song, not playlist )", "Listen", "Cancel");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_MUSICPLAYER)
- {
- if(response)
- {
- new str[255];
- format(str, sizeof str, "%s/getmusic.php?url=%s", WEBSITE_URL, inputtext);
- printf(str);
- HTTP(playerid, HTTP_GET, str, "", "MusicResponse");
- }
- }
- return 1;
- }
- public MusicResponse(index, response_code, data[])
- {
- if(response_code == 200) //Did the request succeed?
- {
- new result[4][128], str[128];
- printf("data : %s", data);
- if(sscanf(data, "p<,>s[32]s[32]s[32]s[32]", result[0], result[1], result[2], result[3])) return SendClientMessage(index, -1, "Something wrong ");
- format(str, sizeof str, "Current Play: %s - Uploader: %s - Genre: %s", result[0], result[1], result[2]);
- SendClientMessage(index, -1, str);
- PlayAudioStreamForPlayer(index, result[3]);
- }
- else
- {
- SendClientMessage(index, -1, "Website down !");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement