RuneScape 2 Development > Snippets

Post your code snippets here! [Updated 08/09/2012]

<<< (123/172) >>>

arham 4:

--- Quote from: AtomicInt_ on February 17, 2012, 10:40:41 PM ---What you said made no sense, like this?

--- Code: Java ---     private CITY_MUSIC play;     public boolean isInvarrock() {        return (isInArea(3158,3469, 3258, 3258));    }     if (isInVarrock()) {        playSound(play.VARROCK);    } else {        stopSound();    }     
--- End quote ---

Hmm, that seems like a better code, since what I did was add the play.Varrock elsewhere.

The Wanderer:
Or you could add the area to the enum and then only have to do playMusic(player) whenever the playing region changes. Might have more arguments than that... :P

RandQm:

--- Quote from: arham 4 on February 17, 2012, 10:35:37 PM ---In my process to make music in my rsps, I put in Music.java an enum and it lists all the cities and there ID list. So, it makes it easier as you can refer it as InVarrock.

My incomplete Enum list:


--- Code: Java ---   public static enum CITY_MUSIC {      VARROCK(169),      WATERFALL(125),      FALLADOR(15),          LUMBRIDGE(2),          START(1),          DRAYNOR(3),          STRANGE(7),          CAMELOT(8),          RIMMINGTON(12),          CW_WIN(16),          FLOWER_MUSIC(18),          FLOWER_MUSIC2(20),          FLOWER_MUSIC3(21),          GOBLIN(23),          KBD_ATTACK_2(25),          SARIM(35),          KHARID(36),          CLAN_WARS(47),          WILDERNESS(48),          FALADOR_CROSS(49),          KHARID2(50),          FAIRY(52),          TO_VARROCK(54),          ESSENSE(57),          JUNGLE(58),          CANAFIS(61),          TUTORIAL(62),          SWAMP(64),          DESSERT(69),          FALADOR2(72),          LOST(73),          CATHERBY(74),          LUMBRIDGE2(76),          FLOWER_MUSIC4(77),          DRAYNOR_MANOR(87),          KARAMJA(92),                          //F2P Side          SAWMILL(93),          EDGEVILLE(96),          WILDERNESS2(103),          CAMELOT2(104),          VARROCKR(106),                        //Varrock Center          UP(126),          AROUND(107),                          //Of FALLY and RIMMINGTON          lANDV(111),                           //Lumbridge - Varrock          ARDOUGNE(116),          FAIRY2(118),          FISHING(119),                         //At CATHERBY          WILDERNESS3(121),          MININGINK(123);                       //The Mine in AL-KHARID 
Will add the full when I am done with it.

TIP: If anyone will use this, you can refer this like:


--- Code: Java ---public boolean isInvarrock()        {    if (isInArea(3158,3469, 3258, 3258)) return true;    return false;} 
for Varrock under


--- Code: Java ---public boolean HasItemAmount(int itemID, int itemAmount) { 
--- End quote ---

DUDE wtf that is literally from a tutorial, ive seen that code before

enzo42:

--- Quote from: RandQm on February 16, 2012, 03:16:32 PM ---
--- Quote from: enzo42 on February 14, 2012, 09:41:49 AM ---Delta snippet's i made:

--- End quote ---

I like the part where it's 95% similar to what I released as tutorial a while back.

Anyways, thought about sharing this, coming from my survival project.
--- End quote ---

What tutorial if i may ask?

Ryley:
317 Client Response Codes - If anyone needs them, I began writing another framework last night, and well, last time I tried, I knew nothing of the 317 protocol, and failed, badly. Now, I'm coming along with it at a much faster pace and have a lot done, I am proud of myself. :D


--- Code: Java ---public final class ResponseCodes {     /**     * This return code makes the client wait 2 seconds then try     * to login once more.     */    public static final int WAIT_2_SEC = 1;     /**     * This return code notifies the client that the     * login request was a success.     */    public static final int SUCCESS = 2;     /**     * This return code notifies the client that the     * login request had invalid details.     *      * <p><b>Message:</b> Invalid username or password.</p>     */    public static final int INVALID_DETAILS = 3;     /**     * This return code notifies the client that the     * login request failed because the user is banned.     *      * <p><b>Message:</b> Your account has been disabled. Please     * check your message-center for details.</p>     */    public static final int BANNED = 4;     /**     * This return code notifies the client that the login     * request failed because the user is already logged in.     *      * <p><b>Message:</b> Your account is already logged in.     * Try again in 60 secs...</p>     */    public static final int ALREADY_LOGGED_IN = 5;     /**     * This return code notifies the client that it's     * version is outdated.     *      * <p><b>Message:</b> RuneScape has been updated! Please     * reload this page.</p>     */    public static final int OUTDATED_CLIENT = 6;     /**     * This return code notifies the client that the     * login request failed because the world is full.     *      * <p><b>Message:</b> This world is full. Please use a different     * world.</p>     */    public static final int WORLD_FULL = 7;     /**     * This return code notifies the client that the login     * server is not available.     *      * <p><b>Message:</b> Unable to connect. Login server offline.</p>     */    public static final int LOGIN_SERVER_OFFLINE = 8;     /**     * This return code notifies that the user already has     * too many connections from the same IP address.     *      * <p><b>Message:</b> Login limit exceeded. Too many connections     * from your address.</p>     */    public static final int LOGIN_LIMIT_EXCEEDED = 9;     /**     * This return code notifies the client that the session key     * IDs were modified.     *      * <p><b>Message:</b> Unable to connect. Bad session id.</p>     */    public static final int BAD_SESSION_ID = 10;     /**     * This return code notifies the client that the login server     * rejected their request for various reasons.     *      * <p><b>Message:</b> Login server rejected session. Please try again.</p>     */    public static final int LOGIN_SERVER_REJECTED = 11;     /**     * This return code notifies the user that they are a non-member and     * are trying to login to a members world.     *      * <p><b>Message:</b> You need a members account to login to this world.     * Please subscribe, or use a different world.</p>     */    public static final int MEMBERS_WORLD = 12;     /**     * This return code notifies the client that the login request could not     * be fully interpreted.     *      * <p><b>Message:</b> Could not complete login. Please try using a different world.</p>     */    public static final int COULD_NOT_COMPLETE_LOGIN = 13;     /**     * This return code notifies the user that an update in the world they     * are trying to connect to is currently in a system update.     *      * <p><b>Message:</b> The server is being updated. Please wait 1 minute and try again.</p>     */    public static final int UPDATE_IN_PROGRESS = 14;     /**     * This return code notifies the user that their failed login attempts     * has passed the limit for the time, and to wait 1 minute and try again.     *      * <p><b>Message:</b> Login attempts exceeded. Please wait 1 minute and try again.</p>     */    public static final int LOGIN_ATTEMPTS_EXCEEDED = 16;     /**     * This return code notifies the user that their account is standing in     * a members-only area and must login to a members server to remove it from     * the area.     *      * <p><b>Message:</b> You are standing in a members-only area.     * To play on this world move to a free area first.</p>     */    public static final int MEMBERS_AREA = 17;     /**     * This return code notifies the client that the login server they attempted to     * ues is not valid.     *      * <p><b>Message:</b> Invalid loginserver requested. Please try using a different world.</p>     */    public static final int INVALID_LOGIN_SERVER = 20;     /**     * This return code notifies the client that they have just left another world and their profile     * will be transfered in a number of seconds.     *      * <p><b>Message:</b> You have only just left another world. Your profile will be transferred in: (number) seconds.</p>     */    public static final int JUST_LEFT_ANOTHER_WORLD = 21; } 

EDIT: The RSWIkia is extremely helpful, thank's for that.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version
Powered by SMFPacks SEO Pro Mod |