Thread: [317] Music system

Results 1 to 4 of 4
  1. #1 [317] Music system 
    Registered Member
    Join Date
    Aug 2007
    Posts
    16
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Sup guys,

    Need help to make load and save methods for music system.

    Code:
    import java.util.LinkedList;
    import java.util.List;
    
    import com.rs2.model.players.Player;
    
    public class MusicManager {
    
    	private final Player player;
    	/**  A list of unlocked music. **/
    	private static List<Integer> unlockedMusics = new LinkedList<Integer>();
    	/** The auto-play flag. **/
    	private boolean auto = true;
    	/** The manual-play flag. **/
    	private boolean man;
    	/**  The looping flag. **/
    	private boolean loop;
    	
    
    	public MusicManager(Player player) {
    		this.player = player;
    	}
    
    	public void Init(){
    		// Add the default unlocked tracks.
    		unlockedMusics.add(62);
    		unlockedMusics.add(466);
    		unlockedMusics.add(0);
    		unlockedMusics.add(400);
    		unlockedMusics.add(547);
    		unlockedMusics.add(321);
    			
    		// Set the AUTO config.
    		player.getActionSender().sendConfig(18, 1);
    		player.getActionSender().sendString("AUTO", 4439);
    			
    		// Update track list.
    		updateTrackList();
    	}
    	
    	/**
    	 * Updates the music track list.
    	 */
    	public void updateTrackList() {
    		for (Music music : MusicLoader.getMusic()) {
    			if (music == null)
    				continue;
    			if (!unlockedMusics.contains(music.getSong()))
    				player.getActionSender().sendString("@[email protected]" +music.getName(), music.getFrame());
    			else
    				player.getActionSender().sendString("@[email protected]" +music.getName(), music.getFrame());
    		}
    	}
    	
    	public void playRegionMusic() {
    		if (!auto)
    			return;
    		int regionId = player.getPosition().getRegionId();
    		Music music = MusicLoader.forRegion(regionId);
    		if (music == null) {
    			music = MusicLoader.forSong(466);
    			player.getActionSender().sendSong(music.getSong());
    			player.getActionSender().sendString(music.getName(), 4439);
    			player.getActionSender().sendMessage("Music isn't added into this region yet! Region = "+ player.getPosition().getRegionId());
    			return;
    		}
    		player.getActionSender().sendSong(music.getSong());
    		player.getActionSender().sendString(music.getName(), 4439);
    		if (!unlockedMusics.contains(music.getSong())) {
    			unlockedMusics.add(music.getSong());
    			player.getActionSender().sendString("@[email protected]" +music.getName(), music.getFrame());
    			player.getActionSender().sendMessage("You have unlocked the song @[email protected]"+ music.getName() +"@[email protected]");
    		}
    	}
    	
        public boolean handleButton(int buttonId) {
        	switch (buttonId) {
    			case 24125: // AUTO feature.
    				if (!auto) {
    					this.auto = true;
    					this.man = false;
    					player.getActionSender().sendConfig(18, 1);
    					player.getActionSender().sendString("AUTO", 4439);
    				}
    				return true;
    			case 24126: // MAN feature.
    				if (!man) {
    					this.auto = false;
    					this.man = true;
    					player.getActionSender().sendConfig(18, 0);
    					player.getActionSender().sendString("MANUAL", 4439);
    				}
    				return true;
    			case 38197: // LOOP feature.
    				this.loop = !loop;
    				player.getActionSender().sendConfig(19, loop ? 1 : 0);
    				player.getActionSender().sendMessage("Music looping is now "+ (loop ? "enabled" : "disabled") +".");
    				return true;
        	}
        	
    		Music music = MusicLoader.forButton(buttonId);
    			if (music != null) {
    				if (!unlockedMusics.contains(music.getSong())) {
    					player.getActionSender().sendMessage("You have not unlocked this piece of music yet!");
    					return true;
    				}
    				player.getActionSender().sendSong(music.getSong());
    				player.getActionSender().sendString(music.getName(), 4439);
    				if (auto) {
    					this.auto = false;
    					this.man = true;
    					player.getActionSender().sendConfig(18, 0);
    				}
    			}
    		return false;
    	}
        
    	/**
    	 * Gets the list of unlocked musics.
    	 * @return The list of unlocked music.
    	 */
    	public static List<Integer> getUnlockedMusic() {
    		return unlockedMusics;
    	}
    }
    Cant make working load , save code for playersave. Someone can help me? Thanks

    Someone?
    Reply With Quote  
     

  2. #2  
    Registered Member 2nubs1cup's Avatar
    Join Date
    Jan 2013
    Posts
    955
    Thanks given
    77
    Thanks received
    86
    Rep Power
    0
    Look at how everything else is coded in playersave such as rights, bank, equipment items, then you should know what to do from there.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Mar 2018
    Posts
    5
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Use these methods and call them when your saving/loading your character.

    Code:
    public List<Integer> getUnlockedMusics() {
        return unlockedMusics;
    }
    
    public void setUnlockedMusics(List<Integer> unlockedMusics) {
        this.unlockedMusics = unlockedMusics;
    }
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Aug 2007
    Posts
    16
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Thanks . How to convert this to unlockedMusics?

    Code:
    JsonArray farmingTools = farming.getAsJsonArray("tools");
    		            if(farmingTools != null && farmingTools.size() > 0){
    		    			for (int i = 0; i < player.getFarmingTools().getTools().length; i++) {
    		    				if(i >= farmingTools.size())
    								break;
    		    				player.getFarmingTools().setTools(i,  farmingTools.get(i).getAsInt());
    		    			}
    		            }


    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Music system
    By buttercup in forum Show-off
    Replies: 13
    Last Post: 09-23-2014, 05:02 AM
  2. [317 - Delta] Basic Music System
    By Mainframe in forum Tutorials
    Replies: 14
    Last Post: 12-09-2012, 08:37 AM
  3. 317 Music system
    By mige5 in forum Show-off
    Replies: 5
    Last Post: 02-27-2012, 04:12 PM
  4. [$80 - $150][317] Full Music System
    By Genesis in forum Buying
    Replies: 6
    Last Post: 02-07-2012, 09:17 AM
  5. Having fun with 317 music system
    By Dust R I P in forum Show-off
    Replies: 27
    Last Post: 10-06-2010, 12:56 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •