• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Tut][317-PI] Reward Chest

Initiate Mage
Joined
Oct 28, 2010
Messages
3
Reaction score
0
Purpose: giving a random item
Difficulty: 1.0?
Tested On(if it applies): Any pi source


Step 1:

Code:
private static int[][] randomItems = {itemid,itemamount};//Example {4151, 1}
                                    private int random = (int)(Math.random() * (randomItems.length - 1));
                                    case id: // chestId
    			             if(c.getItems().playerHasItem(itemId, 1)) {//ItemId                                                      
                                                 c.getItems().deleteItem(itemId, c.getItems().getItemSlot(itemId),1);
                                                 c.getItems().addItem(randomItems[random][1], 1);
                                         } else {
                                                 c.sendMessage("Sorry but you ain't got the required item to use this option.");
                                         }
    				break;

Now above the switch statement add:

Code:
if(c.actionTimer > 0) {
    			return;
    		}
    		c.actionTimer = 4;

Step 2:

Declare in player.java

Code:
public long actionTimer;

Step 3:

In client.java locate
Code:
process() {
and below it add:


Code:
if (actionTimer > 0) {
    			actionTimer--;
    		}
 
Back
Top