Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #file "player.amx"
- #include <a_samp>
- #include <YSI\y_hooks>
- #define Audio(%1,%2) \
- PlayAudioStreamForPlayer(%1,%2)
- #define Stop(%1) \
- StopAudioStreamForPlayer(%1)
- new bool:RadioVehicle[MAX_PLAYERS char];
- hook OnFilterScriptInit() print(">> Radio R2 successfully loaded.");
- hook OnFilterScriptExit() print(">> Stop.");
- hook OnPlayerDeath(playerid, killerid, reason) StopAudioStreamForPlayer(playerid);
- hook OnPlayerDisconnect(playerid, reason) StopAudioStreamForPlayer(playerid);
- hook OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp(cmdtext, "/radio", true) == 0) return Useradio(playerid);
- if(strcmp(cmdtext, "/buyradio", true) == 0) return Buyradio(playerid);
- return SendClientMessage(playerid,-1,"SERVER: Unknown command.");
- }
- hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys & 8192)
- {
- if(GetPlayerVehicleID(playerid)){
- if(!RadioVehicle{playerid}){
- Audio(playerid,"http://webcast.emg.fm:55655/europaplus128.mp3");
- RadioVehicle{playerid} = true;
- SendClientMessage(playerid,-1,"To turn off the radio in the car then numpad4");
- SendClientMessage(playerid,-1,"To scroll through the radio, press N");
- }
- else{
- Stop(playerid);
- RadioVehicle{playerid} = false;
- }
- }
- }
- if(newkeys & KEY_NO){
- if(GetPlayerVehicleID(playerid)){
- new rand=random(6);
- switch(rand){
- case 0: Audio(playerid,"1");
- case 1: Audio(playerid,"2");
- case 2: Audio(playerid,"3");
- case 3: Audio(playerid,"4");
- case 4: Audio(playerid,"5");
- case 5: Audio(playerid,"6");
- case 6: Audio(playerid,"7");
- }
- }
- }
- return 1;
- }
- hook OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
- {
- SendClientMessage(playerid,-1,"To turn on the car radio, press numpad4");
- }
- else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) Stop(playerid);
- }
- hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
- switch(dialogid){
- case 1:{
- switch(listitem) {
- case 0:{
- Audio(playerid,"http://webcast.emg.fm:55655/europaplus128.mp3");
- SendClientMessage(playerid,-1,"Are you wearing the headphones.");
- }
- case 1:{
- Stop(playerid);
- SendClientMessage(playerid,-1,"Are you wearing the headphones.");
- }
- }
- }
- case 2:{
- switch(listitem) {
- case 0:{
- SetPVarInt(playerid,"Radio",1);
- SendClientMessage(playerid, -1, "You bought a player with headphones.");
- GivePlayerMoney(playerid, -5);
- }
- }
- }
- }
- }
- Useradio(playerid)
- {
- printf("Use radio %s.",Name(playerid));
- if(GetPVarInt(playerid,"Radio") == 0)return SendClientMessage(playerid, -1, "You do not have the player.");
- return ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Selecting a radio station","Europa plus\n\
- {FF0000}Radio OFF{FFFFFF}","ENTER","EXIT");
- }
- Buyradio(playerid)
- {
- printf("Buy radio %s.",Name(playerid));
- return ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Buy","Player","ENTER","EXIT");
- }
- stock Name(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- #endscript
Advertisement
Add Comment
Please, Sign In to add comment