Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Default-Style radio stream system
- @Author: Bitrate
- http://forum.sa-mp.com/member.php?u=143266
- */
- #include <a_samp>
- #define MAX_STATIONS 5
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- new Text:pRadioStation[MAX_PLAYERS] = {Text:INVALID_TEXT_DRAW, ...};
- new HideTimer[MAX_PLAYERS];
- forward UpdateStation(playerid, StationiD);
- forward RadioText(playerid);
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Vehicle radio system by Bitrate.\n");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- pRadioStation[playerid] = TextDrawCreate(220, 25, "Radio off");
- TextDrawFont(pRadioStation[playerid], 2);
- TextDrawUseBox(pRadioStation[playerid], 0);
- TextDrawLetterSize(pRadioStation[playerid], 0.7, 1.3);
- TextDrawFont(pRadioStation[playerid], 2);
- TextDrawSetShadow(pRadioStation[playerid],0);
- TextDrawSetOutline(pRadioStation[playerid],1);
- TextDrawColor(pRadioStation[playerid],0x946110FF);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
- {
- SendClientMessage(playerid, 0xFF0000FF, "To select the next radio press ~k~~CONVERSATION_YES~ and to select the prior radio press ~k~~CONVERSATION_NO~");
- UpdateStation(playerid, 1);
- }
- else if(newstate != PLAYER_STATE_DRIVER || newstate != PLAYER_STATE_PASSENGER && oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
- {
- StopAudioStreamForPlayer(playerid);
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public UpdateStation(playerid, StationiD)
- {
- if(StationiD == 0)
- {
- KillTimer(HideTimer[playerid]);
- StopAudioStreamForPlayer(playerid);
- SetPVarInt(playerid, "StationiD", 0);
- TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
- TextDrawSetString(pRadioStation[playerid], "Radio Off");
- HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
- }
- if(StationiD == 1)
- {
- KillTimer(HideTimer[playerid]);
- PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=hits.mp3.m3u");
- SetPVarInt(playerid, "StationiD", 1);
- TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
- TextDrawSetString(pRadioStation[playerid], "The Hits Radio");
- HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
- }
- else if(StationiD == 2)
- {
- KillTimer(HideTimer[playerid]);
- PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=metro.mp3.m3u");
- SetPVarInt(playerid, "StationiD", 2);
- TextDrawSetString(pRadioStation[playerid], "Metro");
- TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
- HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
- }
- else if(StationiD == 3)
- {
- KillTimer(HideTimer[playerid]);
- PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=kerrang.mp3.m3u");
- SetPVarInt(playerid, "StationiD", 3);
- TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
- TextDrawSetString(pRadioStation[playerid], "Kerrang");
- HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
- }
- else if(StationiD == 4)
- {
- KillTimer(HideTimer[playerid]);
- PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=magic1054.mp3.m3u");
- SetPVarInt(playerid, "StationiD", 4);
- TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
- TextDrawSetString(pRadioStation[playerid], "Magic 105.4");
- HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
- }
- else if(StationiD == 5)
- {
- KillTimer(HideTimer[playerid]);
- PlayAudioStreamForPlayer(playerid, "http://tx.whatson.com/icecast.php?i=smashhits.mp3.m3u");
- SetPVarInt(playerid, "StationiD", 5);
- TextDrawShowForPlayer(playerid, pRadioStation[playerid]);
- TextDrawSetString(pRadioStation[playerid], "Smash Hits");
- HideTimer[playerid] = SetTimerEx("RadioText", 3000, false, "i", playerid);
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if(PRESSED(KEY_YES))
- {
- if(GetPVarInt(playerid, "StationiD") >= MAX_STATIONS) SetPVarInt(playerid, "StationiD", -1);
- UpdateStation(playerid, GetPVarInt(playerid, "StationiD") + 1);
- }
- else if(PRESSED(KEY_NO))
- {
- if(GetPVarInt(playerid, "StationiD") <= 0) SetPVarInt(playerid, "StationiD", MAX_STATIONS + 1);
- UpdateStation(playerid, GetPVarInt(playerid, "StationiD") - 1);
- }
- }
- return 1;
- }
- public RadioText(playerid)
- {
- TextDrawHideForPlayer(playerid, pRadioStation[playerid]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement