Giving a random item(s).

Discussion in 'Archives' started by Sam`, Feb 18, 2008.

Giving a random item(s).
  1. Unread #1 - Feb 18, 2008 at 5:33 PM
  2. Sam`
    Joined:
    Feb 18, 2008
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0

    Sam` Newcomer

    Giving a random item(s).

    This tutorial should explain and show you how to make a command, item on object etc etc give you a random item(s).

    Right, to save some space and just to make it easier for you, make a new java file and call it RandomItems and put this in it:
    Code:
    /*
    We will be using this to store the main code of our lil giving of the random item!
    */
    import java.io.*;
    public class RandomItems
    {
    }
    
    I shouldn't have to explain what that accutly does, its basic knowlage.

    Okey, under the first { put:
    Code:
    public static int randomItem[] = {,};
    Now, this stores the itemIDs. But you will need to fill it in. Heres how:
    Code:
    public static int randomItem[] = {1038,1040,1042,1044,1046,1048};//all theses ids are the phats.
    note how i put a comma between the items, this is need to seperate the itemIDs!

    Now under that add:
    Code:
        public static int randomPhat() //Name of the static int.
        {
        	return randomItem[(int)(Math.random()*randomItem.length)]; //Taking the randomItem int.
        }
    
    Now you can save and close.

    Using this in your methods and other crap.

    Here is the code for it:
    Code:
    addItem(RandomItems.randomPhat(), 1);
    broken down:
    Code:
    addItem(THEFILEITISIN.NAMEOFTHESTATICINT(), AMOUNT);
    THEFINEITISIN - This is the file the int is in, in our case it is RandomItems.
    NAMEOFTHESTATICINT - This is the name of the static int. In our case its randomPhat.
    AMOUNT - The amount of the random item(Would be the same item i think). If its not noted or stackable its best to leave as 1.

    I believe you can do this with; Words and EXP.

    Credits 100% Me. - MOST OF THIS WAS WRITTEN IN THE POST BOX.

    Any questions add my msn: [email protected]
     
  3. Unread #2 - Feb 18, 2008 at 5:36 PM
  4. No_name
    Joined:
    Nov 9, 2007
    Posts:
    92
    Referrals:
    0
    Sythe Gold:
    0

    No_name Member

    Giving a random item(s).

    leeched from moparscape.org noob
     
  5. Unread #3 - Feb 18, 2008 at 5:37 PM
  6. Sam`
    Joined:
    Feb 18, 2008
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0

    Sam` Newcomer

    Giving a random item(s).

    ... I am I Samn I from moparscape. Want a PM?
     
  7. Unread #4 - Feb 21, 2008 at 8:52 PM
  8. Samarkov
    Joined:
    Feb 21, 2008
    Posts:
    147
    Referrals:
    0
    Sythe Gold:
    0

    Samarkov Active Member

    Giving a random item(s).

    Nice, this will be helpful! Thanks
    ~~Samarkov
     
< Post your leet bank pictures here :d | A Few problems in creating my private server >

Users viewing this thread
1 guest


 
 
Adblock breaks this site