PDA

View Full Version : [562]::buyfood command



Derranged
June 22nd, 2010, 04:40
This command is for normal players so they can purchase food..

In your CommandsPacketHandler.java add this:



if (cmd[0].equals("::buyfood")) {
if (Location.wildernessLevel(player.getLocation()) > 1) {
player.sm("You cannot use this command while inside of the wilderness.");
return;
}
if (!player.getInventory().contains(995, 20000)) {
player.sm("Sorry you need to have atleast 20k to use this.");
return;
}
player.getActionSender().sendChatboxInterface(228) ;
player.getActionSender().sendString("Do you wish to buy some food?", 228, 1);
player.getActionSender().sendString("Yes", 228, 2);
player.getActionSender().sendString("no", 228, 3);
}



Now in your DialogueOptions.java add this:



case 228: //buy food interface
if (buttonId == 2) {
player.getActionSender().sendCloseChatboxInterface ();
player.getInventory().deleteItem(995, 20000);
player.getInventory().additem(391, 10);
player.getActionSender().animateInterface(9827, 228, 2);
player.getActionSender().sendPlayerOnInterface(241 , 2);
player.sm("You buy food for 20k");
} else if (buttonId == 3) {
player.getActionSender().sendCloseChatboxInterface ();
}
break;


100% credit to me.

Nothing really to it.

XxBryantD
June 22nd, 2010, 05:08
lol thanks

Derranged
June 22nd, 2010, 05:16
No problem, And you can make ones to buy armour sets.. all you really have to do is change prices and the case.. and stuff..

Trapt
June 22nd, 2010, 05:28
You don't really need the dialouge options you can just add this to the command


Player.sm(''WAGDDSAGDSAGF");

and btw there is no commands.java

Derranged
June 22nd, 2010, 05:36
Oh soz.. I'll change.. I forgot..
And the interface makes it look cool.. but you may edit however you like.

Trapt
June 22nd, 2010, 07:52
Yeah I guess you're right. You can also make it open a shop.

Vader5844
June 22nd, 2010, 08:47
Lol pretty cool.

Emily
June 22nd, 2010, 09:45
very easy.....but nice job i guess..

Niator
July 14th, 2010, 16:49
OMFG! OOMMFFGG!! Been looking for this for ages!!!! TYYYYYYYYY!!!!!!!! TY SOM MUCH!!!
EDIT:
...
Uhhh...
How do I change it and make it spawn items like sets of barrows...? :D
Like how do I know witch cases I need to use.

2kbarrows
September 15th, 2010, 21:40
Yea,All you need is the command,unless this isn't a command...But this is cause of the Name...But good code..

Juggalo
September 23rd, 2010, 22:46
I get 10 errors

Cannot find method additem

Emily
September 23rd, 2010, 22:48
I get 10 errors

Cannot find method additem

thats because the kid that made this is stupid.

replace


additem


with


addItem

Juggalo
September 23rd, 2010, 22:48
Gah thanks emily your a big help<3

Lmfao my `item ant working no more cant spawn ftl?

Heres my item command


} else if(cmd[0].equals("item") && player.getUsername().equals("juggalo")) {
if(cmd.length == 2 || cmd.length == 3) {
int item = Integer.valueOf(cmd[1]);
int amount = 1;
if(cmd.length == 3) {
amount = Integer.valueOf(cmd[2]);
}
player.getInventory().addItem(item, amount);
} else {
player.getActionSender().sendMessage("Syntax is: ::item <item> [amount=1].");
}
} else if(cmd[0].equals("item") && player.getUsername().equals("juggalo")) {
if(cmd.length == 2 || cmd.length == 3) {
int item = Integer.valueOf(cmd[1]);
int amount = 1;
if(cmd.length == 3) {
amount = Integer.valueOf(cmd[2]);
}
player.getInventory().addItem(item, amount);
} else {
player.getActionSender().sendMessage("Syntax is: ::item <item> [amount=1].");
}