Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Stream Radio Script v1.03
- * Mit Kopfhörer Weiß(ein/ausschaltbar)
- * von Piet_Meier
- */
- //Includes
- #include <a_samp>
- #include <dini>
- //Defines
- #define ECMD2(%0,%1) if(!strcmp(%0,cmdtext,true)||!strcmp(%1,cmdtext,true))
- #define DIALOG_MUSIC 32666
- #define HEAD_PHONES_SLOT 8
- #define SpielerName(%0) Name[%0]
- #define HEAD_DATA "/Headphones.ini"
- //Enumerator
- enum MusicTitleEnum
- {
- TitleLink[256],
- TitleName[64]
- };
- //Variablen
- new Name[MAX_PLAYERS][MAX_PLAYER_NAME],
- /*
- Zum erstellen
- {"Link vom Lied oder Stream", "Name vom Lied oder Stream"},
- und dass dann in MusicTitle
- */
- MusicTitle[][MusicTitleEnum] =
- {
- {"http://listen.technobase.fm/dsl.pls", "TechnoBase.fm"},
- {"http://listen.housetime.fm/dsl.pls", "HouseTime.fm"}
- };
- public OnFilterScriptInit()
- {
- if(!dini_Exists(HEAD_DATA))dini_Create(HEAD_DATA);
- for(new i=0; i<MAX_PLAYERS; i++)if(IsPlayerConnected(i))GetPlayerName(i, SpielerName(i), MAX_PLAYER_NAME);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- GetPlayerName(playerid, SpielerName(playerid), MAX_PLAYER_NAME);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- StopAudioStreamForPlayer(playerid);
- DistableHeadPhones(playerid, dini_Int(HEAD_DATA, SpielerName(playerid)));
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- StopAudioStreamForPlayer(playerid);
- DistableHeadPhones(playerid, 0);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- ECMD2("/music", "/radio")
- {
- new str[512], nr=0;
- for(new i=0; i<sizeof(MusicTitle); i++)
- {
- if(!nr)format(str, 512, "%s", MusicTitle[i][TitleName]);
- else format(str, 512, "%s\n%s", str, MusicTitle[i][TitleName]);
- nr=1;
- }
- ShowPlayerDialog(playerid, DIALOG_MUSIC, DIALOG_STYLE_LIST, "Music Stream's", str, "Anhören", "Schliessen");
- return 1;
- }
- ECMD2("/mstop", "/rstop")
- {
- StopAudioStreamForPlayer(playerid);
- DistableHeadPhones(playerid, dini_Int(HEAD_DATA, SpielerName(playerid)));
- GameTextForPlayer(playerid, "~w~Stream gestoppt.", 1500, 1);
- return 1;
- }
- ECMD2("/headphones", "/kopfhörer")
- {
- if(dini_Int(HEAD_DATA, SpielerName(playerid)) == 0)
- {
- dini_IntSet(HEAD_DATA, SpielerName(playerid), 1);
- GameTextForPlayer(playerid, "~w~Kopfhoerer~n~aktiviert.", 1500, 1);
- }
- else
- {
- dini_IntSet(HEAD_DATA, SpielerName(playerid), 0);
- GameTextForPlayer(playerid, "~w~Kopfhoerer~n~deaktiviert.", 1500, 1);
- }
- return 1;
- }
- ECMD2("/mhelp", "/rhelp")
- {
- SendClientMessage(playerid, 0xFFFFFFFF, "Anhören: /radio, /music");
- SendClientMessage(playerid, 0xFFFFFFFF, "");
- SendClientMessage(playerid, 0xFFFFFFFF, "Stoppen: /rstop, /mstop");
- SendClientMessage(playerid, 0xFFFFFFFF, "");
- SendClientMessage(playerid, 0xFFFFFFFF, "Kopfhörer: /headphones, /kopfhörer");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if((dialogid == DIALOG_MUSIC) && response == 1)
- {
- PlayAudioStreamForPlayer(playerid, MusicTitle[listitem][TitleLink]);
- new str[90];
- format(str, 90, "~w~Du hoerst~n~%s", MusicTitle[listitem][TitleName]);
- GameTextForPlayer(playerid, str, 2000, 1);
- EnableHeadPhones(playerid);
- }
- return 1;
- }
- stock EnableHeadPhones(playerid)
- {
- if(IsPlayerAttachedObjectSlotUsed(playerid, HEAD_PHONES_SLOT))RemovePlayerAttachedObject(playerid, HEAD_PHONES_SLOT);
- SetPlayerAttachedObject(playerid, HEAD_PHONES_SLOT,19421,2,0.059999,0.022001,0.000000,-92.799964,-172.300109,89.600074,1.070999,0.955000,1.000000);
- return 1;
- }
- stock DistableHeadPhones(playerid, headon)
- {
- if(IsPlayerAttachedObjectSlotUsed(playerid, HEAD_PHONES_SLOT))RemovePlayerAttachedObject(playerid, HEAD_PHONES_SLOT);
- if(headon)SetPlayerAttachedObject(playerid, HEAD_PHONES_SLOT,19421,17,0.070999,0.076999,0.004999,102.700035,-79.999961,-82.699974,1.000000,1.000000,1.000000);
- return 1;
- }
Add Comment
Please, Sign In to add comment