Jump to content
  • 0
Sign in to follow this  
squashy

AdvancedCasket.java problems

Question

Okay so there's no problem that i can see and there's no errors that the compiler can pick up, but this doesn't seem to affect the casket in anyway. This is all saved in a file called AdvancedCasket.java and yes i have edit clickitem.java, but this doesnt work can anyone help out or point if i have done something wrong.

AdvancedCasket.java:

[Code]package server.model.players;

import server.model.players.Client;
import server.event.EventManager;
import server.event.Event;
import server.event.EventContainer;
import server.util.Misc;

public class AdvancedCasket{

public static boolean Canusebox = true;

public static int Common [] =
{4587, 3751, 4131, 2572, 7927, 1321, 1333, 1631, 1619, 1621, 1623, 1625, 1323, 542, 544, 3179, 536, 534, 383, 385 }; // Add more item Id's

public static int Uncommon [] =
{9185, 11732, 4732, 4087, 3481, 3483, 3486, 3488, 2669, 2671, 2673, 2675, 2677, 2653, 2655, 2657, 2659, 2661, 1079, 1093, 1113, 1127, 1147, 1163, 1185, 1201, 2591, 2593, 2595, 2597, 2607, 2609, 2611, 2613}; // Add more item Id's

public static int Rare [] =
{4151, 1038, 1040, 1042, 1044, 1046, 1048, 6585, 2615, 2617, 2619, 2621, 7386, 7390, 7394}; // Add more item Id's


public static int GenerateCasketPrize(final Client c) {
EventManager.getSingleton().addEvent(new Event() {
int BoxTimer = 2;
int Coins = 500000 + Misc.random(500000);
public void execute(EventContainer Box) {
Canusebox = false;
if (BoxTimer == 1) {
c.sendMessage("Retreiving your prize...");
}
if (BoxTimer == 0) {
c.getItems().addItem(995, Coins);
int Random = Misc.random(100);
if (Random <= 64) {
c.getItems().addItem(Common[(int) (Math.random() * Common.length)], 1);
c.sendMessage("Bad luck... You have recieved a [MENTION=231]red[/MENTION]@common [MENTION=24291]bla[/MENTION]@item and [MENTION=112005]Blu[/MENTION]@"+ Coins +" [MENTION=24291]bla[/MENTION]@coins.");
} else if (Random >= 65 && Random <= 89) {
c.getItems().addItem(Uncommon[(int) (Math.random() * Uncommon.length)], 1);
c.sendMessage("not bad! You have recieved an @[email protected] [MENTION=24291]bla[/MENTION]@item and [MENTION=112005]Blu[/MENTION]@"+ Coins +" [MENTION=24291]bla[/MENTION]@coins.");
} else if (Random >= 90 && Random <= 100) {
c.getItems().addItem(Rare[(int) (Math.random() * Rare.length)], 1);
c.sendMessage(" What luck! you have recieved an [MENTION=112005]Blu[/MENTION]@rare [MENTION=24291]bla[/MENTION]@item and [MENTION=112005]Blu[/MENTION]@"+ Coins +" [MENTION=24291]bla[/MENTION]@coins.");
}
}
if (c == null || BoxTimer <= 0) {
Box.stop();
Canusebox = true;
return;
}
if (BoxTimer >= 0) {
BoxTimer--;
}
}
}, 1000);
return Common[(int) (Math.random() * Common.length)];
}

public static void Open(int itemID, Client c) {
if (itemID == 405) {
if (c.getItems().freeSlots() > 1) {
if (Canusebox == true) {
c.getItems().deleteItem(405, 1);
GenerateMyrsteryPrize(c);
} else {
c.sendMessage("Please wait a few seconds before clicking this item again.");
}
} else {
c.sendMessage("You need 2 free inventory slots.");
}

}
}

}[/Code]

Clickitem.java:

[Code] if (itemId == 405)
if (c.getItems().playerHasItem(405)) {
AdvancedCasket.Open(itemId, c);
return;
}[/code] Edited by squashy

Share this post


Link to post
Share on other sites

25 answers to this question

Recommended Posts

  • 0
[quote name='kohlrak']What's it supposed to do, exactly?[/QUOTE]

It gives an item at random, its purpose is to act like a casket from a clue scroll casket on runescape.

Share this post


Link to post
Share on other sites
  • 0
Trying to add tabs where appropriate, i'm finding some weird things. I don't think your code posted correctly...

Share this post


Link to post
Share on other sites
  • 0
[quote name='falconpunch']Code tags please.[/QUOTE]

Okay has code tags now.

Share this post


Link to post
Share on other sites
  • 0
[quote name='kohlrak']Trying to add tabs where appropriate, i'm finding some weird things. I don't think your code posted correctly...[/QUOTE]

Yeah i know sorry, forgot to add code tags

Share this post


Link to post
Share on other sites
  • 0
GenerateMyrsteryPrize(c);

There's no GenerateMyrsteryPrize method in your class which could provide a problem (since it wouldn't give you any items in the end).

Share this post


Link to post
Share on other sites
  • 0
[quote name='Arbatel']GenerateMyrsteryPrize(c);

There's no GenerateMyrsteryPrize method in your class which could provide a problem (since it wouldn't give you any items in the end).[/QUOTE]

OKay hold up i'll fix and see what happens.

Share this post


Link to post
Share on other sites
  • 0
I would also recommend using an IDE so that way it's easier to find problems with your code.

Share this post


Link to post
Share on other sites
  • 0
Casket still wont open :/

Share this post


Link to post
Share on other sites
Sign in to follow this  

×