NexusRSPS 0 #1 Posted July 29, 2014 If i try to add mystery box to my project insanity server, and i use this code: if(itemId == 6199) { c.getItems().deleteItem(6199, 1); int[] arrayOfItems = {1050,1048,1046,1044,1042,1040,1038}; c.getItems().addItem(arrayOfItems[Misc.random(arrayOfItems.length)], 1); } Then i get this error: Clickitem.java20 error: cannot find symbol c.getItems().addItem(arrayOfItems[Misc.random(arrayOfItems.length)], 1); Do i need to declare something? or am i using wrong code? Share this post Link to post Share on other sites
0 Arix 59 #2 Posted July 29, 2014 Have you imported all your used classes like Misc? Share this post Link to post Share on other sites
0 NexusRSPS 0 #3 Posted July 29, 2014 [quote name='Arix']Have you imported all your used classes like Misc?[/QUOTE] I don't think so. Share this post Link to post Share on other sites
0 Arix 59 #4 Posted July 29, 2014 You have to do that in order for it to work. Share this post Link to post Share on other sites
0 NexusRSPS 0 #5 Posted July 29, 2014 (edited) [quote name='Arix']You have to do that in order for it to work.[/QUOTE] But if i remove that code, i can compile again, but mystery box still wont work. Edited July 29, 2014 by jesse 1355 Share this post Link to post Share on other sites
0 Arix 59 #6 Posted July 29, 2014 [quote name='jesse 1355']Could you please tell me how to do that?[/QUOTE] In your src folder, look for the file Misc.java, once you found it, enlist all directories you entered to get to it. Example: if Misc.java is in util folder then my enlisting would be com/myexamplersps/util If you don't understand this, just take a screenshot of the location of Misc.java with the path in windows explorer visible. Share this post Link to post Share on other sites
0 NexusRSPS 0 #7 Posted July 29, 2014 [quote name='Arix']In your src folder, look for the file Misc.java, once you found it, enlist all directories you entered to get to it. Example: if Misc.java is in util folder then my enlisting would be com/myexamplersps/util If you don't understand this, just take a screenshot of the location of Misc.java with the path in windows explorer visible.[/QUOTE] It looks like this.. [IMG]http://i.imgur.com/XZSDF63.png[/IMG] Share this post Link to post Share on other sites
0 Arix 59 #8 Posted July 29, 2014 [quote name='jesse 1355']It looks like this.. [IMG]http://i.imgur.com/XZSDF63.png[/IMG][/QUOTE] Okay so in your Clickitem.java where the error was look if [code] import server.util.Misc; [/code] exists, if not add it at the top where the other import lines are. Share this post Link to post Share on other sites
0 NexusRSPS 0 #9 Posted July 29, 2014 [quote name='Arix']Okay so in your Clickitem.java where the error was look if [code] import server.util.Misc; [/code] exists, if not add it at the top where the other import lines are.[/QUOTE] K, it worked, i added that code, compiled, and didn't get errors, but my mystery boxes aren't still working, do i still need to add something? Share this post Link to post Share on other sites
0 Arix 59 #10 Posted July 29, 2014 [quote name='jesse 1355']K, it worked, i added that code, compiled, and didn't get errors, but my mystery boxes aren't still working, do i still need to add something?[/QUOTE] I don't know :P Mystery boxes are unrelated to Java. You may have used an incorrect ID or may have put the if block in a wrong place. Share this post Link to post Share on other sites
0 Scriptss 0 #11 Posted July 29, 2014 [quote name='jesse 1355']If i try to add mystery box to my project insanity server, and i use this code: if(itemId == 6199) { c.getItems().deleteItem(6199, 1); int[] arrayOfItems = {1050,1048,1046,1044,1042,1040,1038}; c.getItems().addItem(arrayOfItems[Misc.random(arrayOfItems.length)], 1); } Then i get this error: Clickitem.java20 error: cannot find symbol c.getItems().addItem(arrayOfItems[Misc.random(arrayOfItems.length)], 1); Do i need to declare something? or am i using wrong code?[/QUOTE] sonic released a tutorial for this ages ago [code] if (itemId == 6199) { int mysteryReward = Misc.random(5); // Coded by Sonic chao if (mysteryReward == 1) { c.getItems().addItem(1050, 1); c.getItems().deleteItem(6199, 1); c.sendMessage("Thanks for voting!"); } else if (mysteryReward == 2) { c.getItems().addItem(4083, 1); c.getItems().deleteItem(6199, 1); c.sendMessage("Thanks for voting!"); } else if (mysteryReward == 3) { c.getItems().addItem(6585, 1); c.getItems().deleteItem(6199, 1); c.sendMessage("Thanks for voting!"); } else if (mysteryReward == 4) { c.getItems().addItem(1038, 1); c.getItems().addItem(1040, 1); c.getItems().addItem(1042, 1); c.getItems().addItem(1044, 1); c.getItems().addItem(1046, 1); c.getItems().addItem(1048, 1); c.getItems().deleteItem(6199, 1); c.sendMessage("Thanks for voting!"); } else if (mysteryReward == 5) { c.getItems().addItem(1055, 1); c.getItems().deleteItem(6199, 1); c.sendMessage("Thanks for voting!"); } } [/code] keep misc imported as well Share this post Link to post Share on other sites
if(itemId == 6199) {
c.getItems().deleteItem(6199, 1);
int[] arrayOfItems = {1050,1048,1046,1044,1042,1040,1038};
c.getItems().addItem(arrayOfItems[Misc.random(arrayOfItems.length)], 1);
}
Then i get this error:
Clickitem.java20 error: cannot find symbol c.getItems().addItem(arrayOfItems[Misc.random(arrayOfItems.length)], 1);
Do i need to declare something? or am i using wrong code?
Share this post
Link to post
Share on other sites