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:
I shouldn't have to explain what that accutly does, its basic knowlage.
Okey, under the first { put:
Now, this stores the itemIDs. But you will need to fill it in. Heres how:
note how i put a comma between the items, this is need to seperate the itemIDs!
Now under that add:
Now you can save and close.
Using this in your methods and other crap.
Here is the code for it:
broken down:
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]
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
{
}
Okey, under the first { put:
Code:
public static int randomItem[] = {,};
Code:
public static int randomItem[] = {1038,1040,1042,1044,1046,1048};//all theses ids are the phats.
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);
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]

