Jump to content
  • 0
Sign in to follow this  
Hellapagoina

Starterpack Command Issue

Question

Everytime I try to spawn an item on the starterpack source I am unable. Nothing pops up on chat or in my inventory and I don't know what to do to fix this issue. Any suggestions?

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0
Do you have a command to spawn items? also try using this one.
[QUOTE] if (cmd[0].equalsIgnoreCase("itemn")) {
StringBuilder sb = new StringBuilder(cmd[1]);
int amount = 1;
if (cmd.length > 2) {
for (int i = 2; i < cmd.length; i++) {
if (cmd[i].startsWith("+")) {
amount = Integer.parseInt(cmd[i].replace("+", ""));
} else {
sb.append(" ").append(cmd[i]);
}
}
}
String namee = sb.toString().toLowerCase().replace("[", "(")
.replace("]", ")").replaceAll(",", "'");
for (int i = 0; i < Utils.getItemDefinitionsSize(); i++) {
ItemDefinitions def = ItemDefinitions
.getItemDefinitions(i);
if (def.getName().toLowerCase().equalsIgnoreCase(namee)) {
player.getInventory().addItem(i, amount);
player.stopAll();
player.getPackets().sendGameMessage("Found item " + namee + " - id: " + i + ".");
return true;
}
}
player.getPackets().sendGameMessage(
"Could not find item by the name " + namee + ".");
return true;
} [/QUOTE]
What that will do is say you want to spawn a blue partyhat you would do ;;itemn blue_partyhat and it would give you the blue partyhat and the id of it.

Share this post


Link to post
Share on other sites
  • 0
THat goes in my commands.java so wherever your commands are you need to paste it their.

Share this post


Link to post
Share on other sites
  • 0
[QUOTE]if (cmd[0].equalsIgnoreCase("item")) {
if (player.getUsername().equalsIgnoreCase("Your name") || player.getUsername().equalsIgnoreCase("Your friend name/other staff")) {
if (cmd.length < 2) {
player.getPackets().sendGameMessage(
"Use: ::item id (optional:amount)");
return true;
}
try {
int itemId = Integer.valueOf(cmd[1]);
player.getInventory().addItem(itemId,
cmd.length >= 3 ? Integer.valueOf(cmd[2]) : 1);
player.stopAll();
} catch (NumberFormatException e) {
player.getPackets().sendGameMessage(
"Use: ::item id (optional:amount)");
// }
}
return true;
} [/QUOTE]

Thats the command you want? Edited by skatebourddd

Share this post


Link to post
Share on other sites
  • 0
[quote name='skatebourddd']Switch tyler/rob to your name or whoever's name[/QUOTE]

You have commented out the part that only allows tyler/rob to use the command.

Share this post


Link to post
Share on other sites
  • 0
Ziek all you have to do is put ziek in for tyler for it to be a command for the account ziek. That's what i meant.

Share this post


Link to post
Share on other sites
  • 0
[quote name='skatebourddd']Ziek all you have to do is put ziek in for tyler for it to be a command for the account ziek. That's what i meant.[/QUOTE]

He was referring to this

[code]
[B][COLOR="#FF0000"]//[/COLOR][/B]if (player.getUsername().equalsIgnoreCase("tyler") || player.getUsername().equalsIgnoreCase("Rob"))
[/code]

[url=http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html] comments [/url]

Share this post


Link to post
Share on other sites
  • 0
[quote name='Fall Out']He was referring to this

[code]
[B][COLOR="#FF0000"]//[/COLOR][/B]if (player.getUsername().equalsIgnoreCase("tyler") || player.getUsername().equalsIgnoreCase("Rob"))
[/code]

[url=http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html] comments [/url][/QUOTE]

Sorry that is multiple people being able to access the command. if you want just one person just do this
[QUOTE]if (player.getUsername().equalsIgnoreCase("ziek"))[/QUOTE]

or if you want multiple people do this

[QUOTE]if (player.getUsername().equalsIgnoreCase("ziek") || player.getUsername().equalsIgnoreCase("fall out")) [/QUOTE]
Then both ziek and fall out can use the command. Is that what you're asking?

Share this post


Link to post
Share on other sites
  • 0
Never mind derp! sorry i edited it...
the // wasn't suppose to be their.

Share this post


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

×